azclaude-copilot 0.4.35 → 0.4.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,8 +8,8 @@
8
8
  "plugins": [
9
9
  {
10
10
  "name": "azclaude",
11
- "description": "AZCLAUDE is a complete AI coding environment for Claude Code. It installs 36 commands, 9 auto-invoked skills, 15 specialized agents, 4 hooks, and a persistent memory system — in one command.\n\nKey features:\n• Memory across sessions — goals.md + checkpoints injected automatically before every session\n• Self-improving loop — /reflect fixes stale CLAUDE.md rules, /reflexes learns from tool-use patterns, /evolve creates agents from git evidence\n• Autonomous copilot mode — /copilot runs a three-tier team (orchestrator → problem-architect → milestone-builder) across sessions until the product ships\n• Spec-driven workflow — /constitute writes project rules, /spec writes structured ACs, /analyze detects plan drift and ghost milestones, /blueprint traces every milestone to a spec\n• Security layer — 111-rule environment scan (/sentinel), pre-write secret blocking, pre-ship credential audit\n• Progressive levels 0–10 — start with CLAUDE.md, grow into multi-agent pipelines and self-evolving environments\n• Zero dependencies — no npm packages, no external APIs, no vector databases. Plain markdown files and Claude Code's native architecture.\n• Smart install — npx azclaude-copilot@latest auto-detects first install vs upgrade vs verify. Context-aware onboarding shows the right next command for your project state.\n\nExample use cases:\n• /setup — scan an existing project, detect stack + domain + scale, fill CLAUDE.md, generate project-specific skills and agents automatically\n• /copilot \"Build a compliance SaaS with trilingual support\" — walk away, come back to working code across multiple sessions\n• /sentinel — run a scored security audit (0–100, grade A–F) across hooks, permissions, MCP servers, agent configs, and secrets\n• /evolve — detect gaps in the environment, generate new skills and agents from git co-change evidence, report score delta (e.g. 42/100 → 68/100)\n• /constitute — write your project's constitution (non-negotiables, architectural commitments, definition of done) — gates all future AI actions\n• /analyze — cross-artifact consistency check: ghost milestones, spec vs. code drift, unplanned commits\n• /reflect — find stale, missing, or contradicting rules in CLAUDE.md and propose exact fixes\n• /debate \"REST vs GraphQL for this project\" — adversarial evidence-based decision with order-independent scoring, logged to decisions.md",
12
- "version": "0.4.35",
11
+ "description": "AZCLAUDE is a complete AI coding environment for Claude Code. It installs 37 commands, 9 auto-invoked skills, 15 specialized agents, 4 hooks, and a persistent memory system — in one command.\n\nKey features:\n• Memory across sessions — goals.md + checkpoints injected automatically before every session\n• Self-improving loop — /reflect fixes stale CLAUDE.md rules, /reflexes learns from tool-use patterns, /evolve creates agents from git evidence\n• Autonomous copilot mode — /copilot runs a three-tier team (orchestrator → problem-architect → milestone-builder) across sessions until the product ships\n• Spec-driven workflow — /constitute writes project rules, /spec writes structured ACs, /analyze detects plan drift and ghost milestones, /blueprint traces every milestone to a spec\n• Security layer — 111-rule environment scan (/sentinel), pre-write secret blocking, pre-ship credential audit\n• Progressive levels 0–10 — start with CLAUDE.md, grow into multi-agent pipelines and self-evolving environments\n• Zero dependencies — no npm packages, no external APIs, no vector databases. Plain markdown files and Claude Code's native architecture.\n• Smart install — npx azclaude-copilot@latest auto-detects first install vs upgrade vs verify. Context-aware onboarding shows the right next command for your project state.\n\nExample use cases:\n• /setup — scan an existing project, detect stack + domain + scale, fill CLAUDE.md, generate project-specific skills and agents automatically\n• /copilot \"Build a compliance SaaS with trilingual support\" — walk away, come back to working code across multiple sessions\n• /sentinel — run a scored security audit (0–100, grade A–F) across hooks, permissions, MCP servers, agent configs, and secrets\n• /evolve — detect gaps in the environment, generate new skills and agents from git co-change evidence, report score delta (e.g. 42/100 → 68/100)\n• /constitute — write your project's constitution (non-negotiables, architectural commitments, definition of done) — gates all future AI actions\n• /analyze — cross-artifact consistency check: ghost milestones, spec vs. code drift, unplanned commits\n• /reflect — find stale, missing, or contradicting rules in CLAUDE.md and propose exact fixes\n• /debate \"REST vs GraphQL for this project\" — adversarial evidence-based decision with order-independent scoring, logged to decisions.md",
12
+ "version": "0.4.37",
13
13
  "source": {
14
14
  "source": "github",
15
15
  "repo": "haytamAroui/AZ-CLAUDE-COPILOT",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "azclaude",
3
- "version": "0.4.35",
4
- "description": "AZCLAUDE is a complete AI coding environment for Claude Code. It installs 36 commands, 9 auto-invoked skills, 15 specialized agents, 4 hooks, and a persistent memory system — in one command.\n\nKey features:\n• Memory across sessions — goals.md + checkpoints injected automatically before every session\n• Self-improving loop — /reflect fixes stale CLAUDE.md rules, /reflexes learns from tool-use patterns, /evolve creates agents from git evidence\n• Autonomous copilot mode — /copilot runs a three-tier team (orchestrator → problem-architect → milestone-builder) across sessions until the product ships\n• Spec-driven workflow — /constitute writes project rules, /spec writes structured ACs, /analyze detects plan drift and ghost milestones, /blueprint traces every milestone to a spec\n• Security layer — 111-rule environment scan (/sentinel), pre-write secret blocking, pre-ship credential audit\n• Progressive levels 0–10 — start with CLAUDE.md, grow into multi-agent pipelines and self-evolving environments\n• Zero dependencies — no npm packages, no external APIs, no vector databases. Plain markdown files and Claude Code's native architecture.\n• Smart install — npx azclaude-copilot@latest auto-detects first install vs upgrade vs verify. Context-aware onboarding shows the right next command for your project state.\n\nExample use cases:\n• /setup — scan an existing project, detect stack + domain + scale, fill CLAUDE.md, generate project-specific skills and agents automatically\n• /copilot \"Build a compliance SaaS with trilingual support\" — walk away, come back to working code across multiple sessions\n• /sentinel — run a scored security audit (0–100, grade A–F) across hooks, permissions, MCP servers, agent configs, and secrets\n• /evolve — detect gaps in the environment, generate new skills and agents from git co-change evidence, report score delta (e.g. 42/100 → 68/100)\n• /constitute — write your project's constitution (non-negotiables, architectural commitments, definition of done) — gates all future AI actions\n• /analyze — cross-artifact consistency check: ghost milestones, spec vs. code drift, unplanned commits\n• /reflect — find stale, missing, or contradicting rules in CLAUDE.md and propose exact fixes\n• /debate \"REST vs GraphQL for this project\" — adversarial evidence-based decision with order-independent scoring, logged to decisions.md",
3
+ "version": "0.4.37",
4
+ "description": "AZCLAUDE is a complete AI coding environment for Claude Code. It installs 37 commands, 9 auto-invoked skills, 15 specialized agents, 4 hooks, and a persistent memory system — in one command.\n\nKey features:\n• Memory across sessions — goals.md + checkpoints injected automatically before every session\n• Self-improving loop — /reflect fixes stale CLAUDE.md rules, /reflexes learns from tool-use patterns, /evolve creates agents from git evidence\n• Autonomous copilot mode — /copilot runs a three-tier team (orchestrator → problem-architect → milestone-builder) across sessions until the product ships\n• Spec-driven workflow — /constitute writes project rules, /spec writes structured ACs, /analyze detects plan drift and ghost milestones, /blueprint traces every milestone to a spec\n• Security layer — 111-rule environment scan (/sentinel), pre-write secret blocking, pre-ship credential audit\n• Progressive levels 0–10 — start with CLAUDE.md, grow into multi-agent pipelines and self-evolving environments\n• Zero dependencies — no npm packages, no external APIs, no vector databases. Plain markdown files and Claude Code's native architecture.\n• Smart install — npx azclaude-copilot@latest auto-detects first install vs upgrade vs verify. Context-aware onboarding shows the right next command for your project state.\n\nExample use cases:\n• /setup — scan an existing project, detect stack + domain + scale, fill CLAUDE.md, generate project-specific skills and agents automatically\n• /copilot \"Build a compliance SaaS with trilingual support\" — walk away, come back to working code across multiple sessions\n• /sentinel — run a scored security audit (0–100, grade A–F) across hooks, permissions, MCP servers, agent configs, and secrets\n• /evolve — detect gaps in the environment, generate new skills and agents from git co-change evidence, report score delta (e.g. 42/100 → 68/100)\n• /constitute — write your project's constitution (non-negotiables, architectural commitments, definition of done) — gates all future AI actions\n• /analyze — cross-artifact consistency check: ghost milestones, spec vs. code drift, unplanned commits\n• /reflect — find stale, missing, or contradicting rules in CLAUDE.md and propose exact fixes\n• /debate \"REST vs GraphQL for this project\" — adversarial evidence-based decision with order-independent scoring, logged to decisions.md",
5
5
  "author": {
6
6
  "name": "haytamAroui",
7
7
  "url": "https://github.com/haytamAroui"
package/README.md CHANGED
@@ -63,7 +63,7 @@ AZCLAUDE inverts this. **You start with almost nothing. The environment builds i
63
63
  npx azclaude-copilot@latest # one command. that's it.
64
64
  ```
65
65
 
66
- No agent files to write. No skills to configure. No prompt engineering. `npx azclaude-copilot` installs 36 commands, 4 hooks, memory structure, and a manifest. The rest is generated from your actual codebase as you work. Run the same command again later — it auto-detects whether to skip, install, or upgrade.
66
+ No agent files to write. No skills to configure. No prompt engineering. `npx azclaude-copilot` installs 37 commands, 4 hooks, memory structure, and a manifest. The rest is generated from your actual codebase as you work. Run the same command again later — it auto-detects whether to skip, install, or upgrade.
67
67
 
68
68
  **What the environment looks like across sessions:**
69
69
 
@@ -119,7 +119,7 @@ npx azclaude-copilot@latest
119
119
  ```
120
120
 
121
121
  That's it. One command, no flags. Auto-detects whether this is a fresh install or an upgrade:
122
- - **First time** → full install (36 commands, 4 hooks, 15 agents, 10 skills, memory, reflexes)
122
+ - **First time** → full install (37 commands, 4 hooks, 15 agents, 10 skills, memory, reflexes)
123
123
  - **Already installed, older version** → auto-upgrades everything to latest templates
124
124
  - **Already up to date** → verifies, no overwrites
125
125
 
@@ -131,7 +131,7 @@ npx azclaude-copilot@latest doctor # 32 checks — verify everything is wired
131
131
 
132
132
  ## What You Get
133
133
 
134
- **36 commands** · **9 auto-invoked skills** · **15 agents** · **4 hooks** · **memory across sessions** · **learned reflexes** · **self-evolving environment**
134
+ **37 commands** · **9 auto-invoked skills** · **15 agents** · **4 hooks** · **memory across sessions** · **learned reflexes** · **self-evolving environment**
135
135
 
136
136
  ```
137
137
  .claude/
@@ -649,7 +649,7 @@ M1 (schema) → done
649
649
  /parallel M2 M3 M4 M5 # dispatch these milestones simultaneously
650
650
  ```
651
651
 
652
- **Three-layer safety:** `/blueprint` checks directory isolation + shared-utility imports before writing plan.md (Layer 1 no agents spawned). `problem-architect` returns exact `Files Written:` and `Parallel Safe:` per milestone after plan.md (Layer 2). The orchestrator checks file overlap again at dispatch time (Layer 3 — final gate, cannot be bypassed).
652
+ **Four-layer safety:** Before creating any milestones, `/blueprint` runs a **Task Classifier** (Layer 0) — groups coupled work (same schema table, same config file, same utility module) into single milestones so conflicts are impossible by design. Then: directory isolation + shared-utility grep (Layer 1, no agents spawned). `problem-architect` returns exact `Files Written:` and `Parallel Safe:` per milestone (Layer 2). Orchestrator re-checks file overlap at dispatch time (Layer 3 — unconditional final gate).
653
653
 
654
654
  See `docs/parallel-feature.md` for the complete reference.
655
655
 
@@ -677,7 +677,7 @@ AZCLAUDE recommends MCP servers based on your stack and wires them into daily-us
677
677
 
678
678
  ---
679
679
 
680
- ## All 36 Commands
680
+ ## All 37 Commands
681
681
 
682
682
  ### Build and Ship
683
683
 
@@ -709,6 +709,8 @@ AZCLAUDE recommends MCP servers based on your stack and wires them into daily-us
709
709
  | `/issues` | Convert plan.md milestones to GitHub Issues. Deduplicates, creates labels, writes issue numbers back to plan.md for traceability. |
710
710
  | `/parallel` | Run multiple milestones simultaneously. Worktree isolation per agent. Auto-merges after all complete. Three-layer file collision safety. |
711
711
  | `/mcp` | Recommend and install MCP servers based on detected stack. Wires Context7, Sequential Thinking, GitHub, Playwright, Brave Search, Supabase. |
712
+ | `/driven` | Generate `.claude/code-rules.md` — 6-question interview → DO/DO NOT coding contract. Read by every /add and /fix before writing code. |
713
+ | `/verify` | Audit existing code against `code-rules.md`. Reports violations at `file:line`. Auto-fix mode. Falls back to per-stack rule libraries when no contract exists. |
712
714
 
713
715
  ### Think and Improve
714
716
 
@@ -863,11 +865,11 @@ Run `/level-up` at any time to see your current level and build the next one.
863
865
 
864
866
  ## Verified
865
867
 
866
- 1526 tests. Every template, command, capability, agent, hook, and CLI feature verified.
868
+ 1578 tests. Every template, command, capability, agent, hook, and CLI feature verified.
867
869
 
868
870
  ```bash
869
871
  bash tests/test-features.sh
870
- # Results: 1526 passed, 0 failed, 1526 total
872
+ # Results: 1578 passed, 0 failed, 1578 total
871
873
  ```
872
874
 
873
875
  ---
package/bin/cli.js CHANGED
@@ -8,7 +8,7 @@ const { execSync } = require('child_process');
8
8
 
9
9
  const TEMPLATE_DIR = path.join(__dirname, '..', 'templates');
10
10
  const CORE_COMMANDS = ['setup', 'fix', 'add', 'audit', 'test', 'blueprint', 'ship', 'pulse', 'explain', 'snapshot', 'persist'];
11
- const EXTENDED_COMMANDS = ['dream', 'refactor', 'doc', 'loop', 'migrate', 'deps', 'find', 'create', 'reflect', 'hookify', 'sentinel', 'clarify', 'spec', 'analyze', 'constitute', 'tasks', 'issues', 'driven', 'mcp'];
11
+ const EXTENDED_COMMANDS = ['dream', 'refactor', 'doc', 'loop', 'migrate', 'deps', 'find', 'create', 'reflect', 'hookify', 'sentinel', 'clarify', 'spec', 'analyze', 'constitute', 'tasks', 'issues', 'driven', 'mcp', 'verify'];
12
12
  const ADVANCED_COMMANDS = ['evolve', 'debate', 'level-up', 'copilot', 'reflexes', 'parallel'];
13
13
  const COMMANDS = [...CORE_COMMANDS, ...EXTENDED_COMMANDS, ...ADVANCED_COMMANDS];
14
14
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "azclaude-copilot",
3
- "version": "0.4.35",
4
- "description": "AI coding environment — 36 commands, 10 skills, 15 agents, memory, reflexes, evolution. Install: npx azclaude-copilot@latest, then open Claude Code.",
3
+ "version": "0.4.37",
4
+ "description": "AI coding environment — 37 commands, 10 skills, 15 agents, memory, reflexes, evolution. Install: npx azclaude-copilot@latest, then open Claude Code.",
5
5
  "bin": {
6
6
  "azclaude": "bin/cli.js",
7
7
  "azclaude-copilot": "bin/copilot.js"
@@ -40,6 +40,7 @@ Extended (load command file on use):
40
40
  - /tasks: dependency graph + parallel wave groups from plan.md
41
41
  - /issues: convert plan.md milestones to GitHub Issues
42
42
  - Standards: /driven → generates .claude/code-rules.md (coding contract for /add and /fix)
43
+ - /verify → audits existing code against code-rules.md (file:line violations + auto-fix)
43
44
  - MCP: /mcp → recommends and installs MCP servers based on your stack
44
45
 
45
46
  Advanced (Level 5+):
@@ -64,4 +65,4 @@ When priorities conflict:
64
65
  3. {{PRIORITY_3}}
65
66
 
66
67
  ## Available Commands
67
- /dream · /setup · /fix · /add · /audit · /test · /blueprint · /evolve · /debate · /snapshot · /persist · /level-up · /ship · /pulse · /explain · /loop · /refactor · /doc · /migrate · /deps · /find · /create · /reflect · /hookify · /spec · /clarify · /analyze · /constitute · /tasks · /issues · /driven · /mcp · /parallel
68
+ /dream · /setup · /fix · /add · /audit · /test · /blueprint · /evolve · /debate · /snapshot · /persist · /level-up · /ship · /pulse · /explain · /loop · /refactor · /doc · /migrate · /deps · /find · /create · /reflect · /hookify · /spec · /clarify · /analyze · /constitute · /tasks · /issues · /driven · /mcp · /parallel · /verify
@@ -58,6 +58,16 @@ Load only the files that match the current task. Never load the full list.
58
58
  | intelligence/pipeline.md | 3+ agents must chain output — context bleed is a risk | ~350 |
59
59
  | intelligence/experiment.md | Trying a risky approach that must not touch main branch — "try this safely" | ~80 |
60
60
 
61
+ ## Code Rules — per-stack rule libraries (load matching stack only)
62
+ | File | When to load | Tokens |
63
+ |------|-------------|--------|
64
+ | shared/rules/typescript.md | Writing or verifying TypeScript code — load for /add, /fix, /verify when TS detected | ~250 |
65
+ | shared/rules/react.md | Writing or verifying React/Next.js components — load when JSX/TSX detected | ~250 |
66
+ | shared/rules/python.md | Writing or verifying Python/FastAPI/Django code — load when .py detected | ~250 |
67
+ | shared/rules/node.md | Writing or verifying Node.js/Express backend code — load when Node stack detected | ~250 |
68
+
69
+ **When to load:** `/verify` (rule source), `/driven` (default rule generation), `/add` and `/fix` (when no code-rules.md exists and stack is detected). Load only the matching stack file, never all four.
70
+
61
71
  ## Spec-Driven Workflow — load in sequence
62
72
  | Command | Purpose | Loads |
63
73
  |---------|---------|-------|
@@ -0,0 +1,70 @@
1
+ # Node.js / Express Code Rules — Curated DO/DO NOT Reference
2
+
3
+ **Load when**: stack contains Node.js, Express, Fastify, or similar backend JS/TS; generating code-rules.md for Node projects; or verifying Node/Express files.
4
+
5
+ ---
6
+
7
+ ## Async Patterns
8
+
9
+ - DO: use `async/await` throughout — no callback-style code in new files
10
+ - DO: always `await` Promises or chain `.catch()` — unhandled rejections crash Node
11
+ - DO: wrap `await` calls in `try/catch` at the service boundary
12
+ - DO NOT: mix `async/await` and `.then()/.catch()` in the same function
13
+ - DO NOT: use `Promise.all` without handling individual rejections — use `Promise.allSettled` when partial failure is acceptable
14
+
15
+ ## Route Structure
16
+
17
+ - DO: split routes into separate files by resource — `routes/users.ts`, `routes/orders.ts`
18
+ - DO: use a router factory pattern — `export function usersRouter(deps: Deps): Router`
19
+ - DO: validate all request input at the route entry — use zod, joi, or class-validator
20
+ - DO: return semantically correct HTTP status codes:
21
+ - `201` for successful resource creation
22
+ - `204` for successful delete with no body
23
+ - `400` for validation failures
24
+ - `404` for not found
25
+ - `409` for conflicts
26
+ - `422` for unprocessable entity
27
+ - DO NOT: put business logic in route handlers — delegate to a service layer
28
+ - DO NOT: return stack traces in error responses — log server-side, return a generic message
29
+
30
+ ## Middleware
31
+
32
+ - DO: register middleware in order: security → logging → parsing → auth → routes → errors
33
+ - DO: error-handling middleware uses 4 parameters exactly: `(err, req, res, next)`
34
+ - DO: always call `next(err)` on errors in async middleware — never swallow silently
35
+ - DO NOT: call both `next()` and `res.send()` in the same middleware path
36
+ - DO NOT: use synchronous file I/O in middleware (`fs.readFileSync`) — blocks the event loop
37
+
38
+ ## Database and Queries
39
+
40
+ - DO: use parameterized queries or an ORM — never concatenate user input into SQL
41
+ - DO: define a data access layer (repository) — routes and services never call the DB directly
42
+ - DO: use database transactions for multi-step writes
43
+ - DO NOT: select `*` — list columns explicitly in queries
44
+ - DO NOT: put connection logic inside route handlers — use a shared pool or ORM connection
45
+
46
+ ## Security
47
+
48
+ - DO: load secrets from `process.env` — never hardcode keys, tokens, or passwords in source
49
+ - DO: validate and sanitize all user input before use
50
+ - DO: set security headers — use `helmet` for Express
51
+ - DO: apply rate limiting to all public endpoints
52
+ - DO NOT: log request bodies containing passwords or tokens
53
+ - DO NOT: expose internal error messages to clients — wrap in a safe error response
54
+
55
+ ## Configuration
56
+
57
+ - DO: validate all required env vars at startup — fail fast with a clear message if missing
58
+ ```ts
59
+ const PORT = Number(process.env.PORT) || 3000;
60
+ if (!process.env.DATABASE_URL) throw new Error("DATABASE_URL required");
61
+ ```
62
+ - DO: use a config module — centralize all `process.env` access in one file
63
+ - DO NOT: use `process.env.X` scattered throughout the codebase
64
+
65
+ ## Testing
66
+
67
+ - DO: test routes with supertest against the real Express app — not mocked handlers
68
+ - DO: use a test database — never run tests against production or development databases
69
+ - DO: reset database state between tests using transactions or table truncation
70
+ - DO NOT: mock the database layer in route integration tests — it hides real issues
@@ -0,0 +1,70 @@
1
+ # Python Code Rules — Curated DO/DO NOT Reference
2
+
3
+ **Load when**: stack contains Python, FastAPI, Django, or Flask; generating code-rules.md for Python projects; or verifying Python files.
4
+
5
+ ---
6
+
7
+ ## Type Annotations
8
+
9
+ - DO: annotate all public function signatures — parameters and return type
10
+ - DO: use `Optional[X]` (or `X | None` in Python 3.10+) for nullable values
11
+ - DO: use `TypeVar` for generic functions rather than `Any`
12
+ - DO: use `TypedDict` or `dataclasses` for structured dicts
13
+ - DO NOT: use bare `Any` from typing — use `object` or a proper type
14
+ - DO NOT: omit return type on public functions — `-> None` is explicit and correct
15
+
16
+ ## Functions and Classes
17
+
18
+ - DO NOT: use mutable default arguments — `def f(x: list = None)` with `if x is None: x = []`
19
+ - Bad: `def append(item, lst=[])`
20
+ - Good: `def append(item, lst: list | None = None) -> list`
21
+ - DO: use dataclasses for data-only classes — `@dataclass(frozen=True)` for immutable
22
+ - DO: use `@staticmethod` and `@classmethod` correctly — don't use `self` if not needed
23
+ - DO: keep functions under 30 lines — extract helpers when longer
24
+ - DO NOT: use wildcard imports — `from module import *` pollutes the namespace
25
+
26
+ ## Error Handling
27
+
28
+ - DO: catch specific exception types — `except ValueError` not `except Exception`
29
+ - DO: never use bare `except:` — it catches `SystemExit` and `KeyboardInterrupt`
30
+ - DO: re-raise with context when wrapping — `raise ServiceError("msg") from original_error`
31
+ - DO: use custom exception classes that inherit from `Exception` for domain errors
32
+ - DO NOT: silence exceptions with `pass` — log and re-raise or handle explicitly
33
+
34
+ ## Imports and Modules
35
+
36
+ - DO: use absolute imports — `from myapp.users.service import UserService`
37
+ - DO: group imports: stdlib → third-party → local, separated by blank lines
38
+ - DO: use `pathlib.Path` not `os.path` for all file system operations
39
+ - DO NOT: use circular imports — restructure dependencies to break the cycle
40
+ - DO NOT: import inside functions (exception: breaking circular deps or lazy loading)
41
+
42
+ ## String Formatting
43
+
44
+ - DO: use f-strings for string interpolation — `f"Hello, {name}!"`
45
+ - DO NOT: use `%` formatting or `.format()` in new code
46
+ - DO: use triple-quoted strings for multiline strings
47
+ - DO NOT: concatenate strings in a loop — use `"".join(parts)` or a list
48
+
49
+ ## Context Managers and Resources
50
+
51
+ - DO: use `with` for all file I/O, database connections, and lock acquisition
52
+ - DO: implement `__enter__`/`__exit__` (or `@contextmanager`) for custom resources
53
+ - DO NOT: leave files or connections open without explicit close or `with` block
54
+
55
+ ## FastAPI (if applicable)
56
+
57
+ - DO: define Pydantic models for all request bodies and responses
58
+ - DO: use `Annotated` for dependency injection — `Depends()` in type position
59
+ - DO: return typed response models — `response_model=UserResponse`
60
+ - DO: use `HTTPException` with specific status codes and detail messages
61
+ - DO NOT: return raw dicts from route functions — use Pydantic response models
62
+ - DO NOT: put business logic in route handlers — delegate to service layer
63
+ - DO NOT: access `request.body()` directly when a Pydantic body model suffices
64
+
65
+ ## Testing
66
+
67
+ - DO: use `pytest` fixtures for setup, not `setUp`/`tearDown` methods
68
+ - DO: name test functions `test_{what}_{condition}_{expected_outcome}`
69
+ - DO: use `pytest.raises` as context manager for exception testing
70
+ - DO NOT: test implementation details — test behavior and outcomes
@@ -0,0 +1,62 @@
1
+ # React Code Rules — Curated DO/DO NOT Reference
2
+
3
+ **Load when**: stack contains React or Next.js, generating code-rules.md for React projects, or verifying React/JSX files.
4
+
5
+ ---
6
+
7
+ ## Component Structure
8
+
9
+ - DO: write function components exclusively — no class components
10
+ - DO: one component per file; filename matches exported component name (PascalCase)
11
+ - DO: keep components under 150 lines — extract sub-components or hooks when larger
12
+ - DO: co-locate test file with component — `Button.tsx` + `Button.test.tsx` same directory
13
+ - DO NOT: export multiple components from a single file (exception: compound components)
14
+ - DO NOT: use `React.FC` type — write `function Foo(props: FooProps)` instead
15
+
16
+ ## Props
17
+
18
+ - DO: define prop types with `interface` above the component — `interface ButtonProps { ... }`
19
+ - DO: use destructuring in the function signature — `function Button({ label, onClick }: ButtonProps)`
20
+ - DO: provide default values at destructuring — `function Card({ size = 'md' }: CardProps)`
21
+ - DO NOT: pass more than 5-7 props — extract sub-components or use a config object
22
+ - DO NOT: prop-drill beyond 2 levels — use Context, composition, or state management
23
+
24
+ ## Hooks
25
+
26
+ - DO: name custom hooks with `use` prefix and extract to `hooks/` directory
27
+ - DO: list ALL dependencies in useEffect/useMemo/useCallback dependency arrays — no omissions
28
+ - DO: use `useCallback` for functions passed as props to memoized children
29
+ - DO NOT: call hooks inside conditions, loops, or nested functions
30
+ - DO NOT: suppress exhaustive-deps lint rule — fix the dependency, not the lint
31
+ - DO NOT: use useEffect to sync state with props — use derived state or useMemo
32
+
33
+ ## Event Handlers
34
+
35
+ - DO: define event handlers as named `const handleX = () => {}` above the JSX return
36
+ - DO: type events explicitly — `(e: React.ChangeEvent<HTMLInputElement>) => void`
37
+ - DO NOT: use inline arrow functions in JSX props for performance-sensitive components
38
+ - Bad: `<Button onClick={() => handleClick(id)} />`
39
+ - Good: `const handleClick = useCallback(() => onClickId(id), [id, onClickId])`
40
+
41
+ ## State and Data
42
+
43
+ - DO: derive values from state with `useMemo` — avoid redundant state variables
44
+ - DO: handle loading, error, and empty states before rendering data
45
+ - DO: use `null` for "not yet loaded", `undefined` for "optional field absent"
46
+ - DO NOT: use array index as `key` — use stable unique IDs
47
+ - DO NOT: mutate state directly — always return a new value
48
+ - DO NOT: store derived values in state — compute them in the render or with useMemo
49
+
50
+ ## Performance
51
+
52
+ - DO: wrap expensive child renders in `React.memo` when parent re-renders frequently
53
+ - DO: use lazy loading for routes and heavy components — `React.lazy(() => import(...))`
54
+ - DO NOT: premature memoization — profile first, optimize second
55
+ - DO NOT: put complex objects/arrays inline in JSX (recreated on every render)
56
+
57
+ ## Next.js (if applicable)
58
+
59
+ - DO: use Server Components by default — add `"use client"` only when needed
60
+ - DO: co-locate data fetching with the component that needs it (Server Component pattern)
61
+ - DO NOT: fetch data in client components when a Server Component can do it
62
+ - DO NOT: use `getServerSideProps` or `getStaticProps` in new code — use App Router conventions
@@ -0,0 +1,59 @@
1
+ # TypeScript Code Rules — Curated DO/DO NOT Reference
2
+
3
+ **Load when**: stack contains TypeScript, generating code-rules.md for TypeScript projects, or verifying TypeScript files.
4
+
5
+ ---
6
+
7
+ ## Type Safety
8
+
9
+ - DO: annotate all public function return types explicitly — `function getUser(): User | null`
10
+ - DO: use `unknown` for values you don't control (API responses, JSON.parse results)
11
+ - DO: use `interface` for object shapes; `type` for unions, intersections, mapped types
12
+ - DO: use `satisfies` operator to validate literal types without widening — `const config = {...} satisfies Config`
13
+ - DO NOT: use `any` — replace with `unknown`, a proper type, or a generic
14
+ - DO NOT: use non-null assertion `!` without a comment explaining why null is impossible
15
+ - DO NOT: use `as` type casting except at data ingestion boundaries (and document why)
16
+ - DO NOT: use `object` or `{}` as a type — name the shape explicitly
17
+
18
+ ## Null Handling
19
+
20
+ - DO: use optional chaining `?.` and nullish coalescing `??` for safe access
21
+ - DO: return `null` (not `undefined`) from functions that can produce no value — it's explicit
22
+ - DO NOT: check `=== null && === undefined` separately — use `== null` or `??`
23
+
24
+ ## Imports and Modules
25
+
26
+ - DO: use named exports — avoid default exports (makes refactoring and grep harder)
27
+ - DO: use barrel files (`index.ts`) only for public API surface, not internal re-exports
28
+ - DO NOT: use namespace imports `import * as X` — prevents tree-shaking
29
+ - DO NOT: import types with `import` — use `import type` for type-only imports
30
+
31
+ ## Classes and Functions
32
+
33
+ - DO: prefer pure functions over classes for business logic
34
+ - DO: use `readonly` on class properties and array types that must not be mutated
35
+ - DO: implement interfaces explicitly — `class AuthService implements IAuthService`
36
+ - DO NOT: use `namespace` — use ES modules
37
+ - DO NOT: use `enum` — use `const` objects with `as const` (`{ A: 'a', B: 'b' } as const`)
38
+
39
+ ## Async
40
+
41
+ - DO: always handle Promise rejections — wrap in try/catch or chain `.catch()`
42
+ - DO: type async function returns as `Promise<T>` not `Promise<any>`
43
+ - DO NOT: mix async/await and `.then()/.catch()` in the same function
44
+ - DO NOT: use `async` on functions that don't await anything
45
+
46
+ ## Strictness (strict mode)
47
+
48
+ Enable in `tsconfig.json`:
49
+ ```json
50
+ {
51
+ "strict": true,
52
+ "noImplicitReturns": true,
53
+ "noUncheckedIndexedAccess": true,
54
+ "exactOptionalPropertyTypes": true
55
+ }
56
+ ```
57
+
58
+ - DO NOT: add `// @ts-ignore` or `// @ts-expect-error` without a bug tracker link
59
+ - DO NOT: disable `strictNullChecks` — it exists to catch the most common runtime errors
@@ -114,9 +114,9 @@ If constitution found → scan plan steps against non-negotiables:
114
114
  - Flag any plan step that could violate a rule
115
115
  - Add a note to flagged steps: `⚠ Constitution check: may conflict with "{rule}" — verify before implementing`
116
116
 
117
- If code-rules found → read `## Architecture` section:
118
- - The plan must respect the declared architecture pattern (Clean Architecture / DDD / MVC / etc.)
119
- - If a plan step would introduce a pattern that conflicts with the architecture rule — flag it
117
+ If code-rules found → read the file header line (`# Architecture: {pattern}`):
118
+ - The plan must respect the declared architecture pattern (Clean Architecture / DDD / MVC / feature-based / etc.)
119
+ - If a plan step would introduce a pattern that conflicts with the declared architecture — flag it
120
120
  - Add note: `⚠ Code rules: this step should follow {architecture pattern} — verify approach before implementing`
121
121
 
122
122
  Then run `/tasks` to show dependency waves:
@@ -127,69 +127,50 @@ Next: Run /tasks to see which plan steps can run in parallel
127
127
 
128
128
  ---
129
129
 
130
- ## Step 4: Approval Gate
131
-
132
- **ExitPlanMode**
133
-
134
- Present the plan and STOP. Do not write any code.
135
-
136
- Ask the user: **"Approve this plan? (yes / change step N / cancel)"**
130
+ ## Parallel Planning Task Classifier + Wave Assignment (ALL modes)
137
131
 
138
- - `yes` create TaskCreate for each step, then state: "Run /add to execute each task."
139
- - `change step N` revise that step, re-present, ask again
140
- - `cancel` → discard, no tasks created
132
+ **Runs in both interactive and copilot mode.**
133
+ Produces the milestone set and wave structure that Step 3c visualizes.
134
+ In copilot mode, the orchestrator dispatches directly from this output.
141
135
 
142
- Tasks are only created after explicit approval. This is the point of /blueprint.
136
+ **Mode detection:**
137
+ ```bash
138
+ [ -f .claude/copilot-intent.md ] && echo "COPILOT_MODE" || echo "INTERACTIVE_MODE"
139
+ ```
143
140
 
144
- ---
141
+ ### Task Classifier — Zero-Conflict Milestone Design (REQUIRED before wave assignment)
145
142
 
146
- ## Feature-Scoped Mode (Optional)
147
-
148
- When $ARGUMENTS points to a spec file (`.claude/specs/*.md`) OR contains a named feature:
143
+ **Run this BEFORE creating milestones.** Groups coupled work together so parallel dispatch is safe by construction — not by detection after the fact.
149
144
 
145
+ **Step 0: Greenfield check**
150
146
  ```bash
151
- # Detect spec file
152
- [ -f "$ARGUMENTS" ] && echo "spec-mode" || echo "inline-mode"
153
-
154
- # Determine next feature number
155
- NEXT_N=$(ls .claude/features/ 2>/dev/null | grep -c '^' || echo 0)
156
- N=$(printf '%02d' $((NEXT_N + 1)))
157
- SLUG=$(basename "$ARGUMENTS" .md 2>/dev/null || echo "$ARGUMENTS" | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | tr -cd 'a-z0-9-' | cut -c1-40)
158
- FEATURE_DIR=".claude/features/${N}-${SLUG}"
147
+ SRC_COUNT=$(find src/ app/ lib/ -type f 2>/dev/null | wc -l 2>/dev/null || echo 0)
148
+ echo "source_files=$SRC_COUNT"
159
149
  ```
150
+ If source_files < 10 → greenfield project. Force Wave 1 = all foundation work (schema, config, shared utils, types) as a SINGLE milestone regardless of feature count. Parallel only unlocks from Wave 2 onward, after the foundation exists and greps have real files to scan.
160
151
 
161
- If spec file provided create a feature-scoped directory:
162
- ```bash
163
- mkdir -p "$FEATURE_DIR"
164
- cp "$ARGUMENTS" "$FEATURE_DIR/spec.md"
165
- ```
152
+ **Step 1: List raw work items**
153
+ From the intent/spec, enumerate ALL features, endpoints, models, UI pages, and background jobs as raw items. Do not group yet — just list everything the project needs.
166
154
 
167
- Write the plan to `$FEATURE_DIR/plan.md` (same format as `.claude/plan.md`).
168
- Also write a summary entry to `.claude/plan.md` linking to the feature:
169
- ```markdown
170
- ## Feature: {N}-{slug}
171
- Files: .claude/features/{N}-{slug}/plan.md
172
- Status: pending
173
- ```
155
+ **Step 2: Coupling analysis merge rule**
156
+ For each pair of raw work items, check if they share ANY of:
157
+ - Same database table (both CREATE or ALTER the same table)
158
+ - Same config file (`package.json`, `tsconfig.json`, `prisma/schema.prisma`, `docker-compose.yml`, `go.mod`, `Cargo.toml`)
159
+ - Same utility module (both CREATE or MODIFY files in `utils/`, `shared/`, `common/`, `lib/`, `helpers/`)
160
+ - Same API contract (one produces an endpoint, the other consumes it within the same feature boundary)
174
161
 
175
- This keeps the global plan.md as the tracker while feature details live in their own directory.
176
- Each feature directory is self-contained: `spec.md` + `plan.md` + any generated artifacts.
162
+ If any coupling exists merge those two items into ONE milestone. Repeat until no same-wave pair shares any resource.
177
163
 
178
- **When NOT to use feature mode:** quick fixes, single-file changes, copilot mode (uses global plan.md).
164
+ **Step 3: Independence check split rule**
165
+ Work items that share NONE of the above → separate milestones, `Parallel: yes` candidate.
179
166
 
180
- ---
167
+ **Result:** Every milestone is either:
168
+ - **Fat milestone** — all coupled work together. One agent handles everything that would otherwise conflict. Larger task, zero parallel risk.
169
+ - **Thin milestone** — fully independent. Parallel-safe by construction, not by detection.
181
170
 
182
- ## Copilot ModeStructured plan.md Output
171
+ Proceed to Layer 1 with these merged milestones not with raw work items.
183
172
 
184
- When running inside `/copilot` (detected by: `.claude/copilot-intent.md` exists):
185
- - Skip the approval gate (Step 4) — copilot operates autonomously
186
- - Write the plan to `.claude/plan.md` in the structured format defined in `plan-tracker.md`
187
- - Read `.claude/capabilities/shared/plan-tracker.md` for the exact format
188
- - Each milestone = one logical unit of work (1-3 files, one commit)
189
- - Include `Depends:` for milestones that require prior work
190
- - Include `Files:` with expected paths
191
- - Include `Commit:` with conventional commit format
192
- - Write `## Summary` with counts at the bottom
173
+ ---
193
174
 
194
175
  ### Parallel Optimization Pass — Layer 1 (REQUIRED before writing plan.md)
195
176
 
@@ -231,7 +212,7 @@ both need to CREATE or MODIFY files there → set `Parallel: no` for both and ad
231
212
  **Do NOT spawn problem-architect here.** The grep is sufficient for Layer 1. Problem-architect
232
213
  runs after plan.md is written and handles the cases Layer 1 misses.
233
214
 
234
- **Step 4: Set Dirs: and Parallel: fields, write plan.md**
215
+ **Step 4: Set Dirs: and Parallel: fields**
235
216
 
236
217
  ```
237
218
  - Dirs: top-level directories this milestone exclusively owns
@@ -249,6 +230,140 @@ Wave 3: M6 (integration/E2E) — Parallel: no
249
230
 
250
231
  ---
251
232
 
233
+ ## Step 3c: Parallel Dispatch Visualization
234
+
235
+ After classifier + Layer 1 complete, render the dispatch map:
236
+
237
+ ```
238
+ ══════════════════════════════════════════════════════
239
+ Parallel Dispatch Plan
240
+ ══════════════════════════════════════════════════════
241
+
242
+ Wave 1 (sequential — foundation)
243
+ ┌─────────────────────────────────────────────────┐
244
+ │ M1: {title} │
245
+ │ Dirs: {dirs} │
246
+ │ Parallel: no (foundation — must run first)│
247
+ └─────────────────────────────────────────────────┘
248
+
249
+
250
+ Wave 2 (parallel — {N} agents simultaneously)
251
+ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐
252
+ │ M2: {title} │ │ M3: {title} │ │ M4: {title} │
253
+ │ {dirs} │ │ {dirs} │ │ {dirs} │
254
+ │ Parallel: ✓ │ │ Parallel: ✓ │ │ Parallel: ✓ │
255
+ └──────────────┘ └──────────────┘ └──────────────┘
256
+
257
+
258
+ (continue for each wave)
259
+
260
+ ══════════════════════════════════════════════════
261
+ Summary
262
+ ──────────────────────────────────────────────────
263
+ Total milestones: {N}
264
+ Waves: {N}
265
+ Max parallel: {N} agents (Wave {N})
266
+ Sequential estimate: {total} sessions (~{total×30}min)
267
+ Parallel estimate: {waves} waves (~{waves×30}min)
268
+ Time saved: ~{pct}%
269
+
270
+ Merged by classifier:
271
+ • {item A} + {item B} → {MN} ({reason — e.g. shared schema.prisma})
272
+
273
+ Split for parallelism:
274
+ • {item} split from {other item} ({reason — e.g. different dirs, no shared files})
275
+ ══════════════════════════════════════════════════
276
+ ```
277
+
278
+ **Rules:**
279
+ - Show every wave, even single-milestone waves
280
+ - Side-by-side boxes for parallel milestones in the same wave; single wide box for sequential
281
+ - "Sequential estimate" = `total milestones × 30min`; "Parallel estimate" = `wave count × 30min`
282
+ - Time saved % = `(sequential - parallel) / sequential × 100`
283
+ - "Merged by classifier" lists only merges that changed the plan (not items that were always single)
284
+ - "Split for parallelism" lists items the classifier separated into different milestones
285
+
286
+ **In copilot mode:** write the visualization as a comment block at the top of plan.md:
287
+ ```markdown
288
+ <!-- Parallel Dispatch Plan
289
+ Wave 1 (seq): M1 — foundation
290
+ Wave 2 (parallel, 4 agents): M2 M3 M4 M5
291
+ Wave 3 (parallel, 3 agents): M6 M7 M8
292
+ Wave 4 (seq): M9 — integration
293
+ Sequential: ~270min | Parallel: ~120min | Saved: ~56%
294
+ -->
295
+ ```
296
+
297
+ **In interactive mode:** show the visualization before the approval gate.
298
+ Let the user adjust wave grouping: "move M5 to Wave 3" → adjust Depends:, re-render, re-present.
299
+
300
+ ---
301
+
302
+ ## Step 4: Approval Gate
303
+
304
+ **ExitPlanMode**
305
+
306
+ Present the plan and STOP. Do not write any code.
307
+
308
+ Ask the user: **"Approve this plan? (yes / change step N / cancel)"**
309
+
310
+ - `yes` → create TaskCreate for each step, then state: "Run /add to execute each task."
311
+ - `change step N` → revise that step, re-present, ask again
312
+ - `cancel` → discard, no tasks created
313
+
314
+ Tasks are only created after explicit approval. This is the point of /blueprint.
315
+
316
+ ---
317
+
318
+ ## Feature-Scoped Mode (Optional)
319
+
320
+ When $ARGUMENTS points to a spec file (`.claude/specs/*.md`) OR contains a named feature:
321
+
322
+ ```bash
323
+ # Detect spec file
324
+ [ -f "$ARGUMENTS" ] && echo "spec-mode" || echo "inline-mode"
325
+
326
+ # Determine next feature number
327
+ NEXT_N=$(ls .claude/features/ 2>/dev/null | grep -c '^' || echo 0)
328
+ N=$(printf '%02d' $((NEXT_N + 1)))
329
+ SLUG=$(basename "$ARGUMENTS" .md 2>/dev/null || echo "$ARGUMENTS" | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | tr -cd 'a-z0-9-' | cut -c1-40)
330
+ FEATURE_DIR=".claude/features/${N}-${SLUG}"
331
+ ```
332
+
333
+ If spec file provided → create a feature-scoped directory:
334
+ ```bash
335
+ mkdir -p "$FEATURE_DIR"
336
+ cp "$ARGUMENTS" "$FEATURE_DIR/spec.md"
337
+ ```
338
+
339
+ Write the plan to `$FEATURE_DIR/plan.md` (same format as `.claude/plan.md`).
340
+ Also write a summary entry to `.claude/plan.md` linking to the feature:
341
+ ```markdown
342
+ ## Feature: {N}-{slug}
343
+ Files: .claude/features/{N}-{slug}/plan.md
344
+ Status: pending
345
+ ```
346
+
347
+ This keeps the global plan.md as the tracker while feature details live in their own directory.
348
+ Each feature directory is self-contained: `spec.md` + `plan.md` + any generated artifacts.
349
+
350
+ **When NOT to use feature mode:** quick fixes, single-file changes, copilot mode (uses global plan.md).
351
+
352
+ ---
353
+
354
+ ## Copilot Mode — plan.md Format + Layer 2 Validation
355
+
356
+ When running inside `/copilot` (detected by: `.claude/copilot-intent.md` exists):
357
+ - Skip the approval gate (Step 4) — copilot operates autonomously
358
+ - Task Classifier + Layer 1 already ran in the "Parallel Planning" section above
359
+ - Write the plan to `.claude/plan.md` using the classified milestones
360
+ - Read `.claude/capabilities/shared/plan-tracker.md` for the exact format
361
+ - Each milestone = one logical unit of work (1-3 files, one commit)
362
+ - Include `Depends:` for milestones that require prior work
363
+ - Include `Files:` with expected paths
364
+ - Include `Commit:` with conventional commit format
365
+ - Write `## Summary` with counts at the bottom
366
+
252
367
  ### Problem-Architect Validation — Layer 2 (after plan.md is written)
253
368
 
254
369
  Layer 2 refines Layer 1 with exact file-level analysis. Catches shared utilities that
@@ -65,7 +65,7 @@ Use **AskUserQuestion**: "`.claude/code-rules.md` already exists. Regenerate fro
65
65
 
66
66
  ---
67
67
 
68
- ## Step 2: Detect Stack
68
+ ## Step 2: Detect Stack + Load Rule Library
69
69
 
70
70
  Read `CLAUDE.md` Stack field. If empty or missing, run detection:
71
71
 
@@ -80,6 +80,16 @@ State the detected stack before starting the interview. Example:
80
80
  Detected stack: React 19, TypeScript, Node/Express, PostgreSQL
81
81
  ```
82
82
 
83
+ **Load per-stack rule library as the default rule baseline:**
84
+ - TypeScript detected → read `capabilities/shared/rules/typescript.md`
85
+ - React detected → read `capabilities/shared/rules/react.md`
86
+ - Python detected → read `capabilities/shared/rules/python.md`
87
+ - Node/Express detected → read `capabilities/shared/rules/node.md`
88
+
89
+ These rule libraries provide the curated DO/DO NOT defaults for each section of `code-rules.md`.
90
+ When the user selects "Default" in any interview question (Step 3), use the matching rules from the loaded library as the generated content for that section.
91
+ When the user provides custom answers, use those instead — the library is a fallback, not a requirement.
92
+
83
93
  ---
84
94
 
85
95
  ## Step 3: Interview — 6 Questions
@@ -0,0 +1,217 @@
1
+ ---
2
+ name: verify
3
+ description: >
4
+ Audit existing code against the project's coding rules (.claude/code-rules.md).
5
+ Finds rule violations at file:line level, reports them, and optionally auto-fixes.
6
+ Triggers on: "check my code", "verify code quality", "does this follow our rules",
7
+ "check coding style", "audit coding standards", "find violations", "lint against rules",
8
+ "check this file against rules", "are we following conventions", "code quality check",
9
+ "verify standards", "rules check", "style violations", "rule violations".
10
+ NOT triggered by: dependency audits (use /deps), security audit (use /sentinel),
11
+ full project audit (use /audit), governance check (use /constitute).
12
+ argument-hint: "[file/dir/pattern — default: git changed files]"
13
+ disable-model-invocation: true
14
+ allowed-tools: Read, Bash, Glob, Grep
15
+ ---
16
+
17
+ # /verify — Audit Code Against Project Rules
18
+
19
+ $ARGUMENTS
20
+
21
+ ---
22
+
23
+ ## Purpose
24
+
25
+ Check existing files against `.claude/code-rules.md`.
26
+ Report every violation at `file:line` precision.
27
+ Optionally auto-fix violations.
28
+
29
+ This is NOT a linter replacement — it is a semantic rule checker.
30
+ Use it: before a PR, after a big refactor, when onboarding new code.
31
+
32
+ ---
33
+
34
+ ## Step 1: Load Rules
35
+
36
+ ```bash
37
+ # Load project coding contract
38
+ cat .claude/code-rules.md 2>/dev/null | head -5
39
+
40
+ # Detect stack if no code-rules.md
41
+ grep -i "stack:" CLAUDE.md 2>/dev/null | head -2
42
+ ```
43
+
44
+ **If `.claude/code-rules.md` exists:**
45
+ Read the full file — extract every `DO:` and `DO NOT:` rule by section.
46
+ Build a rule checklist:
47
+ ```
48
+ Section: TypeScript
49
+ R1: DO: explicit return types on all public functions
50
+ R2: DO NOT: use `any` — replace with `unknown` or a proper type
51
+ ...
52
+ ```
53
+
54
+ **If no `code-rules.md`:**
55
+ State: "No `.claude/code-rules.md` found — run `/driven` to create your project coding contract."
56
+ Then load the matching per-stack capability as a fallback:
57
+ - TypeScript detected → load `capabilities/shared/rules/typescript.md`
58
+ - React detected → load `capabilities/shared/rules/react.md`
59
+ - Python detected → load `capabilities/shared/rules/python.md`
60
+ - Node/Express detected → load `capabilities/shared/rules/node.md`
61
+
62
+ State which rules are being checked and that they are defaults — not project-specific.
63
+
64
+ ---
65
+
66
+ ## Step 2: Identify Target Files
67
+
68
+ **If $ARGUMENTS provided:**
69
+ ```bash
70
+ # Expand argument to file list
71
+ if [ -f "$ARGUMENTS" ]; then
72
+ echo "single-file"
73
+ elif [ -d "$ARGUMENTS" ]; then
74
+ find "$ARGUMENTS" -type f -name "*.ts" -o -name "*.tsx" -o -name "*.py" -o -name "*.js" | head -50
75
+ else
76
+ # Treat as glob pattern
77
+ ls $ARGUMENTS 2>/dev/null | head -50
78
+ fi
79
+ ```
80
+
81
+ **If no $ARGUMENTS (default — git changed files):**
82
+ ```bash
83
+ git diff --name-only HEAD 2>/dev/null | grep -E "\.(ts|tsx|js|jsx|py)$" | head -30
84
+ ```
85
+
86
+ If no git diff and no argument → scan all source files:
87
+ ```bash
88
+ find src/ lib/ app/ -type f \( -name "*.ts" -o -name "*.tsx" -o -name "*.py" -o -name "*.js" \) 2>/dev/null | head -30
89
+ ```
90
+
91
+ State the file list before proceeding.
92
+
93
+ ---
94
+
95
+ ## Step 3: Check Each Rule
96
+
97
+ For each file × each rule in code-rules.md:
98
+
99
+ **DO NOT rules (search for violations):**
100
+ Map each "DO NOT" to a search pattern, then grep:
101
+ ```bash
102
+ # Example — DO NOT: use `any`
103
+ grep -n ":\s*any\b\|<any>\|as any" {file} 2>/dev/null
104
+
105
+ # Example — DO NOT: use `var`
106
+ grep -n "^\s*var " {file} 2>/dev/null
107
+
108
+ # Example — DO NOT: use `console.log` in production code
109
+ grep -n "console\.log" {file} 2>/dev/null
110
+ ```
111
+
112
+ **DO rules (check absence — structural)**:
113
+ These require reading the file, not just grepping.
114
+ For example:
115
+ - "DO: explicit return types" → read exported functions, check if return type is present
116
+ - "DO: handle loading/error states" → read component, check for loading/error branch
117
+ - "DO: parameterized queries" → check that DB calls don't use string concatenation
118
+
119
+ Use Grep and Read tools — don't spawn agents for Step 3.
120
+
121
+ **Violation format:**
122
+ ```
123
+ {file}:{line} → violates [{section}] {rule}
124
+ ```
125
+
126
+ Example output:
127
+ ```
128
+ src/auth/login.ts:23 → violates [TypeScript] DO NOT: use `any`
129
+ src/auth/login.ts:45 → violates [TypeScript] DO NOT: use non-null assertion `!`
130
+ src/components/Form.tsx:12 → violates [React] DO NOT: use index as `key`
131
+ ```
132
+
133
+ ---
134
+
135
+ ## Step 4: Report
136
+
137
+ After checking all files:
138
+
139
+ ```
140
+ Code Rules Verification — {date}
141
+ Source: .claude/code-rules.md
142
+ Files checked: {N}
143
+ Rules checked: {N}
144
+
145
+ Violations Found: {total}
146
+ ─────────────────────────────────
147
+ {file}:{line} → [{section}] {rule}
148
+ ...
149
+
150
+ Most violated rule: {rule} ({N} occurrences)
151
+ Clean files: {N}/{total}
152
+ ```
153
+
154
+ **If 0 violations:**
155
+ ```
156
+ ✓ All {N} files pass project coding rules.
157
+ Files: {N} | Rules: {N} | Zero violations.
158
+ ```
159
+
160
+ ---
161
+
162
+ ## Step 5: Fix Offer
163
+
164
+ If violations found, ask (use **AskUserQuestion**):
165
+
166
+ "Found {N} violations across {M} files.
167
+
168
+ Options:
169
+ a) Auto-fix — I'll fix each violation now (may require reading context)
170
+ b) Show fix plan — list what would change, I'll implement on approval
171
+ c) Export — write violations to .claude/verify-report.md
172
+ d) Skip — I'll fix manually"
173
+
174
+ **If option a — Auto-fix:**
175
+ For each violation:
176
+ 1. Read the file section around the violation
177
+ 2. Apply the minimal fix that satisfies the rule
178
+ 3. Verify the fix doesn't break adjacent logic
179
+ 4. Show the diff before writing
180
+
181
+ After all fixes:
182
+ ```bash
183
+ # Confirm nothing is broken
184
+ npm test 2>&1 | tail -5 # or pytest or whatever is the test runner
185
+ ```
186
+
187
+ Report: "Fixed {N} violations. {M} files changed. Tests: {result}."
188
+
189
+ **If option c — Export report:**
190
+ Write `.claude/verify-report.md`:
191
+ ```markdown
192
+ # Code Rules Verification Report — {date}
193
+
194
+ ## Summary
195
+ Files: {N} | Violations: {N} | Rules: {N}
196
+
197
+ ## Violations
198
+ | File | Line | Section | Rule |
199
+ |------|------|---------|------|
200
+ | {file} | {line} | {section} | {rule} |
201
+
202
+ ## Most Violated Rules
203
+ 1. {rule} — {N} occurrences
204
+ 2. ...
205
+ ```
206
+
207
+ ---
208
+
209
+ ## When to Run `/verify`
210
+
211
+ | Trigger | Command |
212
+ |---------|---------|
213
+ | Before opening a PR | `/verify` (checks git diff) |
214
+ | After a big refactor | `/verify src/` |
215
+ | Audit a specific file | `/verify src/auth/login.ts` |
216
+ | Full codebase scan | `/verify src/` |
217
+ | After `/driven` changes rules | `/verify` to see existing violations |