azclaude-copilot 0.4.35 → 0.4.36
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.
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +2 -2
- package/README.md +8 -6
- package/bin/cli.js +1 -1
- package/package.json +2 -2
- package/templates/CLAUDE.md +2 -1
- package/templates/capabilities/manifest.md +10 -0
- package/templates/capabilities/shared/rules/node.md +70 -0
- package/templates/capabilities/shared/rules/python.md +70 -0
- package/templates/capabilities/shared/rules/react.md +62 -0
- package/templates/capabilities/shared/rules/typescript.md +59 -0
- package/templates/commands/driven.md +11 -1
- package/templates/commands/verify.md +217 -0
|
@@ -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
|
|
12
|
-
"version": "0.4.
|
|
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.36",
|
|
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.
|
|
4
|
-
"description": "AZCLAUDE is a complete AI coding environment for Claude Code. It installs
|
|
3
|
+
"version": "0.4.36",
|
|
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
|
|
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 (
|
|
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
|
-
**
|
|
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/
|
|
@@ -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
|
|
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
|
-
|
|
868
|
+
1558 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:
|
|
872
|
+
# Results: 1558 passed, 0 failed, 1558 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.
|
|
4
|
-
"description": "AI coding environment —
|
|
3
|
+
"version": "0.4.36",
|
|
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"
|
package/templates/CLAUDE.md
CHANGED
|
@@ -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
|
|
@@ -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 |
|