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.
Files changed (108) hide show
  1. package/.claude-plugin/marketplace.json +27 -0
  2. package/.claude-plugin/plugin.json +17 -0
  3. package/LICENSE +21 -0
  4. package/README.md +477 -0
  5. package/bin/cli.js +1027 -0
  6. package/bin/copilot.js +228 -0
  7. package/hooks/README.md +3 -0
  8. package/hooks/hooks.json +40 -0
  9. package/package.json +41 -0
  10. package/templates/CLAUDE.md +51 -0
  11. package/templates/agents/cc-cli-integrator.md +104 -0
  12. package/templates/agents/cc-template-author.md +109 -0
  13. package/templates/agents/cc-test-maintainer.md +101 -0
  14. package/templates/agents/code-reviewer.md +136 -0
  15. package/templates/agents/loop-controller.md +118 -0
  16. package/templates/agents/orchestrator-init.md +196 -0
  17. package/templates/agents/test-writer.md +129 -0
  18. package/templates/capabilities/evolution/cycle2-knowledge.md +87 -0
  19. package/templates/capabilities/evolution/cycle3-topology.md +128 -0
  20. package/templates/capabilities/evolution/detect.md +103 -0
  21. package/templates/capabilities/evolution/evaluate.md +90 -0
  22. package/templates/capabilities/evolution/generate.md +123 -0
  23. package/templates/capabilities/evolution/re-derivation.md +77 -0
  24. package/templates/capabilities/intelligence/debate.md +104 -0
  25. package/templates/capabilities/intelligence/elo.md +122 -0
  26. package/templates/capabilities/intelligence/experiment.md +86 -0
  27. package/templates/capabilities/intelligence/opro.md +84 -0
  28. package/templates/capabilities/intelligence/pipeline.md +149 -0
  29. package/templates/capabilities/level-builders/level1-claudemd.md +52 -0
  30. package/templates/capabilities/level-builders/level2-mcp.md +58 -0
  31. package/templates/capabilities/level-builders/level3-skills.md +276 -0
  32. package/templates/capabilities/level-builders/level4-memory.md +72 -0
  33. package/templates/capabilities/level-builders/level5-agents.md +123 -0
  34. package/templates/capabilities/level-builders/level6-hooks.md +119 -0
  35. package/templates/capabilities/level-builders/level7-extmcp.md +60 -0
  36. package/templates/capabilities/level-builders/level8-orchestrated.md +98 -0
  37. package/templates/capabilities/manifest.md +58 -0
  38. package/templates/capabilities/shared/5-layer-agent.md +206 -0
  39. package/templates/capabilities/shared/completion-rule.md +44 -0
  40. package/templates/capabilities/shared/context-artifacts.md +96 -0
  41. package/templates/capabilities/shared/domain-advisor-generator.md +205 -0
  42. package/templates/capabilities/shared/friction-log.md +43 -0
  43. package/templates/capabilities/shared/multi-cli-paths.md +56 -0
  44. package/templates/capabilities/shared/native-tools.md +199 -0
  45. package/templates/capabilities/shared/plan-tracker.md +69 -0
  46. package/templates/capabilities/shared/pressure-test.md +88 -0
  47. package/templates/capabilities/shared/quality-check.md +83 -0
  48. package/templates/capabilities/shared/reflexes.md +159 -0
  49. package/templates/capabilities/shared/review-reception.md +70 -0
  50. package/templates/capabilities/shared/security.md +174 -0
  51. package/templates/capabilities/shared/semantic-boundary-check.md +140 -0
  52. package/templates/capabilities/shared/session-rhythm.md +42 -0
  53. package/templates/capabilities/shared/tdd.md +54 -0
  54. package/templates/capabilities/shared/vocabulary-transform.md +63 -0
  55. package/templates/commands/add.md +152 -0
  56. package/templates/commands/audit.md +123 -0
  57. package/templates/commands/blueprint.md +115 -0
  58. package/templates/commands/copilot.md +157 -0
  59. package/templates/commands/create.md +156 -0
  60. package/templates/commands/debate.md +75 -0
  61. package/templates/commands/deps.md +112 -0
  62. package/templates/commands/doc.md +100 -0
  63. package/templates/commands/dream.md +120 -0
  64. package/templates/commands/evolve.md +170 -0
  65. package/templates/commands/explain.md +25 -0
  66. package/templates/commands/find.md +100 -0
  67. package/templates/commands/fix.md +122 -0
  68. package/templates/commands/hookify.md +100 -0
  69. package/templates/commands/level-up.md +48 -0
  70. package/templates/commands/loop.md +62 -0
  71. package/templates/commands/migrate.md +119 -0
  72. package/templates/commands/persist.md +73 -0
  73. package/templates/commands/pulse.md +87 -0
  74. package/templates/commands/refactor.md +97 -0
  75. package/templates/commands/reflect.md +107 -0
  76. package/templates/commands/reflexes.md +141 -0
  77. package/templates/commands/setup.md +97 -0
  78. package/templates/commands/ship.md +131 -0
  79. package/templates/commands/snapshot.md +70 -0
  80. package/templates/commands/test.md +86 -0
  81. package/templates/hooks/post-tool-use.js +175 -0
  82. package/templates/hooks/stop.js +85 -0
  83. package/templates/hooks/user-prompt.js +96 -0
  84. package/templates/scripts/env-scan.sh +46 -0
  85. package/templates/scripts/import-graph.sh +88 -0
  86. package/templates/scripts/validate-boundaries.sh +180 -0
  87. package/templates/skills/agent-creator/SKILL.md +91 -0
  88. package/templates/skills/agent-creator/examples/sample-agent.md +80 -0
  89. package/templates/skills/agent-creator/references/agent-engineering-guide.md +596 -0
  90. package/templates/skills/agent-creator/references/quality-checklist.md +42 -0
  91. package/templates/skills/agent-creator/scripts/scaffold.sh +144 -0
  92. package/templates/skills/architecture-advisor/SKILL.md +92 -0
  93. package/templates/skills/architecture-advisor/references/database-decisions.md +61 -0
  94. package/templates/skills/architecture-advisor/references/decision-matrices.md +122 -0
  95. package/templates/skills/architecture-advisor/references/rendering-decisions.md +39 -0
  96. package/templates/skills/architecture-advisor/scripts/detect-scale.sh +67 -0
  97. package/templates/skills/debate/SKILL.md +36 -0
  98. package/templates/skills/debate/references/acemad-protocol.md +72 -0
  99. package/templates/skills/env-scanner/SKILL.md +41 -0
  100. package/templates/skills/security/SKILL.md +44 -0
  101. package/templates/skills/security/references/security-details.md +48 -0
  102. package/templates/skills/session-guard/SKILL.md +33 -0
  103. package/templates/skills/skill-creator/SKILL.md +82 -0
  104. package/templates/skills/skill-creator/examples/sample-skill.md +74 -0
  105. package/templates/skills/skill-creator/references/quality-checklist.md +36 -0
  106. package/templates/skills/skill-creator/references/skill-engineering-guide.md +365 -0
  107. package/templates/skills/skill-creator/scripts/scaffold.sh +75 -0
  108. package/templates/skills/test-first/SKILL.md +41 -0
@@ -0,0 +1,119 @@
1
+ ---
2
+ name: migrate
3
+ description: >
4
+ Upgrade dependencies, frameworks, or language versions safely.
5
+ Reads changelogs, finds breaking changes, applies fixes, runs tests.
6
+ Triggers on: "upgrade", "migrate", "update dependency", "bump version",
7
+ "move to React 19", "upgrade Node", "update packages", "breaking changes".
8
+ argument-hint: "[what to upgrade — package name, framework, or 'all']"
9
+ disable-model-invocation: true
10
+ allowed-tools: Read, Write, Edit, Bash, Glob, Grep
11
+ ---
12
+
13
+ # /migrate — Safe Dependency & Framework Migration
14
+
15
+ $ARGUMENTS
16
+
17
+ Load: shared/completion-rule.md
18
+
19
+ ---
20
+
21
+ ## Phase 1: Assess Current State
22
+
23
+ If $ARGUMENTS is blank, use **AskUserQuestion**:
24
+ - What needs upgrading? (specific package, framework, or language version)
25
+ - What target version?
26
+
27
+ 1. Read current versions:
28
+ ```bash
29
+ # Node.js / npm
30
+ cat package.json | head -30
31
+ npm outdated 2>&1 | head -20
32
+
33
+ # Python
34
+ cat requirements.txt 2>/dev/null || cat pyproject.toml 2>/dev/null | head -30
35
+ pip list --outdated 2>&1 | head -20
36
+ ```
37
+
38
+ 2. Run tests BEFORE migration:
39
+ ```bash
40
+ {test command}; EXIT=$?
41
+ echo "BEFORE migration — Exit: $EXIT"
42
+ ```
43
+
44
+ **If tests fail before migration: STOP.** Fix first with `/fix`.
45
+
46
+ ---
47
+
48
+ ## Phase 2: Research Breaking Changes
49
+
50
+ For each package being upgraded:
51
+ ```bash
52
+ # Check changelog / release notes
53
+ npm view {package} versions --json 2>/dev/null | tail -5
54
+ ```
55
+
56
+ Use **WebSearch** for major version upgrades:
57
+ - `"{package} migration guide v{old} to v{new}"`
58
+ - `"{package} breaking changes v{new}"`
59
+
60
+ Build a migration checklist:
61
+ ```
62
+ Package: {name} {old} → {new}
63
+ Breaking changes: {list each one}
64
+ Files affected: {grep for usage}
65
+ Migration steps: {ordered list}
66
+ ```
67
+
68
+ ---
69
+
70
+ ## Phase 3: Apply Migration
71
+
72
+ **For major version upgrades**: use **EnterWorktree** to isolate.
73
+
74
+ 1. Update the dependency:
75
+ ```bash
76
+ # npm
77
+ npm install {package}@{version}
78
+ # pip
79
+ pip install {package}=={version}
80
+ ```
81
+
82
+ 2. Apply breaking change fixes — one at a time:
83
+ - Fix each breaking change
84
+ - Reference: `file:line — what changed and why`
85
+ - Run tests after each fix
86
+
87
+ 3. Check for deprecation warnings:
88
+ ```bash
89
+ {test command} 2>&1 | grep -i "deprecat\|warning" | head -10
90
+ ```
91
+
92
+ ---
93
+
94
+ ## Phase 4: Verify
95
+
96
+ Run the full test suite AFTER migration:
97
+ ```bash
98
+ {test command}; EXIT=$?
99
+ echo "AFTER migration — Exit: $EXIT"
100
+ if [ $EXIT -ne 0 ]; then echo "MIGRATION BROKE SOMETHING — check breaking changes"; fi
101
+ ```
102
+
103
+ Check:
104
+ - All tests pass
105
+ - No new deprecation warnings
106
+ - Lock file updated (package-lock.json / poetry.lock)
107
+ - No leftover old version references
108
+
109
+ ---
110
+
111
+ ## Completion Rule
112
+
113
+ Show:
114
+ 1. Before: package versions and test output
115
+ 2. Breaking changes found and how each was resolved
116
+ 3. After: updated versions and test output
117
+ 4. Lock file changes: `git diff --stat`
118
+
119
+ Do not say "migration complete" without showing both test runs.
@@ -0,0 +1,73 @@
1
+ ---
2
+ name: persist
3
+ description: End the session — update goals.md, write friction log, append session summary. Run before closing.
4
+ disable-model-invocation: true
5
+ allowed-tools: Read, Write, Edit
6
+ ---
7
+
8
+ # /persist — Session End
9
+
10
+ Load: shared/session-rhythm.md + shared/friction-log.md
11
+
12
+ ---
13
+
14
+ ## Step 1: Update goals.md
15
+
16
+ Read `.claude/memory/goals.md`. Update these sections:
17
+
18
+ **Current threads** — what is still in progress (not done, not blocked)
19
+ **Done this session** — what was completed (specific, not vague)
20
+ **Next actions** — top 3 concrete next steps only
21
+ **Open blockers** — anything that blocked progress
22
+
23
+ Write the updated file back. Do NOT skip even if the session was short.
24
+
25
+ ---
26
+
27
+ ## Step 2: Write Friction Log (only if there's real friction)
28
+
29
+ Review the session. If ANY of the four categories below apply, write `ops/observations/{YYYY-MM-DD}-{slug}-friction.md`:
30
+ ```
31
+ ---
32
+ date: {ISO date}
33
+ type: friction
34
+ ---
35
+
36
+ ## Harder than it should be
37
+ {what was harder}
38
+
39
+ ## Repeated from last session
40
+ {what repeated}
41
+
42
+ ## Took longer than expected
43
+ {what was slow}
44
+
45
+ ## Environment is missing something
46
+ {what's missing}
47
+ ```
48
+
49
+ If ALL four categories are "None" — skip this file entirely. No friction = no file.
50
+ Only write when there's a real signal worth capturing.
51
+
52
+ ---
53
+
54
+ ## Step 3: Append Session Summary
55
+
56
+ Append to `.claude/memory/sessions/{date}-session.md`:
57
+ ```yaml
58
+ ---
59
+ date: {ISO date}
60
+ topics: [{what was worked on}]
61
+ ---
62
+
63
+ {2-3 sentences: what changed, what was learned, what's next}
64
+ ```
65
+
66
+ ---
67
+
68
+ ## Completion Rule — NON-NEGOTIABLE
69
+
70
+ Print the updated goals.md content.
71
+ Print the friction log content.
72
+ Show both files as proof.
73
+ Do not say "session saved" without showing the actual file content.
@@ -0,0 +1,87 @@
1
+ ---
2
+ name: pulse
3
+ description: Quick project overview — health check, recent changes, current level, next steps from goals.md.
4
+ allowed-tools: Read, Bash, Grep
5
+ ---
6
+
7
+ # /pulse — Project Overview
8
+
9
+ Recent git activity:
10
+ !`git log --oneline -5 2>/dev/null || echo 'no git history'`
11
+
12
+ Uncommitted changes:
13
+ !`git status --short 2>/dev/null || echo 'not a git repo'`
14
+
15
+ Keep it short and visual. No walls of text.
16
+
17
+ ---
18
+
19
+ ## 1. Project Health
20
+
21
+ **IDE diagnostics** — use `mcp__ide__getDiagnostics` if available.
22
+ If available, report count and severity:
23
+ ```
24
+ ✓ IDE: 0 errors, 0 warnings or ✗ IDE: 3 errors, 7 warnings — run /fix
25
+ ```
26
+ If unavailable: skip this line.
27
+
28
+ Then detect the start command and try running it:
29
+ - `package.json` → check `scripts.start` or `scripts.dev`
30
+ - `pyproject.toml` / `Makefile` → detect equivalent
31
+ - Check for missing dependencies, missing env vars, broken config
32
+
33
+ Report:
34
+ ```
35
+ ✓ App starts cleanly or ✗ App fails: {error in one line}
36
+ ✓ Dependencies installed or ✗ Missing: {what}
37
+ ✓ Config complete or ✗ Missing: {what}
38
+ ```
39
+
40
+ ---
41
+
42
+ ## 2. What Changed
43
+ ```bash
44
+ git status --short
45
+ git diff --stat HEAD~1 2>/dev/null || git diff --stat
46
+ ```
47
+
48
+ Show files changed — not the full diff.
49
+
50
+ ---
51
+
52
+ ## 3. Current Level
53
+ Check environment level (same detection as /level-up Step 1).
54
+ One line: "Environment: Level N / 7"
55
+
56
+ ---
57
+
58
+ ## 4. Intelligence Health
59
+
60
+ Quick check on the learning and boundary systems:
61
+
62
+ ```bash
63
+ # Copilot status
64
+ [ -f .claude/plan.md ] && echo "Copilot: plan.md exists" && grep -c "Status:" .claude/plan.md 2>/dev/null | xargs -I{} echo " {} milestones" || echo "Copilot: no plan"
65
+
66
+ # Reflex health
67
+ OBS=".claude/memory/reflexes/observations.jsonl"
68
+ [ -f "$OBS" ] && echo "Reflexes: $(wc -l < "$OBS" | tr -d ' ') observations" || echo "Reflexes: no observations"
69
+ ls .claude/memory/reflexes/project/*.md 2>/dev/null | wc -l | xargs -I{} echo " {} project reflexes"
70
+
71
+ # Boundary health
72
+ [ -f .claude/memory/metrics/boundaries.json ] && echo "Boundaries: $(cat .claude/memory/metrics/boundaries.json 2>/dev/null | grep -o '"warn":[0-9]*' | head -1)" || echo "Boundaries: not scanned"
73
+
74
+ # Blocker count
75
+ [ -f .claude/memory/blockers.md ] && echo "Blockers: $(grep -c "^###" .claude/memory/blockers.md 2>/dev/null || echo 0)" || echo "Blockers: none"
76
+
77
+ # Evolution history
78
+ [ -f ops/evolution-log.md ] && echo "Evolve: $(tail -1 ops/evolution-log.md 2>/dev/null | cut -d'|' -f2 | tr -d ' ')" || echo "Evolve: never run"
79
+ ```
80
+
81
+ ---
82
+
83
+ ## 5. Next Steps
84
+ Based on what you see — suggest 2-3 things to work on next.
85
+ Be specific. Not "improve the code" — "fix the failing test in auth.test.js:47".
86
+
87
+ Read `.claude/memory/goals.md` if it exists — surface the current thread and next action.
@@ -0,0 +1,97 @@
1
+ ---
2
+ name: refactor
3
+ description: >
4
+ Restructure code without changing behavior. Rename, extract, move, simplify.
5
+ Runs tests before AND after to prove nothing broke. Never changes behavior.
6
+ Triggers on: "refactor", "rename", "extract", "move this", "simplify",
7
+ "clean up", "restructure", "split this file", "too long", "DRY this up".
8
+ argument-hint: "[what to refactor — file, function, or pattern]"
9
+ disable-model-invocation: true
10
+ allowed-tools: Read, Write, Edit, Bash, Glob, Grep
11
+ ---
12
+
13
+ # /refactor — Safe Code Restructuring
14
+
15
+ $ARGUMENTS
16
+
17
+ Load: shared/completion-rule.md
18
+
19
+ ---
20
+
21
+ ## Phase 1: Understand Current State
22
+
23
+ If $ARGUMENTS is blank, use **AskUserQuestion**:
24
+ - What specifically needs refactoring?
25
+ - What's the goal? (readability, DRY, modularity, rename)
26
+
27
+ 1. Read the target code and all files that import/use it:
28
+ ```bash
29
+ grep -r "{target}" --include="*.ts" --include="*.py" --include="*.js" -l | head -20
30
+ ```
31
+ 2. Map all references — every file that will need updating
32
+ 3. Run the full test suite BEFORE any changes:
33
+ ```bash
34
+ {test command}; EXIT=$?
35
+ echo "BEFORE refactor — Exit: $EXIT"
36
+ ```
37
+ 4. Record the test output — this is your safety net
38
+
39
+ **If tests fail before refactoring: STOP.** Fix tests first with `/fix`. Never refactor on a red test suite.
40
+
41
+ ---
42
+
43
+ ## Phase 2: Plan the Change
44
+
45
+ Write a refactoring plan before touching any code:
46
+
47
+ ```
48
+ Target: {file:line — what's being refactored}
49
+ Type: {rename | extract function | extract file | move | simplify | inline}
50
+ Files: {list of all files that will change}
51
+ Risk: {low — rename only | medium — logic restructure | high — cross-file move}
52
+ ```
53
+
54
+ For **high risk**: use **EnterWorktree** — isolate the refactor. Merge only if tests pass.
55
+
56
+ ---
57
+
58
+ ## Phase 3: Apply
59
+
60
+ Execute the refactoring. Reference every change as `file:line — what changed`.
61
+
62
+ Rules:
63
+ - Change structure, never behavior
64
+ - Update ALL references — grep to verify none were missed:
65
+ ```bash
66
+ grep -r "{old_name}" --include="*.ts" --include="*.py" --include="*.js" | head -10
67
+ ```
68
+ - If any references remain: fix them before proceeding
69
+ - Update imports, exports, type references, tests, docs
70
+
71
+ ---
72
+
73
+ ## Phase 4: Verify
74
+
75
+ Run the full test suite AFTER changes:
76
+ ```bash
77
+ {test command}; EXIT=$?
78
+ echo "AFTER refactor — Exit: $EXIT"
79
+ if [ $EXIT -ne 0 ]; then echo "REFACTOR BROKE SOMETHING — revert or fix"; fi
80
+ ```
81
+
82
+ Compare before/after:
83
+ - Same number of tests passing
84
+ - No new failures
85
+ - No new warnings
86
+
87
+ ---
88
+
89
+ ## Completion Rule
90
+
91
+ Show:
92
+ 1. Before test output (passing)
93
+ 2. List of changes: `file:line — what changed`
94
+ 3. After test output (passing)
95
+ 4. Grep proof that no stale references remain
96
+
97
+ Do not say "refactoring complete" without showing both test runs.
@@ -0,0 +1,107 @@
1
+ # /reflect — Self-Improving CLAUDE.md
2
+
3
+ **Purpose**: Analyze conversation patterns and friction to propose improvements to CLAUDE.md rules.
4
+ Unlike /evolve (which improves the environment structure), /reflect improves Claude's *behavior* by
5
+ updating the instructions that guide it.
6
+
7
+ ---
8
+
9
+ ## Step 1: Gather Evidence
10
+
11
+ Read these files to find friction patterns:
12
+
13
+ 1. **Friction logs** — `ops/observations/*-friction.md` (last 5 files)
14
+ 2. **goals.md** — look for repeated blockers or stalled threads
15
+ 3. **Session logs** — `.claude/memory/sessions/` (last 3 sessions)
16
+ 4. **Current CLAUDE.md** — the rules file being evaluated
17
+
18
+ If friction logs are empty or don't exist, analyze the current conversation transcript instead:
19
+ - Where did you hesitate, backtrack, or give a wrong answer?
20
+ - Where did the user correct you?
21
+ - Where did you over-engineer or under-deliver?
22
+
23
+ ---
24
+
25
+ ## Step 2: Identify Patterns
26
+
27
+ Look for these categories:
28
+
29
+ | Category | Signal | Example |
30
+ |----------|--------|---------|
31
+ | **Missing rule** | Same mistake repeated across sessions | Always forgetting to run tests |
32
+ | **Vague rule** | Rule exists but doesn't prevent the mistake | "Write good tests" doesn't say which framework |
33
+ | **Contradicting rules** | Two rules conflict | "Be concise" vs "Explain thoroughly" |
34
+ | **Dead rule** | Rule refers to something that no longer exists | References a deleted file or old convention |
35
+ | **Missing routing** | Task type has no dispatch entry | User asks for something not in Quick dispatch |
36
+
37
+ ---
38
+
39
+ ## Step 3: Propose Changes
40
+
41
+ For each finding, propose a specific CLAUDE.md edit:
42
+
43
+ ```
44
+ Finding: [what's wrong]
45
+ Evidence: [which friction log / conversation turn showed this]
46
+ Proposed change:
47
+
48
+ ## Rules
49
+ + 5. **Tests** — Run `npm test` before every commit. Never skip.
50
+
51
+ OR
52
+
53
+ Quick dispatch:
54
+ + - /reflect → commands/reflect.md (self-improving CLAUDE.md)
55
+ ```
56
+
57
+ **Rules for proposals:**
58
+ - One finding = one change. Don't bundle.
59
+ - Show the exact text to add/remove/modify.
60
+ - Never remove a rule the user explicitly added.
61
+ - Never add a rule that contradicts an existing one without flagging the conflict.
62
+
63
+ ---
64
+
65
+ ## Step 4: Review with User
66
+
67
+ Present all findings as a numbered list. Wait for approval.
68
+
69
+ ```
70
+ Reflection found 3 improvements:
71
+
72
+ 1. MISSING RULE — No test framework specified
73
+ Evidence: 3 sessions used Jest, 1 used Vitest by mistake
74
+ Proposed: Add "5. **Tests** — Use Jest. Run `npm test` before commits."
75
+
76
+ 2. DEAD RULE — Rule 4 references `shared-skills/` which was removed
77
+ Proposed: Remove rule 4.
78
+
79
+ 3. MISSING ROUTING — /reflect not in Quick dispatch
80
+ Proposed: Add routing entry.
81
+
82
+ Apply which? (all / 1,2 / none)
83
+ ```
84
+
85
+ ---
86
+
87
+ ## Step 5: Apply
88
+
89
+ For each approved change:
90
+ 1. Edit CLAUDE.md with the exact proposed text
91
+ 2. If a routing entry was added, verify the command file exists
92
+ 3. Run tests if the project has them
93
+
94
+ ---
95
+
96
+ ## Step 6: Log
97
+
98
+ Append to `ops/observations/{date}-reflect.md`:
99
+
100
+ ```markdown
101
+ # Reflection — {date}
102
+ Applied {N} of {M} proposed changes.
103
+
104
+ ## Changes
105
+ - [applied] {finding 1 summary}
106
+ - [skipped] {finding 2 summary} — reason: {user said no / conflict}
107
+ ```
@@ -0,0 +1,141 @@
1
+ ---
2
+ name: reflexes
3
+ description: >
4
+ View, analyze, and manage learned reflexes. Shows what patterns the system has
5
+ detected from session observations with confidence scoring.
6
+ Triggers on: "reflexes", "what have you learned", "show learned patterns",
7
+ "reflex status", "analyze observations", "promote reflex".
8
+ argument-hint: "[status | analyze | promote | clear]"
9
+ disable-model-invocation: true
10
+ allowed-tools: Read, Write, Edit, Bash, Glob, Grep
11
+ ---
12
+
13
+ # /reflexes — Learned Behavioral Patterns
14
+
15
+ $ARGUMENTS
16
+
17
+ Load: capabilities/shared/reflexes.md
18
+
19
+ ---
20
+
21
+ ## Subcommand: status (default)
22
+
23
+ Show all learned reflexes with confidence scores + observation health.
24
+
25
+ ```bash
26
+ # Observation health
27
+ OBS_FILE=".claude/memory/reflexes/observations.jsonl"
28
+ if [ -f "$OBS_FILE" ]; then
29
+ OBS_COUNT=$(wc -l < "$OBS_FILE" 2>/dev/null | tr -d ' ')
30
+ LATEST=$(tail -1 "$OBS_FILE" 2>/dev/null | grep -o '"ts":"[^"]*"' | head -1)
31
+ echo "Observations: $OBS_COUNT total, latest: $LATEST"
32
+ # Check capture recency (warn if > 24h since last observation)
33
+ echo "Health: $([ "$OBS_COUNT" -gt 10 ] && echo 'good' || echo 'low — hooks may not be capturing')"
34
+ else
35
+ echo "Observations: none — hooks not capturing yet"
36
+ fi
37
+
38
+ # Count project reflexes
39
+ ls .claude/memory/reflexes/project/*.md 2>/dev/null || echo "No project reflexes yet"
40
+
41
+ # Count global reflexes
42
+ ls .claude/memory/reflexes/global/*.md 2>/dev/null || echo "No global reflexes yet"
43
+ ```
44
+
45
+ For each reflex file, read and display:
46
+ ```
47
+ | ID | Trigger | Confidence | Domain | Scope | Evidence |
48
+ |----|---------|-----------|--------|-------|----------|
49
+ ```
50
+
51
+ Sort by confidence (highest first).
52
+
53
+ ---
54
+
55
+ ## Subcommand: analyze
56
+
57
+ Analyze observations.jsonl to detect new patterns and create/update reflexes.
58
+
59
+ 1. Read `.claude/memory/reflexes/observations.jsonl` (last 500 lines)
60
+ 2. Detect patterns with 3+ occurrences:
61
+ - **Tool sequences**: same chain of tools used repeatedly
62
+ - **File co-access**: files always accessed together
63
+ - **Error → fix pairs**: same error resolved the same way
64
+ - **Naming patterns**: consistent naming in created files
65
+ 3. For each detected pattern:
66
+ - Check if reflex already exists → update confidence (+0.05 per new observation)
67
+ - If new → create reflex file with initial confidence based on count
68
+ 4. Write reflex files to `.claude/memory/reflexes/project/`
69
+
70
+ ### Reflex File Format
71
+
72
+ ```markdown
73
+ ---
74
+ id: {kebab-case-name}
75
+ trigger: "{when condition}"
76
+ action: "{what to do}"
77
+ confidence: {0.3-0.95}
78
+ domain: {code-style|testing|git|debugging|workflow|file-patterns|security}
79
+ scope: {project|global}
80
+ evidence_count: {N}
81
+ last_observed: {YYYY-MM-DD}
82
+ ---
83
+
84
+ # {Title}
85
+
86
+ ## Evidence
87
+ - Observed {N} times across {M} sessions
88
+ - Pattern: {description}
89
+ - Last observed: {date}
90
+ ```
91
+
92
+ ---
93
+
94
+ ## Subcommand: promote
95
+
96
+ Promote a project reflex to global scope.
97
+
98
+ ```bash
99
+ # If specific ID given
100
+ # Move .claude/memory/reflexes/project/{id}.md → .claude/memory/reflexes/global/{id}.md
101
+ # Update scope field in frontmatter to "global"
102
+
103
+ # If no ID given — auto-promote all qualifying
104
+ # Criteria: confidence >= 0.8 AND domain in (security, workflow, git)
105
+ ```
106
+
107
+ Show what was promoted and why.
108
+
109
+ ---
110
+
111
+ ## Subcommand: clear
112
+
113
+ Clear stale observations (older than 30 days) and low-confidence reflexes (< 0.3).
114
+
115
+ ```bash
116
+ # Archive old observations
117
+ mv .claude/memory/reflexes/observations.jsonl .claude/memory/reflexes/observations-$(date +%Y%m%d).archive.jsonl
118
+
119
+ # Remove reflexes with confidence < 0.3
120
+ # List what would be removed, then confirm
121
+ ```
122
+
123
+ ---
124
+
125
+ ## Copilot Mode
126
+
127
+ When running inside `/copilot`:
128
+ - Skip user confirmation for promote and clear
129
+ - Auto-run `analyze` every 3 milestones (alongside /evolve)
130
+ - Feed strong reflexes (confidence >= 0.7) into /add behavior
131
+
132
+ ---
133
+
134
+ ## Completion Rule
135
+
136
+ Show:
137
+ 1. Reflex table (ID, trigger, confidence, domain, scope)
138
+ 2. Observation count
139
+ 3. Any new reflexes created or updated
140
+
141
+ Do not say "reflexes analyzed" without showing the table.