azclaude-copilot 0.1.0
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 +27 -0
- package/.claude-plugin/plugin.json +17 -0
- package/LICENSE +21 -0
- package/README.md +477 -0
- package/bin/cli.js +1027 -0
- package/bin/copilot.js +228 -0
- package/hooks/README.md +3 -0
- package/hooks/hooks.json +40 -0
- package/package.json +41 -0
- package/templates/CLAUDE.md +51 -0
- package/templates/agents/cc-cli-integrator.md +104 -0
- package/templates/agents/cc-template-author.md +109 -0
- package/templates/agents/cc-test-maintainer.md +101 -0
- package/templates/agents/code-reviewer.md +136 -0
- package/templates/agents/loop-controller.md +118 -0
- package/templates/agents/orchestrator-init.md +196 -0
- package/templates/agents/test-writer.md +129 -0
- package/templates/capabilities/evolution/cycle2-knowledge.md +87 -0
- package/templates/capabilities/evolution/cycle3-topology.md +128 -0
- package/templates/capabilities/evolution/detect.md +103 -0
- package/templates/capabilities/evolution/evaluate.md +90 -0
- package/templates/capabilities/evolution/generate.md +123 -0
- package/templates/capabilities/evolution/re-derivation.md +77 -0
- package/templates/capabilities/intelligence/debate.md +104 -0
- package/templates/capabilities/intelligence/elo.md +122 -0
- package/templates/capabilities/intelligence/experiment.md +86 -0
- package/templates/capabilities/intelligence/opro.md +84 -0
- package/templates/capabilities/intelligence/pipeline.md +149 -0
- package/templates/capabilities/level-builders/level1-claudemd.md +52 -0
- package/templates/capabilities/level-builders/level2-mcp.md +58 -0
- package/templates/capabilities/level-builders/level3-skills.md +276 -0
- package/templates/capabilities/level-builders/level4-memory.md +72 -0
- package/templates/capabilities/level-builders/level5-agents.md +123 -0
- package/templates/capabilities/level-builders/level6-hooks.md +119 -0
- package/templates/capabilities/level-builders/level7-extmcp.md +60 -0
- package/templates/capabilities/level-builders/level8-orchestrated.md +98 -0
- package/templates/capabilities/manifest.md +58 -0
- package/templates/capabilities/shared/5-layer-agent.md +206 -0
- package/templates/capabilities/shared/completion-rule.md +44 -0
- package/templates/capabilities/shared/context-artifacts.md +96 -0
- package/templates/capabilities/shared/domain-advisor-generator.md +205 -0
- package/templates/capabilities/shared/friction-log.md +43 -0
- package/templates/capabilities/shared/multi-cli-paths.md +56 -0
- package/templates/capabilities/shared/native-tools.md +199 -0
- package/templates/capabilities/shared/plan-tracker.md +69 -0
- package/templates/capabilities/shared/pressure-test.md +88 -0
- package/templates/capabilities/shared/quality-check.md +83 -0
- package/templates/capabilities/shared/reflexes.md +159 -0
- package/templates/capabilities/shared/review-reception.md +70 -0
- package/templates/capabilities/shared/security.md +174 -0
- package/templates/capabilities/shared/semantic-boundary-check.md +140 -0
- package/templates/capabilities/shared/session-rhythm.md +42 -0
- package/templates/capabilities/shared/tdd.md +54 -0
- package/templates/capabilities/shared/vocabulary-transform.md +63 -0
- package/templates/commands/add.md +152 -0
- package/templates/commands/audit.md +123 -0
- package/templates/commands/blueprint.md +115 -0
- package/templates/commands/copilot.md +157 -0
- package/templates/commands/create.md +156 -0
- package/templates/commands/debate.md +75 -0
- package/templates/commands/deps.md +112 -0
- package/templates/commands/doc.md +100 -0
- package/templates/commands/dream.md +120 -0
- package/templates/commands/evolve.md +170 -0
- package/templates/commands/explain.md +25 -0
- package/templates/commands/find.md +100 -0
- package/templates/commands/fix.md +122 -0
- package/templates/commands/hookify.md +100 -0
- package/templates/commands/level-up.md +48 -0
- package/templates/commands/loop.md +62 -0
- package/templates/commands/migrate.md +119 -0
- package/templates/commands/persist.md +73 -0
- package/templates/commands/pulse.md +87 -0
- package/templates/commands/refactor.md +97 -0
- package/templates/commands/reflect.md +107 -0
- package/templates/commands/reflexes.md +141 -0
- package/templates/commands/setup.md +97 -0
- package/templates/commands/ship.md +131 -0
- package/templates/commands/snapshot.md +70 -0
- package/templates/commands/test.md +86 -0
- package/templates/hooks/post-tool-use.js +175 -0
- package/templates/hooks/stop.js +85 -0
- package/templates/hooks/user-prompt.js +96 -0
- package/templates/scripts/env-scan.sh +46 -0
- package/templates/scripts/import-graph.sh +88 -0
- package/templates/scripts/validate-boundaries.sh +180 -0
- package/templates/skills/agent-creator/SKILL.md +91 -0
- package/templates/skills/agent-creator/examples/sample-agent.md +80 -0
- package/templates/skills/agent-creator/references/agent-engineering-guide.md +596 -0
- package/templates/skills/agent-creator/references/quality-checklist.md +42 -0
- package/templates/skills/agent-creator/scripts/scaffold.sh +144 -0
- package/templates/skills/architecture-advisor/SKILL.md +92 -0
- package/templates/skills/architecture-advisor/references/database-decisions.md +61 -0
- package/templates/skills/architecture-advisor/references/decision-matrices.md +122 -0
- package/templates/skills/architecture-advisor/references/rendering-decisions.md +39 -0
- package/templates/skills/architecture-advisor/scripts/detect-scale.sh +67 -0
- package/templates/skills/debate/SKILL.md +36 -0
- package/templates/skills/debate/references/acemad-protocol.md +72 -0
- package/templates/skills/env-scanner/SKILL.md +41 -0
- package/templates/skills/security/SKILL.md +44 -0
- package/templates/skills/security/references/security-details.md +48 -0
- package/templates/skills/session-guard/SKILL.md +33 -0
- package/templates/skills/skill-creator/SKILL.md +82 -0
- package/templates/skills/skill-creator/examples/sample-skill.md +74 -0
- package/templates/skills/skill-creator/references/quality-checklist.md +36 -0
- package/templates/skills/skill-creator/references/skill-engineering-guide.md +365 -0
- package/templates/skills/skill-creator/scripts/scaffold.sh +75 -0
- package/templates/skills/test-first/SKILL.md +41 -0
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: level3-skills
|
|
3
|
+
description: >
|
|
4
|
+
Build Level 3: create project-specific skills and commands.
|
|
5
|
+
Triggers on: "build level 3", "add skill", "create command", "automate workflow".
|
|
6
|
+
tokens: ~250
|
|
7
|
+
requires: level2-mcp
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Level 3: Skills and Commands
|
|
11
|
+
|
|
12
|
+
Skills are invoked by the user (/command). Each skill is a self-contained instruction set.
|
|
13
|
+
Skills are Layer 2 in the progressive disclosure model — loaded only when invoked.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
### 3-Level Progressive Disclosure
|
|
18
|
+
|
|
19
|
+
Skills load in layers. Never dump the full body into context prematurely.
|
|
20
|
+
|
|
21
|
+
| Layer | What loads | When |
|
|
22
|
+
|-------|-----------|------|
|
|
23
|
+
| 1 — Metadata | Frontmatter description only (~20 words) | Session start — always |
|
|
24
|
+
| 2 — Body | Full skill instructions (≤ 500 lines) | When skill is invoked |
|
|
25
|
+
| 3 — References | `references/` subdirectory files | Only when body explicitly links to them |
|
|
26
|
+
|
|
27
|
+
**The `references/` subdir**: complex skills can have a `references/` folder next to the skill file containing large lookup tables, code templates, or spec extracts. The skill body links to these — they never auto-load.
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
.claude/commands/
|
|
31
|
+
add-endpoint.md ← Layer 2 body
|
|
32
|
+
references/
|
|
33
|
+
endpoint-template.ts ← Layer 3 (only loads if body says "read references/endpoint-template.ts")
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
### The Pushy Description Rule
|
|
39
|
+
|
|
40
|
+
**Claude undertriggers skills.** The description is the only thing read at Layer 1 — it must aggressively list every scenario that should activate the skill.
|
|
41
|
+
|
|
42
|
+
**Bad description (undertriggers):**
|
|
43
|
+
```yaml
|
|
44
|
+
description: >
|
|
45
|
+
Add a new React component to the project.
|
|
46
|
+
```
|
|
47
|
+
This only fires when the user says "add a React component". Misses: "new page", "new screen", "build a form", "create a UI for X".
|
|
48
|
+
|
|
49
|
+
**Good description (pushes back):**
|
|
50
|
+
```yaml
|
|
51
|
+
description: >
|
|
52
|
+
Add a new React component, page, screen, or UI element.
|
|
53
|
+
Triggers on: "new component", "new page", "new screen", "build a form",
|
|
54
|
+
"create a UI", "add a view", "make a <anything> component".
|
|
55
|
+
Use this whenever a new .tsx file needs to be created with project conventions.
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Rule: **List 10+ trigger scenarios. Overtriggering is better than undertriggering.**
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
### RECIPE vs REFERENCE — The Fundamental Distinction
|
|
63
|
+
|
|
64
|
+
**CLAUDE.md = what exists (REFERENCE)**
|
|
65
|
+
**Skills = how to do things (RECIPE)**
|
|
66
|
+
|
|
67
|
+
| If the sentence starts with… | It belongs in… |
|
|
68
|
+
|------------------------------|----------------|
|
|
69
|
+
| "The project has…" / "This repo uses…" | CLAUDE.md (REFERENCE) |
|
|
70
|
+
| "To add a…" / "When creating a…" / "Run these steps to…" | Skill file (RECIPE) |
|
|
71
|
+
|
|
72
|
+
**Test before writing**: Ask "Is this describing the state of the project, or the steps to accomplish something?" State → CLAUDE.md. Steps → Skill.
|
|
73
|
+
|
|
74
|
+
Mixing them creates skills that read like documentation and documents that read like instructions — both become useless.
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
### Anatomy of a Skill File
|
|
79
|
+
|
|
80
|
+
Every skill file requires:
|
|
81
|
+
```yaml
|
|
82
|
+
---
|
|
83
|
+
name: {skill-name}
|
|
84
|
+
description: [One clear sentence — what it does and when]
|
|
85
|
+
argument-hint: "[what arguments it expects]" # shows in autocomplete
|
|
86
|
+
disable-model-invocation: true # omit for auto-triggered skills
|
|
87
|
+
allowed-tools: Read, Grep, Bash # scoped permissions for this skill
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## /{skill-name} — Title
|
|
91
|
+
|
|
92
|
+
$ARGUMENTS
|
|
93
|
+
|
|
94
|
+
[body — ≤ 500 lines]
|
|
95
|
+
[reference pointers if needed: "For endpoint template, read references/endpoint-template.ts"]
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**All frontmatter fields:**
|
|
99
|
+
|
|
100
|
+
| Field | Required | Use when |
|
|
101
|
+
|-------|----------|----------|
|
|
102
|
+
| `name` | No | Defaults to filename. Set to override. |
|
|
103
|
+
| `description` | Yes | One sentence — what it does. Claude uses this for auto-triggering. |
|
|
104
|
+
| `argument-hint` | Recommended | Skill takes arguments — shows in `/` autocomplete. |
|
|
105
|
+
| `disable-model-invocation: true` | For manual commands | Prevents auto-triggering. Use for destructive or session-ending commands. |
|
|
106
|
+
| `allowed-tools` | Recommended | Scope permissions. Read-only skills: `Read, Grep`. Build skills: `Read, Write, Edit, Bash`. |
|
|
107
|
+
| `context: fork` | For heavy commands | Runs in isolated subagent. Use for long autonomous tasks (/evolve, /dream). |
|
|
108
|
+
| `user-invocable: false` | For background knowledge | Hides from `/` menu. Use for internal reference-only skills. |
|
|
109
|
+
|
|
110
|
+
**Dynamic injection** — inject real data before Claude reads the skill:
|
|
111
|
+
```markdown
|
|
112
|
+
## Current state
|
|
113
|
+
!`git log --oneline -5`
|
|
114
|
+
!`bash .claude/scripts/env-scan.sh 2>/dev/null`
|
|
115
|
+
```
|
|
116
|
+
The `!`command`` syntax runs the shell command immediately. Claude only sees the output — not the command. Use for `/pulse`, `/setup`, any skill that needs live project data.
|
|
117
|
+
|
|
118
|
+
**`ultrathink`** — include this word anywhere in the skill body to enable extended thinking for that skill.
|
|
119
|
+
|
|
120
|
+
**Body must include** (for RECIPE skills):
|
|
121
|
+
- Step-by-step instructions with exact commands
|
|
122
|
+
- Code templates (inline if short, reference link if long)
|
|
123
|
+
- Decision trees (if X then Y else Z)
|
|
124
|
+
- Anti-patterns with explicit "do NOT" labels
|
|
125
|
+
- Completion rule: what the user sees as proof of completion
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
### What Makes a Good Skill
|
|
130
|
+
|
|
131
|
+
1. **Single responsibility** — one skill does one thing
|
|
132
|
+
2. **Self-contained** — reads what it needs explicitly, doesn't assume other files are loaded
|
|
133
|
+
3. **Thin router or direct executor**:
|
|
134
|
+
- Thin router: "load capabilities/X.md and run it" (evolve.md, debate.md)
|
|
135
|
+
- Direct executor: contains the full instruction (fix.md, persist.md)
|
|
136
|
+
4. **Pushy description** — 3+ trigger variants listed
|
|
137
|
+
5. **Completion Rule enforced** — every skill ends with a concrete output requirement
|
|
138
|
+
6. **Self-correction wired in** — see CE 2.0 Self-Correction below
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
### CE 2.0 Self-Correction — Three Layers
|
|
143
|
+
|
|
144
|
+
Written instructions alone drift. These three layers make self-correction structural:
|
|
145
|
+
|
|
146
|
+
**Layer 1 — Bash exit-code gate (automatic, no judgment required)**
|
|
147
|
+
```bash
|
|
148
|
+
{command}; EXIT=$?
|
|
149
|
+
if [ $EXIT -ne 0 ]; then echo "FAILED — do not proceed"; fi
|
|
150
|
+
```
|
|
151
|
+
Use in any skill that runs a command and must not proceed on failure.
|
|
152
|
+
The gate catches the failure mechanically — Claude cannot "feel" that it passed.
|
|
153
|
+
|
|
154
|
+
**Layer 2 — Structured checkpoint (forced self-assessment before proceeding)**
|
|
155
|
+
```
|
|
156
|
+
Root cause: [file:line]
|
|
157
|
+
Mechanism: [why it breaks]
|
|
158
|
+
Fix: [what will change]
|
|
159
|
+
Confidence: [high / medium / low]
|
|
160
|
+
```
|
|
161
|
+
Placed at Phase 3 of diagnostic skills. If confidence = low → skill loops back.
|
|
162
|
+
Forces Claude to commit to a hypothesis before writing code.
|
|
163
|
+
|
|
164
|
+
**Layer 3 — Structured escalation after 2 attempts (not prose)**
|
|
165
|
+
```
|
|
166
|
+
Attempt 1: [file:line — what was changed]
|
|
167
|
+
Result 1: [exact error output]
|
|
168
|
+
|
|
169
|
+
Attempt 2: [file:line — what was changed]
|
|
170
|
+
Result 2: [exact error output]
|
|
171
|
+
|
|
172
|
+
Stuck at: [file:line]
|
|
173
|
+
Need: [specific info or decision that would unblock this]
|
|
174
|
+
```
|
|
175
|
+
After 2 failed attempts, report this format — not "I'm sorry, I couldn't fix it."
|
|
176
|
+
Structured output lets the user unblock the agent in one reply.
|
|
177
|
+
|
|
178
|
+
**When to apply each layer:**
|
|
179
|
+
| Layer | Apply when |
|
|
180
|
+
|-------|-----------|
|
|
181
|
+
| Exit-code gate | Any skill that runs bash and must not proceed on failure |
|
|
182
|
+
| Structured checkpoint | Diagnostic skills (fix, debug, investigate) |
|
|
183
|
+
| Structured escalation | Any skill with a retry loop |
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
### Command Design — Encode Decisions, Not Delegation
|
|
188
|
+
|
|
189
|
+
**Test**: If deleting the command and telling the agent directly gives the same result → the command adds no value. Rewrite it.
|
|
190
|
+
|
|
191
|
+
**Bad command (thin delegator):**
|
|
192
|
+
```
|
|
193
|
+
## /add-feature
|
|
194
|
+
Tell the user to plan the feature, write tests, implement it, and open a PR.
|
|
195
|
+
```
|
|
196
|
+
This delegates work back to Claude with no constraints. Claude will ask clarifying questions instead of acting.
|
|
197
|
+
|
|
198
|
+
**Good command (encodes the decision tree):**
|
|
199
|
+
```
|
|
200
|
+
## /add-feature
|
|
201
|
+
1. Read CLAUDE.md → identify domain and stack
|
|
202
|
+
2. If domain = developer → check tdd.md Iron Law first (tests before code)
|
|
203
|
+
3. Identify affected modules from $ARGUMENTS
|
|
204
|
+
4. Check co-change history: git log --follow -p -- {module} | grep "^+++ b/"
|
|
205
|
+
5. Write failing test → implement → green → commit
|
|
206
|
+
6. Output: test count before/after, files changed, ready for /ship
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
**Standard commands to always generate for developer projects:**
|
|
210
|
+
|
|
211
|
+
These three are installed by `npx azclaude` into `.claude/commands/` automatically.
|
|
212
|
+
|
|
213
|
+
Check they exist — if not, the install is incomplete:
|
|
214
|
+
```bash
|
|
215
|
+
ls .claude/commands/add.md .claude/commands/audit.md .claude/commands/test.md 2>/dev/null \
|
|
216
|
+
|| echo "Missing — re-run: npx azclaude"
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
If this project is a **Code** category (has package.json / Cargo.toml / etc.) — all three must be present. No exceptions.
|
|
220
|
+
|
|
221
|
+
| Command | What it encodes |
|
|
222
|
+
|---------|----------------|
|
|
223
|
+
| `add.md` | Feature addition: scope intake → understand pattern → TDD → implement → verify |
|
|
224
|
+
| `audit.md` | Spec compliance first → code quality second — uses EnterPlanMode |
|
|
225
|
+
| `test.md` | IDE diagnostics → run suite → interpret failures → apply /fix |
|
|
226
|
+
|
|
227
|
+
**Stack-specific commands to generate when stack detected:**
|
|
228
|
+
| Stack | Generate |
|
|
229
|
+
|-------|---------|
|
|
230
|
+
| Next.js / React | `new-page.md`, `new-component.md` |
|
|
231
|
+
| Express / FastAPI | `new-endpoint.md` |
|
|
232
|
+
| Any DB | `migrate.md` |
|
|
233
|
+
| Any deploy config | `deploy.md` |
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
### Native Tools in Skills
|
|
238
|
+
|
|
239
|
+
Before writing any new skill: load `capabilities/shared/native-tools.md`.
|
|
240
|
+
Every skill that collects user input, tracks progress, or runs commands must use the appropriate native tool — not simulate it with prose.
|
|
241
|
+
|
|
242
|
+
Quick check before writing:
|
|
243
|
+
- Does this skill ask questions? → `AskUserQuestion`
|
|
244
|
+
- Does this skill have multiple steps? → `TaskCreate/TaskUpdate`
|
|
245
|
+
- Does this skill do analysis before action? → `EnterPlanMode/ExitPlanMode`
|
|
246
|
+
- Does this skill run risky changes? → `EnterWorktree`
|
|
247
|
+
- Does this skill run a command and check result? → exit-code gate
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
### Check shared-skills First
|
|
252
|
+
Before creating a new skill:
|
|
253
|
+
```bash
|
|
254
|
+
ls ~/shared-skills/ 2>/dev/null
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
If a matching skill exists and its tech stack matches this project → import it:
|
|
258
|
+
```bash
|
|
259
|
+
cp ~/shared-skills/{skill}.md .claude/commands/{skill}.md
|
|
260
|
+
```
|
|
261
|
+
Log which portable skills were imported and from which project.
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
### Skill Placement
|
|
266
|
+
- `.claude/commands/{skill}.md` — project-specific skills
|
|
267
|
+
- `~/shared-skills/{skill}.md` — general skills that work across projects (after k=10 gate)
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
### Level 3 Complete When
|
|
272
|
+
- At least 3 project-specific skills exist
|
|
273
|
+
- Each has a pushy description (3+ trigger variants)
|
|
274
|
+
- Each passes RECIPE vs REFERENCE test
|
|
275
|
+
- Body ≤ 500 lines (overflow goes to references/ subdir)
|
|
276
|
+
- shared-skills checked and relevant ones imported
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: level4-memory
|
|
3
|
+
description: >
|
|
4
|
+
Build Level 4: memory system with goals.md, session logs, friction logs.
|
|
5
|
+
Triggers on: "build level 4", "add memory", "set up session tracking".
|
|
6
|
+
tokens: ~200
|
|
7
|
+
requires: level3-skills
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Level 4: Memory System
|
|
11
|
+
|
|
12
|
+
Memory has 6 layers in Claude Code. AZCLAUDE uses layers 1-3 natively.
|
|
13
|
+
|
|
14
|
+
| Layer | What | Always loaded? |
|
|
15
|
+
|-------|------|----------------|
|
|
16
|
+
| 1 | CLAUDE.md | ✅ Yes |
|
|
17
|
+
| 2 | Auto memory (.claude/memory/) | ❌ On-demand |
|
|
18
|
+
| 3 | Modular rules (.claude/rules/) | ❌ On-demand |
|
|
19
|
+
| 4 | Skill metadata (frontmatter) | ✅ Lightweight |
|
|
20
|
+
| 5 | Skill bodies | ❌ On-demand |
|
|
21
|
+
| 6 | External memory (goals.md via hook) | ✅ Via hook |
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
### Create Memory Directories
|
|
26
|
+
```bash
|
|
27
|
+
mkdir -p .claude/memory/sessions
|
|
28
|
+
mkdir -p .claude/memory/learnings
|
|
29
|
+
mkdir -p ops/observations
|
|
30
|
+
mkdir -p shared-skills
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
### Create goals.md
|
|
36
|
+
Write `.claude/memory/goals.md`:
|
|
37
|
+
```markdown
|
|
38
|
+
# Goals — {project_name}
|
|
39
|
+
Updated: {date}
|
|
40
|
+
|
|
41
|
+
## Current threads
|
|
42
|
+
(describe what's in progress)
|
|
43
|
+
|
|
44
|
+
## Done this session
|
|
45
|
+
- Initial setup complete
|
|
46
|
+
|
|
47
|
+
## Next actions
|
|
48
|
+
1. {first concrete action}
|
|
49
|
+
2. {second concrete action}
|
|
50
|
+
3. {third concrete action}
|
|
51
|
+
|
|
52
|
+
## Open blockers
|
|
53
|
+
(none)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
### Memory Access Pattern (3-layer)
|
|
59
|
+
Never read all memory files eagerly. Use the 3-layer pattern:
|
|
60
|
+
1. **Search** — grep keywords, list files (no content read)
|
|
61
|
+
2. **Filter** — recency (last 5 sessions), relevance (keyword match)
|
|
62
|
+
3. **Read** — only files that passed filter
|
|
63
|
+
|
|
64
|
+
Cost: Layer 1+2 ≈ 100 tokens. Layer 3: only matched files.
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
### Level 4 Complete When
|
|
69
|
+
- `.claude/memory/goals.md` exists with correct structure
|
|
70
|
+
- `ops/observations/` directory exists for friction logs
|
|
71
|
+
- `shared-skills/` directory exists for portable skills
|
|
72
|
+
- Hook injects goals.md automatically (set up in Level 6)
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: level5-agents
|
|
3
|
+
description: >
|
|
4
|
+
Build Level 5: project-specific custom agents.
|
|
5
|
+
Triggers on: "build level 5", "create agent", "add custom agent".
|
|
6
|
+
tokens: ~300
|
|
7
|
+
requires: level4-memory
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Level 5: Custom Agents
|
|
11
|
+
|
|
12
|
+
Custom agents are defined in `.claude/agents/{name}.md`.
|
|
13
|
+
They fire when spawned via the Agent tool from a skill or CLAUDE.md routing.
|
|
14
|
+
|
|
15
|
+
Load shared/5-layer-agent.md for the full structure definition.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
### When to Create a Custom Agent
|
|
20
|
+
|
|
21
|
+
Create an agent when:
|
|
22
|
+
- The task genuinely requires isolation (fresh context window)
|
|
23
|
+
- The task is parallelizable with other agents (multiple files to analyze simultaneously)
|
|
24
|
+
- The task is too long to run in the parent context without polluting it
|
|
25
|
+
|
|
26
|
+
Do NOT create an agent when:
|
|
27
|
+
- A skill with direct tool calls can do the same work
|
|
28
|
+
- The "agent" would just read one file and return its content
|
|
29
|
+
- You're using agents as a routing mechanism (routing belongs in CLAUDE.md)
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
### Co-Change Analysis — Determine Agent Boundaries
|
|
34
|
+
|
|
35
|
+
Do NOT create one agent per directory. Check what changes together:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# Files frequently edited together in the same commits
|
|
39
|
+
git log --name-only --format="" --diff-filter=M \
|
|
40
|
+
| sort | uniq -c | sort -rn | head -30
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Rule**: Directories in the same commits → same agent.
|
|
44
|
+
Example: if `api/routes/` and `extraction/` always change together,
|
|
45
|
+
one agent owns both — not two.
|
|
46
|
+
|
|
47
|
+
**Rule**: Testing is a responsibility, not a role.
|
|
48
|
+
The agent that owns `engine/` also owns `tests/engine/`.
|
|
49
|
+
Do NOT create a separate tester agent unless tests are truly
|
|
50
|
+
independent from the code they test (rare).
|
|
51
|
+
|
|
52
|
+
3 focused agents with clear boundaries > 6 overlapping agents.
|
|
53
|
+
|
|
54
|
+
**Good agent split** (files that change independently):
|
|
55
|
+
```
|
|
56
|
+
agent: frontend-agent → src/components/, src/pages/ (UI changes alone)
|
|
57
|
+
agent: api-agent → src/api/, src/middleware/ (backend changes alone)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**Bad agent split** (files that always change together):
|
|
61
|
+
```
|
|
62
|
+
agent: schema-agent → src/db/schema/ (these always change
|
|
63
|
+
agent: migration-agent → src/db/migrations/ ← with schema — merge them)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Framework Collision Detection
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
grep -r "langgraph\|crewai\|autogen\|langchain.*agent" \
|
|
70
|
+
pyproject.toml package.json 2>/dev/null | head -5
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
If found: prefix ALL Claude Code agents with `cc-` (e.g., `cc-frontend`).
|
|
74
|
+
Add to every agent description: `# Claude Code Development Agent (not a {framework} application agent)`
|
|
75
|
+
|
|
76
|
+
This prevents Claude from confusing the application's LangGraph agents with Claude Code agents.
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
### Agent File Structure
|
|
81
|
+
```yaml
|
|
82
|
+
---
|
|
83
|
+
name: {agent-name}
|
|
84
|
+
description: >
|
|
85
|
+
What this agent does. When to spawn it.
|
|
86
|
+
Include: what input it receives, what output it produces.
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Layer 1: PERSONA
|
|
90
|
+
{Who this agent is — role, not personality}
|
|
91
|
+
|
|
92
|
+
## Layer 2: SCOPE
|
|
93
|
+
{What it does. What it explicitly does NOT do.}
|
|
94
|
+
|
|
95
|
+
## Layer 3: TOOLS & RESOURCES
|
|
96
|
+
{Which tools it may use. Which capability files to load for this task.}
|
|
97
|
+
|
|
98
|
+
## Layer 4: CONSTRAINTS
|
|
99
|
+
{Hard limits. What it must never do.}
|
|
100
|
+
|
|
101
|
+
## Layer 5: DOMAIN CONTEXT
|
|
102
|
+
{Domain knowledge specific to this project that shapes every decision.}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
### Context Passing to Agents
|
|
108
|
+
|
|
109
|
+
When spawning this agent, pass ONLY:
|
|
110
|
+
- The specific capability file for its task (not the full module)
|
|
111
|
+
- The output from the previous step (not the full conversation)
|
|
112
|
+
- Shared rules if the task requires them (tdd.md, completion-rule.md)
|
|
113
|
+
|
|
114
|
+
Pass micro-sections, not monoliths. A detection agent gets detect.md (~100 lines).
|
|
115
|
+
Not a full module file — pass only the micro-section for the specific task.
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
### Level 5 Complete When
|
|
120
|
+
- At least 1 custom agent exists for a genuine parallel/isolation use case
|
|
121
|
+
- Each agent has all 5 layers
|
|
122
|
+
- Each agent passes self-applicability check
|
|
123
|
+
- Agents are listed in manifest.md if they need to be discoverable
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: level6-hooks
|
|
3
|
+
description: >
|
|
4
|
+
Build Level 6: lifecycle hooks for automatic context injection.
|
|
5
|
+
Triggers on: "build level 6", "add hooks", "automate session start".
|
|
6
|
+
tokens: ~200
|
|
7
|
+
requires: level5-agents
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Level 6: Lifecycle Hooks
|
|
11
|
+
|
|
12
|
+
Hooks are PUSH-based, not PULL-based. They fire automatically on events.
|
|
13
|
+
Claude does not need to remember to read goals.md — the hook injects it.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
### Global vs Project-Level
|
|
18
|
+
|
|
19
|
+
| Type | What | Where | When |
|
|
20
|
+
|------|------|-------|------|
|
|
21
|
+
| Global | UserPromptSubmit + Stop | `~/.claude/settings.json` | Every project, installed once |
|
|
22
|
+
| Project | Formatter, linter, project-specific | `.claude/settings.json` | This project only |
|
|
23
|
+
|
|
24
|
+
Global hooks are installed by the `npx azclaude` command.
|
|
25
|
+
Project hooks are added here if needed beyond the global defaults.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
### Defense in Depth — 3-Layer Session Safety
|
|
30
|
+
|
|
31
|
+
Three independent layers ensure session state is never lost. Any single layer can fail
|
|
32
|
+
and the other two catch it. This is not redundancy — each layer covers a different failure mode.
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
Layer 1: CLAUDE.md instruction
|
|
36
|
+
↓ "Read .claude/memory/goals.md at session start"
|
|
37
|
+
Failure mode: Claude ignores it (instruction drift)
|
|
38
|
+
Coverage: always in context — lowest reliability
|
|
39
|
+
|
|
40
|
+
Layer 2: UserPromptSubmit hook
|
|
41
|
+
↓ Injects goals.md content into every prompt automatically
|
|
42
|
+
Failure mode: Node.js not in PATH (rare — Node ≥ 16 required, same as npm)
|
|
43
|
+
Coverage: PUSH-based, doesn't depend on Claude following instructions
|
|
44
|
+
|
|
45
|
+
Layer 3: Stop hook
|
|
46
|
+
↓ Creates friction stub when session ends without /persist
|
|
47
|
+
Failure mode: hook not installed, session crashes
|
|
48
|
+
Coverage: catches unclean exits that Layer 1+2 cannot
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**Why all 3 are required**: Layer 1 alone = broken when Claude is busy. Layer 2 alone = broken if Node.js unavailable (extremely rare). Layer 3 alone = reactive not proactive. Together = session state survives all common failure modes.
|
|
52
|
+
|
|
53
|
+
**Installing Layer 2+3**: `npx azclaude` installs global hooks to `~/.claude/settings.json`.
|
|
54
|
+
**Installing Layer 1**: `/setup` writes the instruction into CLAUDE.md.
|
|
55
|
+
|
|
56
|
+
CLAUDE.md creates goals.md if it doesn't exist yet.
|
|
57
|
+
The hook injects it if it does exist and is stale.
|
|
58
|
+
Both layers cover the same need — defense in depth.
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
### PostToolUse Auto-Format Hooks (Project-Level)
|
|
63
|
+
|
|
64
|
+
After detecting the project stack, generate a `.claude/settings.json` with auto-format:
|
|
65
|
+
|
|
66
|
+
```json
|
|
67
|
+
{
|
|
68
|
+
"hooks": {
|
|
69
|
+
"PostToolUse": [
|
|
70
|
+
{
|
|
71
|
+
"matcher": "Write|Edit",
|
|
72
|
+
"hooks": [{ "type": "command", "command": "case \"$CLAUDE_FILE_PATH\" in *[';''|''&''`''$''('')''>''<']*) exit 0 ;; esac && {stack-specific command}" }]
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
> **Security**: Sanitize `$CLAUDE_FILE_PATH` using a `case...in` guard — rejects paths
|
|
80
|
+
> containing shell metacharacters before the formatter runs. A path like `; rm -rf /;.ts`
|
|
81
|
+
> exits silently instead of executing. See `shared/security.md` for full details.
|
|
82
|
+
|
|
83
|
+
**Format command by stack:**
|
|
84
|
+
|
|
85
|
+
| Stack detected | Format command |
|
|
86
|
+
|---------------|----------------|
|
|
87
|
+
| Node/TypeScript | `npx prettier --write "$CLAUDE_FILE_PATH" 2>/dev/null \|\| true` |
|
|
88
|
+
| Python | `ruff format "$CLAUDE_FILE_PATH" 2>/dev/null \|\| black "$CLAUDE_FILE_PATH" 2>/dev/null \|\| true` |
|
|
89
|
+
| Go | `gofmt -w "$CLAUDE_FILE_PATH" 2>/dev/null \|\| true` |
|
|
90
|
+
| Rust | `rustfmt "$CLAUDE_FILE_PATH" 2>/dev/null \|\| true` |
|
|
91
|
+
| Ruby | `rubocop --autocorrect "$CLAUDE_FILE_PATH" 2>/dev/null \|\| true` |
|
|
92
|
+
|
|
93
|
+
All commands end with `|| true` — format errors must never fail the tool call.
|
|
94
|
+
Only add if the formatter is confirmed installed (`which prettier` etc.).
|
|
95
|
+
|
|
96
|
+
**The split**:
|
|
97
|
+
- `~/.claude/settings.json` → lifecycle hooks (UserPromptSubmit, Stop) — global, installed once by `npx azclaude`
|
|
98
|
+
- `.claude/settings.json` → formatter hooks (PostToolUse) — project-specific, per stack, generated by `/setup`
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
### Global Hook Behavior
|
|
103
|
+
|
|
104
|
+
The exact hook commands are defined in `bin/cli.js` — that is the source of truth.
|
|
105
|
+
Do not duplicate the hook code here; reference it instead.
|
|
106
|
+
|
|
107
|
+
**UserPromptSubmit** — runs `~/.claude/hooks/user-prompt.js` (Node.js, cross-platform). Injects `goals.md` once at session start using `os.tmpdir()/.azclaude-session-{ppid}`. Fires on the first prompt only — not on every subsequent prompt.
|
|
108
|
+
|
|
109
|
+
**Stop** — runs `~/.claude/hooks/stop.js` (Node.js, cross-platform). Fires when session ends:
|
|
110
|
+
- Stamps `goals.md` with today's date
|
|
111
|
+
- Creates friction stub in `ops/observations/` if `/persist` was not run
|
|
112
|
+
- Warns: "session state not persisted — run /persist before closing"
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
### Level 6 Complete When
|
|
117
|
+
- Global hooks confirmed in `~/.claude/settings.json` (`_azclaude: true`)
|
|
118
|
+
- goals.md is auto-injected at session start
|
|
119
|
+
- Stop hook creates friction stubs on unclean exits
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: level7-extmcp
|
|
3
|
+
description: >
|
|
4
|
+
Build Level 7: external MCP servers and advanced tool composition.
|
|
5
|
+
Triggers on: "build level 7", "external MCP", "advanced tools".
|
|
6
|
+
tokens: ~150
|
|
7
|
+
requires: level6-hooks
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Level 7: External MCP Servers
|
|
11
|
+
|
|
12
|
+
Level 7 extends Claude's capabilities beyond the project boundary.
|
|
13
|
+
External MCPs connect Claude to the world: databases, browsers, APIs, services.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
### What Qualifies as Level 7
|
|
18
|
+
|
|
19
|
+
- External data sources (production database, analytics, monitoring)
|
|
20
|
+
- Browser automation (Playwright, Puppeteer)
|
|
21
|
+
- Communication tools (Slack, email, GitHub issues)
|
|
22
|
+
- Cloud services (AWS, GCP, deployment pipelines)
|
|
23
|
+
- Cross-project memory (azrole-memory or equivalent)
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
### Validation Before Installing
|
|
28
|
+
|
|
29
|
+
For each external MCP:
|
|
30
|
+
1. Does the project actually need this capability?
|
|
31
|
+
2. Is the MCP server trusted? (check source, not just npm package name)
|
|
32
|
+
3. What data does it access? Document it.
|
|
33
|
+
4. Does it require credentials? Store in env, never in .mcp.json plaintext.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
### Cross-Project Memory (optional)
|
|
38
|
+
|
|
39
|
+
If working across multiple projects and want shared patterns:
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"mcpServers": {
|
|
43
|
+
"memory": {
|
|
44
|
+
"command": "node",
|
|
45
|
+
"args": ["/path/to/memory-server.js"]
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Cross-project memory stores: goals, friction patterns, ELO scores, portable skills.
|
|
52
|
+
It does NOT replace project-level memory — it supplements it.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
### Level 7 Complete When
|
|
57
|
+
- External MCPs installed and verified with test calls
|
|
58
|
+
- Credentials in environment variables, not in committed files
|
|
59
|
+
- Each server documented in manifest.md or .mcp.json comments
|
|
60
|
+
- No external MCP accesses data it doesn't need (principle of least access)
|