@arthai/agents 1.0.5 → 1.0.7
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/README.md +33 -3
- package/VERSION +1 -1
- package/agents/troubleshooter.md +132 -0
- package/bin/cli.js +296 -0
- package/bundles/canvas.json +1 -1
- package/bundles/compass.json +1 -1
- package/bundles/counsel.json +1 -0
- package/bundles/cruise.json +1 -1
- package/bundles/forge.json +12 -1
- package/bundles/prism.json +1 -0
- package/bundles/scalpel.json +5 -2
- package/bundles/sentinel.json +8 -2
- package/bundles/shield.json +1 -0
- package/bundles/spark.json +1 -0
- package/compiler.sh +14 -0
- package/dist/plugins/canvas/.claude-plugin/plugin.json +1 -1
- package/dist/plugins/canvas/VERSION +1 -0
- package/dist/plugins/canvas/commands/planning.md +100 -11
- package/dist/plugins/canvas/hooks/hooks.json +16 -0
- package/dist/plugins/canvas/hooks/project-setup.sh +109 -0
- package/dist/plugins/canvas/templates/CLAUDE.md.managed-block +123 -0
- package/dist/plugins/canvas/templates/CLAUDE.md.template +111 -0
- package/dist/plugins/compass/.claude-plugin/plugin.json +1 -1
- package/dist/plugins/compass/VERSION +1 -0
- package/dist/plugins/compass/commands/planning.md +100 -11
- package/dist/plugins/compass/hooks/hooks.json +16 -0
- package/dist/plugins/compass/hooks/project-setup.sh +109 -0
- package/dist/plugins/compass/templates/CLAUDE.md.managed-block +123 -0
- package/dist/plugins/compass/templates/CLAUDE.md.template +111 -0
- package/dist/plugins/counsel/.claude-plugin/plugin.json +1 -1
- package/dist/plugins/counsel/VERSION +1 -0
- package/dist/plugins/counsel/hooks/hooks.json +10 -0
- package/dist/plugins/counsel/hooks/project-setup.sh +109 -0
- package/dist/plugins/counsel/templates/CLAUDE.md.managed-block +123 -0
- package/dist/plugins/counsel/templates/CLAUDE.md.template +111 -0
- package/dist/plugins/cruise/.claude-plugin/plugin.json +1 -1
- package/dist/plugins/cruise/VERSION +1 -0
- package/dist/plugins/cruise/hooks/hooks.json +16 -0
- package/dist/plugins/cruise/hooks/project-setup.sh +109 -0
- package/dist/plugins/cruise/templates/CLAUDE.md.managed-block +123 -0
- package/dist/plugins/cruise/templates/CLAUDE.md.template +111 -0
- package/dist/plugins/forge/.claude-plugin/plugin.json +1 -1
- package/dist/plugins/forge/VERSION +1 -0
- package/dist/plugins/forge/agents/troubleshooter.md +132 -0
- package/dist/plugins/forge/commands/implement.md +99 -1
- package/dist/plugins/forge/commands/planning.md +100 -11
- package/dist/plugins/forge/hooks/escalation-guard.sh +177 -0
- package/dist/plugins/forge/hooks/hooks.json +22 -0
- package/dist/plugins/forge/hooks/project-setup.sh +109 -0
- package/dist/plugins/forge/templates/CLAUDE.md.managed-block +123 -0
- package/dist/plugins/forge/templates/CLAUDE.md.template +111 -0
- package/dist/plugins/prime/.claude-plugin/plugin.json +1 -1
- package/dist/plugins/prime/VERSION +1 -0
- package/dist/plugins/prime/agents/troubleshooter.md +132 -0
- package/dist/plugins/prime/commands/calibrate.md +20 -0
- package/dist/plugins/prime/commands/ci-fix.md +36 -0
- package/dist/plugins/prime/commands/fix.md +23 -0
- package/dist/plugins/prime/commands/implement.md +99 -1
- package/dist/plugins/prime/commands/planning.md +100 -11
- package/dist/plugins/prime/commands/qa-incident.md +54 -0
- package/dist/plugins/prime/commands/restart.md +186 -30
- package/dist/plugins/prime/hooks/escalation-guard.sh +177 -0
- package/dist/plugins/prime/hooks/hooks.json +60 -0
- package/dist/plugins/prime/hooks/post-config-change-restart-reminder.sh +86 -0
- package/dist/plugins/prime/hooks/post-server-crash-watch.sh +120 -0
- package/dist/plugins/prime/hooks/pre-server-port-guard.sh +110 -0
- package/dist/plugins/prime/hooks/project-setup.sh +109 -0
- package/dist/plugins/prime/hooks/sync-agents.sh +99 -12
- package/dist/plugins/prime/templates/CLAUDE.md.managed-block +123 -0
- package/dist/plugins/prime/templates/CLAUDE.md.template +111 -0
- package/dist/plugins/prism/.claude-plugin/plugin.json +1 -1
- package/dist/plugins/prism/VERSION +1 -0
- package/dist/plugins/prism/commands/qa-incident.md +54 -0
- package/dist/plugins/prism/hooks/hooks.json +12 -0
- package/dist/plugins/prism/hooks/project-setup.sh +109 -0
- package/dist/plugins/prism/templates/CLAUDE.md.managed-block +123 -0
- package/dist/plugins/prism/templates/CLAUDE.md.template +111 -0
- package/dist/plugins/scalpel/.claude-plugin/plugin.json +1 -1
- package/dist/plugins/scalpel/VERSION +1 -0
- package/dist/plugins/scalpel/agents/troubleshooter.md +132 -0
- package/dist/plugins/scalpel/commands/ci-fix.md +36 -0
- package/dist/plugins/scalpel/commands/fix.md +23 -0
- package/dist/plugins/scalpel/hooks/escalation-guard.sh +177 -0
- package/dist/plugins/scalpel/hooks/hooks.json +24 -0
- package/dist/plugins/scalpel/hooks/project-setup.sh +109 -0
- package/dist/plugins/scalpel/templates/CLAUDE.md.managed-block +123 -0
- package/dist/plugins/scalpel/templates/CLAUDE.md.template +111 -0
- package/dist/plugins/sentinel/.claude-plugin/plugin.json +1 -1
- package/dist/plugins/sentinel/VERSION +1 -0
- package/dist/plugins/sentinel/agents/troubleshooter.md +132 -0
- package/dist/plugins/sentinel/commands/restart.md +186 -30
- package/dist/plugins/sentinel/hooks/escalation-guard.sh +177 -0
- package/dist/plugins/sentinel/hooks/hooks.json +64 -0
- package/dist/plugins/sentinel/hooks/post-config-change-restart-reminder.sh +86 -0
- package/dist/plugins/sentinel/hooks/post-server-crash-watch.sh +120 -0
- package/dist/plugins/sentinel/hooks/pre-server-port-guard.sh +110 -0
- package/dist/plugins/sentinel/hooks/project-setup.sh +109 -0
- package/dist/plugins/sentinel/templates/CLAUDE.md.managed-block +123 -0
- package/dist/plugins/sentinel/templates/CLAUDE.md.template +111 -0
- package/dist/plugins/shield/.claude-plugin/plugin.json +1 -1
- package/dist/plugins/shield/VERSION +1 -0
- package/dist/plugins/shield/hooks/hooks.json +22 -12
- package/dist/plugins/shield/hooks/project-setup.sh +109 -0
- package/dist/plugins/shield/templates/CLAUDE.md.managed-block +123 -0
- package/dist/plugins/shield/templates/CLAUDE.md.template +111 -0
- package/dist/plugins/spark/.claude-plugin/plugin.json +1 -1
- package/dist/plugins/spark/VERSION +1 -0
- package/dist/plugins/spark/commands/calibrate.md +20 -0
- package/dist/plugins/spark/hooks/hooks.json +10 -0
- package/dist/plugins/spark/hooks/project-setup.sh +109 -0
- package/dist/plugins/spark/templates/CLAUDE.md.managed-block +123 -0
- package/dist/plugins/spark/templates/CLAUDE.md.template +111 -0
- package/hook-defs.json +31 -0
- package/hooks/escalation-guard.sh +177 -0
- package/hooks/post-config-change-restart-reminder.sh +86 -0
- package/hooks/post-server-crash-watch.sh +120 -0
- package/hooks/pre-server-port-guard.sh +110 -0
- package/hooks/project-setup.sh +109 -0
- package/hooks/sync-agents.sh +99 -12
- package/install.sh +2 -2
- package/package.json +1 -1
- package/portable.manifest +7 -1
- package/skills/calibrate/SKILL.md +20 -0
- package/skills/ci-fix/SKILL.md +36 -0
- package/skills/fix/SKILL.md +23 -0
- package/skills/implement/SKILL.md +99 -1
- package/skills/license/SKILL.md +159 -0
- package/skills/planning/SKILL.md +100 -11
- package/skills/qa-incident/SKILL.md +54 -0
- package/skills/restart/SKILL.md +187 -31
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: troubleshooter
|
|
3
|
+
description: "Specialized debugging agent for when other agents get stuck. Performs root cause analysis using error context, knowledge base, git history, and CLAUDE.md. Produces structured diagnosis with confidence level and recommended fix."
|
|
4
|
+
model: sonnet
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Troubleshooter Agent
|
|
8
|
+
|
|
9
|
+
You are a specialized debugging agent. You are called when another agent or workflow
|
|
10
|
+
has failed multiple times and needs expert diagnosis.
|
|
11
|
+
|
|
12
|
+
## When You Are Spawned
|
|
13
|
+
|
|
14
|
+
Another agent has hit a wall — they've tried 2-3 fixes and keep failing. Your job
|
|
15
|
+
is to diagnose the root cause and provide a fix with confidence rating.
|
|
16
|
+
|
|
17
|
+
## Your Process (follow in order)
|
|
18
|
+
|
|
19
|
+
### 1. Understand the Problem (DO NOT SKIP)
|
|
20
|
+
|
|
21
|
+
Read the error context provided in your spawn prompt. Extract:
|
|
22
|
+
- **Exact error message** (not paraphrased)
|
|
23
|
+
- **What was being attempted** (the goal, not just the command)
|
|
24
|
+
- **What has already been tried** (and why each attempt failed)
|
|
25
|
+
- **The file(s) involved**
|
|
26
|
+
|
|
27
|
+
### 2. Consult Knowledge Base (BEFORE forming any hypothesis)
|
|
28
|
+
|
|
29
|
+
Check these sources in order:
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
.claude/knowledge/qa-knowledge/ → past incidents with error signatures
|
|
33
|
+
.claude/knowledge/shared/conventions.md → project-specific gotchas and rules
|
|
34
|
+
.claude/knowledge/shared/patterns.md → architecture patterns that may explain the error
|
|
35
|
+
.claude/knowledge/agents/ → per-agent learning files
|
|
36
|
+
CLAUDE.md → project configuration, test commands, services
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Search for:
|
|
40
|
+
- The exact error message (or key phrases)
|
|
41
|
+
- The file/module involved
|
|
42
|
+
- The command that failed
|
|
43
|
+
- Similar past incidents
|
|
44
|
+
|
|
45
|
+
**If you find a match:** Follow the documented fix. Do not reinvent.
|
|
46
|
+
**If no match:** Proceed to step 3.
|
|
47
|
+
|
|
48
|
+
### 3. Gather Fresh Evidence
|
|
49
|
+
|
|
50
|
+
Read the actual source code around the error:
|
|
51
|
+
- The file mentioned in the error (read 50+ lines of context, not just the error line)
|
|
52
|
+
- Related files (imports, callers, configuration)
|
|
53
|
+
- Recent changes: `git log --oneline -10 -- <file>` and `git diff HEAD -- <file>`
|
|
54
|
+
|
|
55
|
+
Check the environment:
|
|
56
|
+
- `git status` — are there uncommitted changes that might cause the issue?
|
|
57
|
+
- Check if the right dependencies are installed (node_modules, venv, etc.)
|
|
58
|
+
- Check if services are running (ports, Docker containers)
|
|
59
|
+
- Check environment variables that the code expects
|
|
60
|
+
|
|
61
|
+
### 4. Form Hypothesis (evidence-based only)
|
|
62
|
+
|
|
63
|
+
Based on steps 2-3, form ONE primary hypothesis and optionally one alternative.
|
|
64
|
+
Each hypothesis MUST cite evidence:
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
HYPOTHESIS: [what I think is wrong]
|
|
68
|
+
EVIDENCE:
|
|
69
|
+
- [source]: [what I found that supports this]
|
|
70
|
+
- [source]: [what I found that supports this]
|
|
71
|
+
CONFIDENCE: HIGH / MEDIUM / LOW
|
|
72
|
+
- HIGH: evidence directly explains the error, fix is clear
|
|
73
|
+
- MEDIUM: evidence is consistent but not conclusive
|
|
74
|
+
- LOW: best guess based on limited evidence
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### 5. Recommend Fix
|
|
78
|
+
|
|
79
|
+
Provide a specific, actionable fix:
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
RECOMMENDED FIX:
|
|
83
|
+
File: [exact file path]
|
|
84
|
+
Change: [what to modify — be specific, not vague]
|
|
85
|
+
Why: [how this addresses the root cause]
|
|
86
|
+
Verify: [command to run to confirm the fix works]
|
|
87
|
+
|
|
88
|
+
ALTERNATIVE FIX (if confidence < HIGH):
|
|
89
|
+
File: [exact file path]
|
|
90
|
+
Change: [what to modify]
|
|
91
|
+
Why: [different hypothesis this addresses]
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### 6. Output Format
|
|
95
|
+
|
|
96
|
+
Always produce this structured output:
|
|
97
|
+
|
|
98
|
+
```markdown
|
|
99
|
+
## Troubleshooter Diagnosis
|
|
100
|
+
|
|
101
|
+
**Error:** [exact error]
|
|
102
|
+
**Root Cause:** [1-2 sentence explanation]
|
|
103
|
+
**Confidence:** HIGH / MEDIUM / LOW
|
|
104
|
+
|
|
105
|
+
### Evidence
|
|
106
|
+
- [source 1]: [finding]
|
|
107
|
+
- [source 2]: [finding]
|
|
108
|
+
- Knowledge base: [match found / no match]
|
|
109
|
+
|
|
110
|
+
### Recommended Fix
|
|
111
|
+
- File: [path]
|
|
112
|
+
- Change: [specific change]
|
|
113
|
+
- Verify: [command]
|
|
114
|
+
|
|
115
|
+
### What Was Wrong With Previous Attempts
|
|
116
|
+
- Attempt 1: [why it didn't work — specific reason]
|
|
117
|
+
- Attempt 2: [why it didn't work — specific reason]
|
|
118
|
+
|
|
119
|
+
### If This Doesn't Work
|
|
120
|
+
- [Next diagnostic step to try]
|
|
121
|
+
- [What data to gather]
|
|
122
|
+
- [Whether to escalate to user — and what to ask them]
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Rules
|
|
126
|
+
|
|
127
|
+
1. **Never guess.** Every claim must cite evidence from code, logs, KB, or git history.
|
|
128
|
+
2. **Check KB first.** If a past incident matches, use that fix. Don't reinvent.
|
|
129
|
+
3. **Be specific.** "Check the config" is not a fix. "Change line 42 of config.ts from X to Y" is.
|
|
130
|
+
4. **Explain why previous attempts failed.** This is as valuable as the fix itself.
|
|
131
|
+
5. **Know when to escalate.** If confidence is LOW and you can't gather more evidence, say so. Recommend what data to ask the user for.
|
|
132
|
+
6. **Don't try the fix yourself.** Your job is diagnosis. The calling agent implements the fix.
|
|
@@ -160,6 +160,42 @@ gh run view <FAILED_RUN_ID> --log-failed 2>&1 | tail -200
|
|
|
160
160
|
| **Build failures** | build errors | Read error, fix import/export/config |
|
|
161
161
|
| **Migration** | Alembic/Django errors | Fix migration file |
|
|
162
162
|
| **Dependency** | pip/npm install failures | Fix requirements/package.json |
|
|
163
|
+
| **Toolkit tests** | 15/20-skill-runtime-safety, manifest-coverage | See Toolkit Test Fixes below |
|
|
164
|
+
|
|
165
|
+
#### Toolkit-Specific Test Fixes (claude-agents repo)
|
|
166
|
+
|
|
167
|
+
When CI fails on the mechanical test suite (`tests/run.sh`), these are the common failures and auto-fixes:
|
|
168
|
+
|
|
169
|
+
| Test | Failure message | Root cause | Auto-fix |
|
|
170
|
+
|------|----------------|-----------|----------|
|
|
171
|
+
| `20-skill-runtime-safety` | "regex-unsafe [brackets] in descriptions" | SKILL.md `description:` or `arguments:` field contains `[text]` | Replace `[text]` with `<text>` in the frontmatter field. Brackets break regex matching in Claude Code. |
|
|
172
|
+
| `20-skill-runtime-safety` | "Skills missing required frontmatter fields" | SKILL.md missing `user-invocable: true` or `arguments:` | Add missing field to the YAML frontmatter between `---` markers. Check `git show HEAD~1:path/to/SKILL.md` for the original. |
|
|
173
|
+
| `15-manifest-coverage` | "entries mapped to categories" | New file in `portable.manifest` not listed in any `get_category_items()` category in `install.sh` | Add the manifest entry to the appropriate category in `install.sh:get_category_items()`. |
|
|
174
|
+
| `15-manifest-coverage` | "Install creates all expected symlinks" | New file in `portable.manifest` but install didn't create the symlink | Usually follows from the category mapping fix above. |
|
|
175
|
+
| `15-manifest-coverage` | "Entry counts are consistent" | Mismatch between manifest entries and installed files | Check that new manifest entries have matching source files. |
|
|
176
|
+
| `19-brownfield-assessment` | "classify_file returns IDENTICAL" | Agent fixture is stale after editing an agent `.md` file | Update fixture: `cp agents/{name}.md tests/fixtures/claude-setups/poweruser/.claude/agents/` |
|
|
177
|
+
|
|
178
|
+
**Auto-fix sequence for toolkit tests:**
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
# 1. Get the exact failure
|
|
182
|
+
gh run view <ID> --log-failed 2>&1 | grep -E "FAIL|✗" | head -5
|
|
183
|
+
|
|
184
|
+
# 2. For bracket issues — find and fix ALL bracket descriptions
|
|
185
|
+
grep -rn 'description:.*\[' skills/*/SKILL.md
|
|
186
|
+
# Replace [text] with <text> in each match
|
|
187
|
+
|
|
188
|
+
# 3. For missing frontmatter — compare against last known good
|
|
189
|
+
git show HEAD~1:path/to/SKILL.md | head -6
|
|
190
|
+
# Restore missing fields
|
|
191
|
+
|
|
192
|
+
# 4. For manifest coverage — add to install.sh categories
|
|
193
|
+
grep "get_category_items" install.sh
|
|
194
|
+
# Add new entries to the right category
|
|
195
|
+
|
|
196
|
+
# 5. Verify locally before pushing
|
|
197
|
+
bash tests/run.sh --suite 15,20 --scenario a
|
|
198
|
+
```
|
|
163
199
|
|
|
164
200
|
**Attempt escalation:**
|
|
165
201
|
- Attempt 1: Apply the obvious fix (auto-fix tools, direct code fix)
|
|
@@ -476,6 +476,29 @@ Select the right agent based on which layer the bug is in:
|
|
|
476
476
|
If `.claude/project-profile.md` exists, read it to determine the platform and pick the right agent.
|
|
477
477
|
If `/calibrate` generated custom agents (e.g., `ios-developer.md`), use those for platform-specific bugs.
|
|
478
478
|
|
|
479
|
+
**4.2b: Escalation protocol for fix agents**
|
|
480
|
+
|
|
481
|
+
Include this in the implementation agent's prompt:
|
|
482
|
+
|
|
483
|
+
```
|
|
484
|
+
## When Your Fix Doesn't Work (MANDATORY)
|
|
485
|
+
|
|
486
|
+
1. After first failed attempt: re-read the root cause analysis from Step 1.
|
|
487
|
+
Is the root cause correct? If not, go back to Step 1.
|
|
488
|
+
2. After second failed attempt: consult knowledge base:
|
|
489
|
+
- .claude/knowledge/qa-knowledge/ (error keywords)
|
|
490
|
+
- .claude/knowledge/shared/conventions.md (project gotchas)
|
|
491
|
+
- git log --all --grep="<error keyword>" --oneline -10
|
|
492
|
+
3. After third failed attempt: STOP. Do not try another fix.
|
|
493
|
+
Generate a STUCK REPORT and send to team-lead:
|
|
494
|
+
- Error: [exact message]
|
|
495
|
+
- Root cause hypothesis: [from Step 1]
|
|
496
|
+
- Fix attempts: [1, 2, 3 with results]
|
|
497
|
+
- KB consultation results: [what you found]
|
|
498
|
+
- Recommendation: [re-investigate root cause / ask user for X / try different approach]
|
|
499
|
+
4. If a troubleshooter agent is available, team-lead may spawn one.
|
|
500
|
+
```
|
|
501
|
+
|
|
479
502
|
**Agent prompt includes:**
|
|
480
503
|
```
|
|
481
504
|
1. Root cause analysis from Step 1
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# PostToolUse hook (Bash): Circuit breaker for consecutive failures.
|
|
3
|
+
# Tracks failed commands by error signature. After 3 failures with the same
|
|
4
|
+
# signature, forces KB consultation and outputs a structured stuck report.
|
|
5
|
+
#
|
|
6
|
+
# Uses .claude/.escalation-state.json to persist state across tool calls.
|
|
7
|
+
# stdout is injected as context.
|
|
8
|
+
|
|
9
|
+
set -euo pipefail
|
|
10
|
+
|
|
11
|
+
PROJECT_DIR="${CLAUDE_PROJECT_DIR:-$(pwd)}"
|
|
12
|
+
STATE_FILE="$PROJECT_DIR/.claude/.escalation-state.json"
|
|
13
|
+
CIRCUIT_BREAKER_THRESHOLD=3
|
|
14
|
+
|
|
15
|
+
# Extract the command and exit code
|
|
16
|
+
COMMAND="${CLAUDE_TOOL_INPUT_COMMAND:-}"
|
|
17
|
+
if [ -z "$COMMAND" ] && [ -n "${CLAUDE_TOOL_INPUT:-}" ]; then
|
|
18
|
+
COMMAND=$(echo "$CLAUDE_TOOL_INPUT" | python3 -c "import json,sys; print(json.load(sys.stdin).get('command',''))" 2>/dev/null) || true
|
|
19
|
+
fi
|
|
20
|
+
|
|
21
|
+
EXIT_CODE="${CLAUDE_TOOL_RESULT_EXIT_CODE:-0}"
|
|
22
|
+
|
|
23
|
+
[ -z "$COMMAND" ] && exit 0
|
|
24
|
+
|
|
25
|
+
# ---------------------------------------------------------------------------
|
|
26
|
+
# Skip tracking for non-failing commands and read-only commands
|
|
27
|
+
# ---------------------------------------------------------------------------
|
|
28
|
+
|
|
29
|
+
# Success — reset state if we had failures for this signature
|
|
30
|
+
if [ "$EXIT_CODE" = "0" ]; then
|
|
31
|
+
if [ -f "$STATE_FILE" ]; then
|
|
32
|
+
# Clear state on success — the issue is resolved
|
|
33
|
+
python3 -c "
|
|
34
|
+
import json, sys
|
|
35
|
+
try:
|
|
36
|
+
with open('$STATE_FILE', 'r') as f:
|
|
37
|
+
state = json.load(f)
|
|
38
|
+
# Reset consecutive failures
|
|
39
|
+
state['consecutive_failures'] = 0
|
|
40
|
+
state['last_error_signature'] = ''
|
|
41
|
+
state['attempts'] = []
|
|
42
|
+
with open('$STATE_FILE', 'w') as f:
|
|
43
|
+
json.dump(state, f, indent=2)
|
|
44
|
+
except:
|
|
45
|
+
pass
|
|
46
|
+
" 2>/dev/null || true
|
|
47
|
+
fi
|
|
48
|
+
exit 0
|
|
49
|
+
fi
|
|
50
|
+
|
|
51
|
+
# Skip tracking for read-only commands (ls, cat, grep, git status, etc.)
|
|
52
|
+
if echo "$COMMAND" | grep -qE '^\s*(ls|cat|head|tail|grep|rg|git\s+(status|log|diff|show|branch)|echo|pwd|which|type|file|wc)\b'; then
|
|
53
|
+
exit 0
|
|
54
|
+
fi
|
|
55
|
+
|
|
56
|
+
# ---------------------------------------------------------------------------
|
|
57
|
+
# Compute error signature from command + exit code
|
|
58
|
+
# ---------------------------------------------------------------------------
|
|
59
|
+
|
|
60
|
+
# Get the last few lines of error output (from CLAUDE_TOOL_RESULT_STDERR or infer)
|
|
61
|
+
ERROR_OUTPUT="${CLAUDE_TOOL_RESULT_STDERR:-}"
|
|
62
|
+
if [ -z "$ERROR_OUTPUT" ] && [ -n "${CLAUDE_TOOL_RESULT_STDOUT:-}" ]; then
|
|
63
|
+
# Sometimes errors go to stdout (e.g., npm, python)
|
|
64
|
+
ERROR_OUTPUT=$(echo "${CLAUDE_TOOL_RESULT_STDOUT:-}" | tail -5)
|
|
65
|
+
fi
|
|
66
|
+
|
|
67
|
+
# Compute signature: hash of (command_base + error_pattern)
|
|
68
|
+
# Strip variable parts (paths, timestamps, PIDs) for stable signatures
|
|
69
|
+
COMMAND_BASE=$(echo "$COMMAND" | awk '{print $1, $2}')
|
|
70
|
+
ERROR_PATTERN=$(echo "$ERROR_OUTPUT" | sed 's/[0-9]\{4,\}//g; s|/[^ ]*||g' | head -3)
|
|
71
|
+
SIGNATURE=$(echo "${COMMAND_BASE}:${ERROR_PATTERN}" | shasum -a 256 | cut -c1-16)
|
|
72
|
+
|
|
73
|
+
# ---------------------------------------------------------------------------
|
|
74
|
+
# Update state and check circuit breaker
|
|
75
|
+
# ---------------------------------------------------------------------------
|
|
76
|
+
|
|
77
|
+
RESULT=$(python3 -c "
|
|
78
|
+
import json, sys, time, os
|
|
79
|
+
|
|
80
|
+
state_file = '$STATE_FILE'
|
|
81
|
+
signature = '$SIGNATURE'
|
|
82
|
+
command = '''$COMMAND'''[:200]
|
|
83
|
+
error = '''$ERROR_OUTPUT'''[:500]
|
|
84
|
+
threshold = $CIRCUIT_BREAKER_THRESHOLD
|
|
85
|
+
|
|
86
|
+
# Load or create state
|
|
87
|
+
state = {'consecutive_failures': 0, 'last_error_signature': '', 'attempts': [], 'total_circuits_tripped': 0}
|
|
88
|
+
try:
|
|
89
|
+
if os.path.exists(state_file):
|
|
90
|
+
with open(state_file, 'r') as f:
|
|
91
|
+
state = json.load(f)
|
|
92
|
+
except:
|
|
93
|
+
pass
|
|
94
|
+
|
|
95
|
+
# Check if same signature as last failure
|
|
96
|
+
if state.get('last_error_signature') == signature:
|
|
97
|
+
state['consecutive_failures'] = state.get('consecutive_failures', 0) + 1
|
|
98
|
+
else:
|
|
99
|
+
# New error signature — reset counter
|
|
100
|
+
state['consecutive_failures'] = 1
|
|
101
|
+
state['attempts'] = []
|
|
102
|
+
|
|
103
|
+
state['last_error_signature'] = signature
|
|
104
|
+
state['attempts'] = (state.get('attempts', []) + [{'command': command, 'error': error[:200], 'time': time.time()}])[-5:]
|
|
105
|
+
|
|
106
|
+
# Check threshold
|
|
107
|
+
tripped = state['consecutive_failures'] >= threshold
|
|
108
|
+
|
|
109
|
+
if tripped:
|
|
110
|
+
state['total_circuits_tripped'] = state.get('total_circuits_tripped', 0) + 1
|
|
111
|
+
|
|
112
|
+
# Save state
|
|
113
|
+
os.makedirs(os.path.dirname(state_file), exist_ok=True)
|
|
114
|
+
with open(state_file, 'w') as f:
|
|
115
|
+
json.dump(state, f, indent=2)
|
|
116
|
+
|
|
117
|
+
# Output: tripped|count|attempts_summary
|
|
118
|
+
attempts_summary = ' / '.join([a.get('command', '')[:60] for a in state.get('attempts', [])])
|
|
119
|
+
print(f\"{'TRIPPED' if tripped else 'OK'}|{state['consecutive_failures']}|{attempts_summary}\")
|
|
120
|
+
" 2>/dev/null) || exit 0
|
|
121
|
+
|
|
122
|
+
STATUS=$(echo "$RESULT" | cut -d'|' -f1)
|
|
123
|
+
COUNT=$(echo "$RESULT" | cut -d'|' -f2)
|
|
124
|
+
ATTEMPTS=$(echo "$RESULT" | cut -d'|' -f3-)
|
|
125
|
+
|
|
126
|
+
# ---------------------------------------------------------------------------
|
|
127
|
+
# If not tripped, show warning at count 2
|
|
128
|
+
# ---------------------------------------------------------------------------
|
|
129
|
+
|
|
130
|
+
if [ "$STATUS" = "OK" ] && [ "$COUNT" = "2" ]; then
|
|
131
|
+
echo "ESCALATION WARNING: 2 consecutive failures with same error pattern."
|
|
132
|
+
echo "One more failure triggers the circuit breaker."
|
|
133
|
+
echo "Before retrying: check .claude/knowledge/ for known solutions."
|
|
134
|
+
exit 0
|
|
135
|
+
fi
|
|
136
|
+
|
|
137
|
+
# ---------------------------------------------------------------------------
|
|
138
|
+
# Circuit breaker tripped — inject structured stuck report
|
|
139
|
+
# ---------------------------------------------------------------------------
|
|
140
|
+
|
|
141
|
+
if [ "$STATUS" = "TRIPPED" ]; then
|
|
142
|
+
echo "CIRCUIT BREAKER TRIPPED — $COUNT consecutive failures with same error signature."
|
|
143
|
+
echo ""
|
|
144
|
+
echo "STOP. Do not attempt another fix without completing these steps:"
|
|
145
|
+
echo ""
|
|
146
|
+
echo "1. CONSULT KNOWLEDGE BASE:"
|
|
147
|
+
echo " - Read .claude/knowledge/shared/conventions.md"
|
|
148
|
+
echo " - Read .claude/knowledge/qa-knowledge/ (search for error keywords)"
|
|
149
|
+
echo " - Run: git log --all --grep='fix:' --oneline -10"
|
|
150
|
+
echo ""
|
|
151
|
+
echo "2. GATHER EVIDENCE (if not already done):"
|
|
152
|
+
echo " - Read full error output (not just the last line)"
|
|
153
|
+
echo " - Check environment: env vars, ports (lsof), processes (ps), disk (df)"
|
|
154
|
+
echo " - Check dependencies: node_modules, venv, Docker containers"
|
|
155
|
+
echo ""
|
|
156
|
+
echo "3. IF STILL STUCK — use this template to ask for help:"
|
|
157
|
+
echo " ┌─────────────────────────────────────────────────────────┐"
|
|
158
|
+
echo " │ STUCK REPORT │"
|
|
159
|
+
echo " │ │"
|
|
160
|
+
echo " │ Error: [exact error message] │"
|
|
161
|
+
echo " │ Context: [what I was doing] │"
|
|
162
|
+
echo " │ Attempts: │"
|
|
163
|
+
echo " │ 1. [what I tried] -> [result] │"
|
|
164
|
+
echo " │ 2. [what I tried] -> [result] │"
|
|
165
|
+
echo " │ 3. [what I tried] -> [result] │"
|
|
166
|
+
echo " │ Evidence: [logs, state, KB search results] │"
|
|
167
|
+
echo " │ What I need: [access/data/decision] │"
|
|
168
|
+
echo " │ My recommendation: [option A because X] │"
|
|
169
|
+
echo " └─────────────────────────────────────────────────────────┘"
|
|
170
|
+
echo ""
|
|
171
|
+
echo "4. IF ON A TEAM — escalate to troubleshooter agent or ask a teammate."
|
|
172
|
+
echo " If solo — present the stuck report to the user with options."
|
|
173
|
+
echo ""
|
|
174
|
+
echo "Previous attempts: $ATTEMPTS"
|
|
175
|
+
fi
|
|
176
|
+
|
|
177
|
+
exit 0
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"hooks": {
|
|
3
|
+
"SessionStart": [
|
|
4
|
+
{
|
|
5
|
+
"matcher": "",
|
|
6
|
+
"hooks": [
|
|
7
|
+
{
|
|
8
|
+
"type": "command",
|
|
9
|
+
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/project-setup.sh",
|
|
10
|
+
"timeout": 10
|
|
11
|
+
}
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
],
|
|
3
15
|
"PreToolUse": [
|
|
4
16
|
{
|
|
5
17
|
"matcher": "Edit",
|
|
@@ -21,6 +33,18 @@
|
|
|
21
33
|
}
|
|
22
34
|
]
|
|
23
35
|
}
|
|
36
|
+
],
|
|
37
|
+
"PostToolUse": [
|
|
38
|
+
{
|
|
39
|
+
"matcher": "Bash",
|
|
40
|
+
"hooks": [
|
|
41
|
+
{
|
|
42
|
+
"type": "command",
|
|
43
|
+
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/escalation-guard.sh",
|
|
44
|
+
"timeout": 5
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
}
|
|
24
48
|
]
|
|
25
49
|
}
|
|
26
50
|
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# hooks/project-setup.sh — SessionStart hook: first-run project setup for marketplace installs.
|
|
3
|
+
#
|
|
4
|
+
# Runs on every SessionStart. Checks for marker file .claude/.toolkit-setup-done.
|
|
5
|
+
# If missing (or version is stale): creates CLAUDE.md from template, injects managed block,
|
|
6
|
+
# updates .gitignore with toolkit markers.
|
|
7
|
+
#
|
|
8
|
+
# Templates are read from ${CLAUDE_PLUGIN_ROOT}/templates/ (bundled with the plugin).
|
|
9
|
+
|
|
10
|
+
set -euo pipefail
|
|
11
|
+
|
|
12
|
+
PROJECT_DIR="${CLAUDE_PROJECT_DIR:-$(pwd)}"
|
|
13
|
+
PLUGIN_ROOT="${CLAUDE_PLUGIN_ROOT:-}"
|
|
14
|
+
MARKER_FILE="$PROJECT_DIR/.claude/.toolkit-setup-done"
|
|
15
|
+
|
|
16
|
+
# Exit silently if CLAUDE_PLUGIN_ROOT is not set (not running from a plugin context)
|
|
17
|
+
if [ -z "$PLUGIN_ROOT" ]; then
|
|
18
|
+
exit 0
|
|
19
|
+
fi
|
|
20
|
+
|
|
21
|
+
TEMPLATES_DIR="$PLUGIN_ROOT/templates"
|
|
22
|
+
TEMPLATE_CLAUDE="$TEMPLATES_DIR/CLAUDE.md.template"
|
|
23
|
+
TEMPLATE_BLOCK="$TEMPLATES_DIR/CLAUDE.md.managed-block"
|
|
24
|
+
|
|
25
|
+
# Exit silently if templates are not bundled
|
|
26
|
+
if [ ! -f "$TEMPLATE_CLAUDE" ] || [ ! -f "$TEMPLATE_BLOCK" ]; then
|
|
27
|
+
exit 0
|
|
28
|
+
fi
|
|
29
|
+
|
|
30
|
+
# Read toolkit version from VERSION file (bundled alongside plugin)
|
|
31
|
+
TOOLKIT_VERSION="0.0.0"
|
|
32
|
+
if [ -f "$PLUGIN_ROOT/VERSION" ]; then
|
|
33
|
+
TOOLKIT_VERSION=$(cat "$PLUGIN_ROOT/VERSION" 2>/dev/null | tr -d '[:space:]' || echo "0.0.0")
|
|
34
|
+
fi
|
|
35
|
+
|
|
36
|
+
MANAGED_START="<!-- >>> claude-agents toolkit (DO NOT EDIT THIS BLOCK) >>> -->"
|
|
37
|
+
MANAGED_END="<!-- <<< claude-agents toolkit <<< -->"
|
|
38
|
+
GITIGNORE_START="# >>> claude-agents managed (DO NOT EDIT THIS BLOCK) >>>"
|
|
39
|
+
|
|
40
|
+
# Check marker file — skip if current version is already set up
|
|
41
|
+
if [ -f "$MARKER_FILE" ]; then
|
|
42
|
+
STORED_VERSION=$(cat "$MARKER_FILE" 2>/dev/null | tr -d '[:space:]' || echo "")
|
|
43
|
+
if [ "$STORED_VERSION" = "$TOOLKIT_VERSION" ]; then
|
|
44
|
+
exit 0
|
|
45
|
+
fi
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
CLAUDE_MD="$PROJECT_DIR/CLAUDE.md"
|
|
49
|
+
GITIGNORE="$PROJECT_DIR/.gitignore"
|
|
50
|
+
|
|
51
|
+
# 1. Create CLAUDE.md from template if it doesn't exist (never overwrite existing)
|
|
52
|
+
if [ ! -f "$CLAUDE_MD" ]; then
|
|
53
|
+
PROJECT_NAME=$(basename "$PROJECT_DIR")
|
|
54
|
+
sed "s/{{PROJECT_NAME}}/$PROJECT_NAME/g" "$TEMPLATE_CLAUDE" > "$CLAUDE_MD"
|
|
55
|
+
fi
|
|
56
|
+
|
|
57
|
+
# 2. Inject managed block into CLAUDE.md if missing, or update if version is stale
|
|
58
|
+
if [ -f "$CLAUDE_MD" ]; then
|
|
59
|
+
BLOCK_CONTENT=$(cat "$TEMPLATE_BLOCK")
|
|
60
|
+
NEW_BLOCK=$(printf '%s\n<!-- version: %s -->\n%s\n%s' \
|
|
61
|
+
"$MANAGED_START" "$TOOLKIT_VERSION" "$BLOCK_CONTENT" "$MANAGED_END")
|
|
62
|
+
|
|
63
|
+
if ! grep -qF "$MANAGED_START" "$CLAUDE_MD"; then
|
|
64
|
+
# Block missing — append it
|
|
65
|
+
printf '\n\n%s\n' "$NEW_BLOCK" >> "$CLAUDE_MD"
|
|
66
|
+
else
|
|
67
|
+
# Block exists — update if version changed
|
|
68
|
+
EXISTING_VERSION=$(grep -o '<!-- version: [^>]* -->' "$CLAUDE_MD" 2>/dev/null | head -1 | sed 's/<!-- version: //;s/ -->//' | tr -d '[:space:]' || echo "")
|
|
69
|
+
if [ "$EXISTING_VERSION" != "$TOOLKIT_VERSION" ]; then
|
|
70
|
+
# Replace block contents between markers
|
|
71
|
+
tmp=$(mktemp)
|
|
72
|
+
in_block=false
|
|
73
|
+
wrote_block=false
|
|
74
|
+
while IFS= read -r line; do
|
|
75
|
+
if echo "$line" | grep -qF "$MANAGED_START"; then
|
|
76
|
+
in_block=true
|
|
77
|
+
printf '%s\n' "$NEW_BLOCK" >> "$tmp"
|
|
78
|
+
wrote_block=true
|
|
79
|
+
continue
|
|
80
|
+
fi
|
|
81
|
+
if echo "$line" | grep -qF "$MANAGED_END"; then
|
|
82
|
+
in_block=false
|
|
83
|
+
continue
|
|
84
|
+
fi
|
|
85
|
+
if ! $in_block; then
|
|
86
|
+
echo "$line" >> "$tmp"
|
|
87
|
+
fi
|
|
88
|
+
done < "$CLAUDE_MD"
|
|
89
|
+
mv "$tmp" "$CLAUDE_MD"
|
|
90
|
+
fi
|
|
91
|
+
fi
|
|
92
|
+
fi
|
|
93
|
+
|
|
94
|
+
# 3. Update .gitignore with toolkit marker block if missing
|
|
95
|
+
if [ ! -f "$GITIGNORE" ] || ! grep -qF "$GITIGNORE_START" "$GITIGNORE" 2>/dev/null; then
|
|
96
|
+
GITIGNORE_BLOCK=$(printf '%s\n.claude/.toolkit-last-seen-sha\n.claude/.toolkit-setup-done\n.claude/.claude-agents.conf\n%s' \
|
|
97
|
+
"$GITIGNORE_START" "# <<< claude-agents managed <<<")
|
|
98
|
+
if [ ! -f "$GITIGNORE" ]; then
|
|
99
|
+
printf '%s\n' "$GITIGNORE_BLOCK" > "$GITIGNORE"
|
|
100
|
+
else
|
|
101
|
+
printf '\n\n%s\n' "$GITIGNORE_BLOCK" >> "$GITIGNORE"
|
|
102
|
+
fi
|
|
103
|
+
fi
|
|
104
|
+
|
|
105
|
+
# 4. Write marker file with current version
|
|
106
|
+
mkdir -p "$PROJECT_DIR/.claude"
|
|
107
|
+
printf '%s\n' "$TOOLKIT_VERSION" > "$MARKER_FILE"
|
|
108
|
+
|
|
109
|
+
exit 0
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
## Engineering Principles (MANDATORY — applies to ALL work)
|
|
2
|
+
|
|
3
|
+
### Research Before Fixing
|
|
4
|
+
- **Never guess.** Before changing code, read the relevant source files, docs, and configs.
|
|
5
|
+
- Understand WHY something is broken before attempting a fix.
|
|
6
|
+
- If your first fix doesn't work, STOP. Don't try another guess. Re-read the code.
|
|
7
|
+
- Use explore-light (Haiku, 1x cost) to scan the codebase before expensive agents investigate.
|
|
8
|
+
|
|
9
|
+
### No Over-Engineering
|
|
10
|
+
- **Do exactly what's needed.** Don't add abstractions, utilities, or frameworks unless the code already uses them.
|
|
11
|
+
- Match existing patterns — run explore-light to find how similar code is structured before writing new code.
|
|
12
|
+
- A bug fix touches the minimum files possible. A feature matches the existing architecture.
|
|
13
|
+
- If you're creating a new class/helper/utility that nothing else in the codebase uses, you're over-engineering.
|
|
14
|
+
|
|
15
|
+
### Test Before Shipping
|
|
16
|
+
- **Run tests locally before pushing.** Never push untested code.
|
|
17
|
+
- If the project has `/precheck`, run it. If it has `/qa`, run it in commit mode.
|
|
18
|
+
- After fixing a bug, verify the fix AND verify nothing else broke (differential testing).
|
|
19
|
+
- If 3+ consecutive fix attempts fail, STOP. Step back and reassess the root cause from scratch.
|
|
20
|
+
|
|
21
|
+
### Deployment Safety
|
|
22
|
+
- **Never modify production systems without explicit confirmation.**
|
|
23
|
+
- Don't change deploy targets, CI pipeline structure, or infrastructure config silently.
|
|
24
|
+
- Don't overwrite existing files during deployment without asking.
|
|
25
|
+
- If a deployment breaks something, investigate before attempting to fix. Don't cascade.
|
|
26
|
+
|
|
27
|
+
## Toolkit Awareness (MANDATORY — READ THIS FIRST)
|
|
28
|
+
|
|
29
|
+
You have a **claude-agents toolkit** installed in this project. It provides specialized
|
|
30
|
+
agents, skills, and hooks that handle domain-specific work better and cheaper.
|
|
31
|
+
|
|
32
|
+
**You are the ORCHESTRATOR.** The triage router fires on every message with a routing
|
|
33
|
+
table and SPEED score. Use it to decide: toolkit or you?
|
|
34
|
+
|
|
35
|
+
### When to use the toolkit (SPEED score 2+):
|
|
36
|
+
- **Multi-step workflows**: `/pr`, `/deploy`, `/planning`, `/implement`, `/qa`, `/ci-fix`
|
|
37
|
+
encode battle-tested sequences you'd otherwise do manually and forget steps
|
|
38
|
+
- **Domain expertise**: SRE, QA, frontend, backend agents have project context baked in
|
|
39
|
+
- **Cost savings**: Haiku/Sonnet agents handle 80% of tasks at 1/60th the cost of Opus
|
|
40
|
+
- **Parallelism**: Team skills spawn multiple agents working simultaneously
|
|
41
|
+
|
|
42
|
+
### When to use YOU directly (SPEED score 0-1):
|
|
43
|
+
- **Quick lookups**: Read/Grep/Glob for finding a file, checking a value, reading code
|
|
44
|
+
- **Small targeted edits**: 1-2 file changes where you already know what to do
|
|
45
|
+
- **Complex reasoning**: Architecture decisions, debugging novel problems, nuanced tradeoffs
|
|
46
|
+
- **Conversation flow**: Follow-up questions, clarifications, explaining code
|
|
47
|
+
- **Creative problem-solving**: When the task doesn't fit any existing pattern
|
|
48
|
+
- **Judgment calls**: Security reviews, design decisions, "should we even do this?"
|
|
49
|
+
|
|
50
|
+
### The balance:
|
|
51
|
+
The toolkit handles **process** (repeatable workflows, domain-specific checks, multi-step
|
|
52
|
+
sequences). You handle **judgment** (reasoning, creativity, novel problems, architecture).
|
|
53
|
+
|
|
54
|
+
A senior engineer doesn't do everything themselves — they delegate routine work and focus
|
|
55
|
+
their expertise where it matters most. That's you. The toolkit is your team.
|
|
56
|
+
|
|
57
|
+
**Don't over-delegate**: If it's faster to just Read a file and answer, do it.
|
|
58
|
+
**Don't under-delegate**: If it's a 5-step workflow the toolkit has a skill for, use it.
|
|
59
|
+
|
|
60
|
+
### Project Knowledge System
|
|
61
|
+
|
|
62
|
+
If this project has been calibrated (`/calibrate`), deep context is available:
|
|
63
|
+
|
|
64
|
+
- **`.claude/project-profile.md`** — Architecture patterns, coding conventions, domain model,
|
|
65
|
+
testing style. Read this before writing any code to match the project's patterns.
|
|
66
|
+
- **`.claude/knowledge/`** — The toolkit's long-term memory for this project:
|
|
67
|
+
- `shared/conventions.md` — Coding rules learned from corrections. **Read before writing code.**
|
|
68
|
+
- `shared/domain.md` — Business rules beyond what's in the code. **Read before domain decisions.**
|
|
69
|
+
- `shared/vocabulary.md` — What the team calls things. **Use these terms.**
|
|
70
|
+
- `shared/patterns.md` — Architecture patterns. **Follow these when adding new code.**
|
|
71
|
+
- `agents/{your-name}.md` — Your past learning. **Read on session start.**
|
|
72
|
+
- **Write back** when you learn something new — corrections, discoveries, decisions.
|
|
73
|
+
- See `knowledge/README.md` for the full protocol.
|
|
74
|
+
- **`.claude/knowledge/external/sources.md`** — Where team knowledge lives outside code
|
|
75
|
+
(Notion, Linear, Figma, etc.). Check before making decisions that might already be documented.
|
|
76
|
+
|
|
77
|
+
## Session Start Behavior (MANDATORY)
|
|
78
|
+
|
|
79
|
+
On your FIRST response in every new session, ALWAYS start with a brief status line
|
|
80
|
+
using context from the SessionStart hook. Include:
|
|
81
|
+
- Current branch + uncommitted file count
|
|
82
|
+
- Docker/infra status (if problems detected)
|
|
83
|
+
- Open PRs or assigned issues (if any)
|
|
84
|
+
- Any red flags (pending migrations, expired tokens)
|
|
85
|
+
|
|
86
|
+
Format: 1-3 compact lines before addressing the user's request. Example:
|
|
87
|
+
```
|
|
88
|
+
📋 project — main | 5 uncommitted | Docker: postgres ✓ redis ✓ | 2 open PRs
|
|
89
|
+
```
|
|
90
|
+
Then proceed with the user's actual request.
|
|
91
|
+
|
|
92
|
+
**CRITICAL — Greetings and vague first messages**: If the user's first message is a
|
|
93
|
+
greeting ("hey", "hi", "hello", "yo", "sup") or vague ("help", "what's up",
|
|
94
|
+
"what should I work on") or ANY message under 5 words with no specific task —
|
|
95
|
+
**ALWAYS use the `/onboard` skill**. Never respond to greetings yourself. The
|
|
96
|
+
bootstrap hook status line is a quick snapshot — `/onboard` gives the real briefing
|
|
97
|
+
with open PRs, issues, priorities, and actionable next steps.
|
|
98
|
+
|
|
99
|
+
## Routing Trace (MANDATORY)
|
|
100
|
+
|
|
101
|
+
On EVERY response, show a compact routing trace so the user understands the decision
|
|
102
|
+
path. Place it at the end of your response in a dimmed block:
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
🔀 Routing: [what triage decided] → [agent/skill/tool used] ([cost tier])
|
|
106
|
+
Why: [1-line reason for this routing choice]
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Examples:
|
|
110
|
+
```
|
|
111
|
+
🔀 Routing: backend bug fix → python-backend agent (Sonnet, 10x)
|
|
112
|
+
Why: touches backend/app/services/, needs CLAUDE.md context, SPEED=4
|
|
113
|
+
```
|
|
114
|
+
```
|
|
115
|
+
🔀 Routing: file lookup → Grep (built-in, 0x)
|
|
116
|
+
Why: single-file search, no project context needed, SPEED=0
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Rules:
|
|
120
|
+
- Always show the SPEED score breakdown if score >= 2
|
|
121
|
+
- Show which hook provided the context (triage-router, bootstrap, etc.)
|
|
122
|
+
- If you chose NOT to use the triage router's suggestion, explain why
|
|
123
|
+
- Skip the trace only for simple follow-up messages in an ongoing conversation
|