# Claude Style

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
[![npm version](https://img.shields.io/npm/v/claude-style.svg)](https://www.npmjs.com/package/claude-style)
[![npm downloads](https://img.shields.io/npm/dm/claude-style.svg)](https://www.npmjs.com/package/claude-style)
[![CI](https://github.com/cativo23/claude-style/actions/workflows/ci.yml/badge.svg)](https://github.com/cativo23/claude-style/actions/workflows/ci.yml)
[![Qwen Code Compatible](https://img.shields.io/badge/Qwen%20Code-1.0+-blue.svg)](https://github.com/QwenLM/qwen-code)
[![Code of Conduct](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md)

Make Qwen Code behave more like Claude Code. Not a clone — a **style pack** that gives Qwen Claude's communication patterns, task rules, and workflow conventions.

> [!NOTE]
> This project replicates ~60% of Claude Code's observable behavior (formatting, style, task rules). Deep behavioral traits (tool-calling mechanics, risk assessment, meta-cognition) depend on model training and cannot be replicated via prompts alone. See [What This Does](#what-this-does--does-not) for details.

---

## Quick Start

### One-line install

```bash
npx claude-style
```

### Or from GitHub

```bash
qwen extensions install https://github.com/cativo23/claude-style
```

### Verify

Inside Qwen Code:
```
> /load-core-prompts
> /memory show
```

You should see Claude-style rules loaded.

---

## What This Does (and Does Not)

### What it DOES

| Feature | Effectiveness |
|---------|--------------|
| **Communication style** — concise, no fluff, no comments in code | ~80% |
| **Task rules** — read before modify, no unnecessary additions, no premature abstractions | ~70% |
| **Reasoning patterns** — systematic approach, show your work | ~65% |
| **Tool constraints** — proper tool usage patterns | ~45% |
| **Git safety** — no destructive operations, no hook skipping | ~70% |

### What it does NOT

- **Not a Claude clone** — Qwen remains Qwen with its own model characteristics
- **Not identical tool-calling** — Qwen's tools differ from Claude's architecture
- **Not deep behavioral replication** — RLHF-dependent traits (risk assessment, refusal patterns) remain Qwen's own
- **Not security-equivalent** — Qwen has its own safety guardrails, not Claude's

## Verified Results

Tested with 3-run A/B/C comparison ([full results](docs/benchmark-results.md)).

### Code Conciseness (lines, lower is better)

| Tool | Avg Lines | vs Vanilla |
|------|----------:|-----------:|
| Qwen Vanilla | 80 | — |
| **Qwen + Claude Style** | **33** | **−58%** |
| Claude Code Native | 28 | −65% |

### Explanation Brevity (words, lower is better)

| Tool | Avg Words | vs Vanilla |
|------|----------:|-----------:|
| Qwen Vanilla | 75 | — |
| **Qwen + Claude Style** | **35** | **−53%** |
| Claude Code Native | 68 | −9% |

**Claude Style achieves 58% code reduction and 53% text reduction vs vanilla Qwen**, getting within 17% of Claude Code Native in code conciseness while being even more concise in explanations than Claude itself.

> [!IMPORTANT]
> **Less code ≠ worse code.** The generated code is **equally functional and correct** — just more concise. Claude Style removes docstrings, type hints, and unnecessary features that weren't asked for. A 33-line class that works is better than a 80-line class that does the same thing with extra documentation.

### The honest number

**~60% behavioral similarity** to Claude Code. You'll notice:
- More concise responses
- No unnecessary code comments
- Reading files before editing
- No feature creep beyond what's asked

You won't notice:
- Identical error handling patterns
- Same tool invocation order
- Claude's exact reasoning texture

---

## Slash Commands

| Command | Description |
|---------|-------------|
| `/load-core-prompts` | Load essential Claude behavioral rules |
| `/claude-review` | Review code with Claude-style guidelines |
| `/claude-refactor` | Refactor without premature abstractions |
| `/claude-debug` | Debug with systematic Claude methodology |
| `/claude-plan` | Plan features in 5-phase Claude style |
| `/claude-explore` | Explore codebase with Claude patterns |
| `/claude-security` | Security review with Claude guidelines |
| `/claude-commit` | Create commits + PRs Claude-style |

---

## How It Works

```
Claude Code System Prompts (MIT, Piebald-AI)
         ↓
   Extracted & Adapted
         ↓
   Qwen Extension + Hooks
         ↓
   Behavioral Rules in Qwen
```

### Architecture

1. **Context Files** — `QWEN.md` loaded automatically with core rules
2. **Hooks** — Inject constraints at `SessionStart`, `PreToolUse`, `SubagentStart`
3. **Skills** — Auto-activated by context (review, debug, plan)
4. **Commands** — Manual activation via slash commands

### Why hooks + context files?

Qwen Code doesn't expose a true system prompt API. We use `additionalContext` injection via hooks, which is the closest mechanism available. It's not a perfect replacement for Claude's system prompt slot, but it's effective for behavioral rules.

See [docs/architecture.md](docs/architecture.md) for details.

---

## Prompts Included

Extracted from [Piebald-AI/claude-code-system-prompts](https://github.com/Piebald-AI/claude-code-system-prompts) (MIT License) and adapted for Qwen.

### Core Rules (~10 files)
- Communication style
- Read before modify
- No unnecessary additions
- No premature abstractions
- No unnecessary error handling
- Security guidelines
- Software engineering focus
- Minimize file creation
- No compatibility hacks
- No time estimates

### Tool Constraints (~3 files)
- Edit tool best practices
- Search tool patterns
- Bash tool constraints

See [prompts/](prompts/) for the full list.

---

## Installation Options

### Option 1: npm (recommended)
```bash
npx claude-style
```

### Option 2: Qwen extension
```bash
qwen extensions install https://github.com/cativo23/claude-style
```

### Option 3: Manual
```bash
git clone https://github.com/cativo23/claude-style
cd claude-style
./scripts/setup.sh
```

---

## Verified Results

Benchmarked with 3-run A/B/C comparison:

| Metric | Qwen Vanilla | Qwen + Claude Style | Improvement |
|--------|-------------|-------------------|------------|
| Code lines | 80 avg | 33 avg | **−58%** |
| Explanation words | 75 avg | 35 avg | **−53%** |
| Docstrings | 14 | 0 | Cleaner code |

**[Full benchmark results →](docs/benchmark-results.md)**

## Updating

```bash
# If installed via npx
npx claude-style@latest

# If installed as extension
cd ~/.qwen/extensions/claude-style
git pull
```

Or use the built-in sync script:
```bash
./scripts/sync-prompts.sh
```

---

## Testing

```bash
npm test
# or
./scripts/test.sh
```

This runs behavioral checks comparing vanilla Qwen vs Qwen with Claude Style loaded.

---

## Security

This package:
- Has **zero runtime dependencies**
- Runs with **user-level privileges** only
- Creates a **backup** of your settings before any modification
- Makes **no network calls** during installation or runtime

See [SECURITY.md](SECURITY.md) for our full security policy and vulnerability reporting process.

## What's the Catch?

**No catch.** This is:
- Open source (MIT)
- Free to use
- Based on publicly available Claude prompts
- Honest about limitations

**What we don't promise:**
- Perfect Claude clone
- Model-level behavior replication
- Security equivalence

**What we do promise:**
- Qwen will be more concise, direct, and structured
- You'll notice the style difference from day one
- Updates track Claude Code prompt changes

---

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md).

Quick version:
1. Fork the repo
2. Add/modify prompts or skills
3. Run `./scripts/test.sh`
4. Open a PR

We especially welcome:
- Better prompt translations
- New skills
- Bug fixes
- Documentation improvements

---

## Acknowledgments

- [Piebald-AI](https://github.com/Piebald-AI/claude-code-system-prompts) — for extracting Claude Code system prompts (MIT License)
- [Qwen Code](https://github.com/QwenLM/qwen-code) — for the extension system and hooks

---

## License

MIT. See [LICENSE](LICENSE).

Claude Code system prompts are from [Piebald-AI/claude-code-system-prompts](https://github.com/Piebald-AI/claude-code-system-prompts), also MIT.
