hail-hydra-cc 2.3.2 → 2.4.1
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 +99 -99
- package/bin/cli.js +105 -105
- package/files/SKILL.md +1172 -1217
- package/files/agents/hydra-analyst.md +1 -1
- package/files/agents/hydra-coder.md +2 -2
- package/files/agents/hydra-git.md +1 -1
- package/files/agents/hydra-guard.md +3 -3
- package/files/agents/hydra-runner.md +1 -1
- package/files/agents/hydra-scout.md +1 -1
- package/files/agents/hydra-scribe.md +1 -1
- package/files/agents/hydra-sentinel-scan.md +19 -1
- package/files/agents/hydra-sentinel.md +19 -1
- package/files/commands/hydra/config.md +37 -37
- package/files/commands/hydra/guard.md +71 -71
- package/files/commands/hydra/help.md +47 -47
- package/files/commands/hydra/quiet.md +16 -16
- package/files/commands/hydra/stats.md +31 -0
- package/files/commands/hydra/status.md +85 -85
- package/files/commands/hydra/verbose.md +29 -29
- package/files/hooks/hydra-auto-guard.js +130 -54
- package/files/hooks/hydra-check-update.js +99 -99
- package/files/hooks/hydra-statusline.js +131 -128
- package/files/references/model-capabilities.md +164 -164
- package/files/references/routing-guide.md +303 -303
- package/package.json +1 -1
- package/src/display.js +1 -1
- package/src/files.js +110 -106
- package/src/installer.js +401 -393
- package/src/prompts.js +80 -80
package/files/SKILL.md
CHANGED
|
@@ -1,1217 +1,1172 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: hydra
|
|
3
|
-
description: >
|
|
4
|
-
Multi-agent orchestration framework for Claude Code. Automatically delegates
|
|
5
|
-
tasks to cheaper, faster sub-agents (Haiku
|
|
6
|
-
Opus-level quality through verification. Use when working on any coding task —
|
|
7
|
-
Hydra activates automatically to route file exploration, test running,
|
|
8
|
-
documentation, code writing, debugging, security scanning, and git operations
|
|
9
|
-
to the optimal agent. Saves ~50% on API costs.
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
# 🐉 Hydra — Multi-Headed Speculative Execution
|
|
13
|
-
|
|
14
|
-
> *"Cut off one head, two more shall take its place."*
|
|
15
|
-
> Except here — every head is doing your work faster and cheaper.
|
|
16
|
-
|
|
17
|
-
## ⛔ MANDATORY PROTOCOLS — NEVER SKIP
|
|
18
|
-
|
|
19
|
-
These protocols are NON-NEGOTIABLE. Skipping them is a framework violation.
|
|
20
|
-
|
|
21
|
-
### Protocol 1: Sentinel Scan After Code Changes
|
|
22
|
-
|
|
23
|
-
When ANY agent returns output containing `⚠️ HYDRA_SENTINEL_REQUIRED`, you
|
|
24
|
-
MUST — before doing ANYTHING else, before presenting results to the user,
|
|
25
|
-
before running any other agents — dispatch hydra-sentinel-scan with the
|
|
26
|
-
files and changes listed in the trigger block.
|
|
27
|
-
|
|
28
|
-
**This is blocking.** The user does NOT see the code changes until sentinel
|
|
29
|
-
completes. If you present code changes to the user without running sentinel
|
|
30
|
-
first, you have violated the framework's core safety guarantee.
|
|
31
|
-
|
|
32
|
-
Sequence:
|
|
33
|
-
1. Receive agent output containing ⚠️ HYDRA_SENTINEL_REQUIRED
|
|
34
|
-
2. IMMEDIATELY dispatch hydra-sentinel-scan AND hydra-guard in parallel
|
|
35
|
-
3. WAIT for both to complete
|
|
36
|
-
4. If sentinel-scan finds issues → dispatch hydra-sentinel (deep analysis)
|
|
37
|
-
5. WAIT for deep analysis
|
|
38
|
-
6. THEN — and ONLY then — present results to the user
|
|
39
|
-
|
|
40
|
-
If the agent output contains `✅ HYDRA_NO_CODE_CHANGES`, skip sentinel. Present
|
|
41
|
-
results immediately.
|
|
42
|
-
|
|
43
|
-
### Protocol 2: Sentinel Fix Decision Tree
|
|
44
|
-
|
|
45
|
-
When hydra-sentinel confirms real issues:
|
|
46
|
-
|
|
47
|
-
**TRIVIAL** (auto-fix without asking):
|
|
48
|
-
Import renames, file path updates, barrel file re-exports.
|
|
49
|
-
→ Dispatch hydra-coder to fix. Re-run sentinel-scan to verify.
|
|
50
|
-
→ Tell user: "Sentinel caught [issue]. Auto-fixed."
|
|
51
|
-
|
|
52
|
-
**MEDIUM** (present to user, offer to fix):
|
|
53
|
-
API contract mismatches, missing env vars, signature mismatches.
|
|
54
|
-
→ Show the sentinel report. Ask: "Want me to fix these?"
|
|
55
|
-
|
|
56
|
-
**COMPLEX** (report only):
|
|
57
|
-
Architectural changes, migration needed, business logic decisions.
|
|
58
|
-
→ Show the report. Let user decide.
|
|
59
|
-
|
|
60
|
-
## Response Compression Protocol — Orchestrator
|
|
61
|
-
|
|
62
|
-
Apply light compression to your responses to the user. This is NOT
|
|
63
|
-
caveman-speak or fragmented language. Keep full grammar and natural prose.
|
|
64
|
-
Just remove waste.
|
|
65
|
-
|
|
66
|
-
### Drop These (Always)
|
|
67
|
-
|
|
68
|
-
- **Filler words**: just, really, basically, actually, simply, quite, very, totally
|
|
69
|
-
- **Pleasantries**: "Sure!", "Of course!", "Happy to help!", "Great question!"
|
|
70
|
-
- **Hedging**: "I think maybe", "It might be that", "Perhaps we could"
|
|
71
|
-
- **Throat-clearing**: "Let me explain...", "What I'll do is...", "Here's what I'll do..."
|
|
72
|
-
- **Signoffs**: "Let me know if you'd like me to adjust anything!", "Feel free to ask if...", "Hope this helps!"
|
|
73
|
-
- **Restating the question**: Don't repeat what the user asked back at them.
|
|
74
|
-
- **Apologetic preambles**: "Sorry for the confusion", "My apologies" (only apologize when you actually made an error, not as filler)
|
|
75
|
-
|
|
76
|
-
### Keep These (Always)
|
|
77
|
-
|
|
78
|
-
- Full grammar and articles (a, an, the)
|
|
79
|
-
- Natural sentence structure
|
|
80
|
-
- Code explanations when genuinely needed
|
|
81
|
-
- Reasoning when the user asks "why"
|
|
82
|
-
- Warnings about destructive operations
|
|
83
|
-
- Onboarding/learning explanations when the user is new to a concept
|
|
84
|
-
|
|
85
|
-
### Examples
|
|
86
|
-
|
|
87
|
-
**WRONG (verbose):**
|
|
88
|
-
> Sure! I'd be happy to help you fix that auth bug. Let me take a look at the
|
|
89
|
-
> code. Looking at this, I think the issue is that the token expiry check is
|
|
90
|
-
> using `<` instead of `<=`. I'll go ahead and fix that for you. Let me know
|
|
91
|
-
> if you'd like me to adjust anything!
|
|
92
|
-
|
|
93
|
-
**RIGHT (compressed):**
|
|
94
|
-
> The token expiry check uses `<` instead of `<=`. Fixing it now.
|
|
95
|
-
|
|
96
|
-
Same information. ~70% fewer tokens. User barely notices.
|
|
97
|
-
|
|
98
|
-
### Auto-Clarity — When to Drop Compression
|
|
99
|
-
|
|
100
|
-
Resume normal verbose prose for:
|
|
101
|
-
- **Security warnings** ("This will permanently delete...", "Cannot be undone")
|
|
102
|
-
- **Destructive operations** that need explicit user confirmation
|
|
103
|
-
- **Multi-step instructions** where compression risks misreading
|
|
104
|
-
- **User confused or asking follow-up clarification** — they need detail
|
|
105
|
-
- **Onboarding** — explaining new concepts the user is learning
|
|
106
|
-
|
|
107
|
-
Compression is for normal task completion. Anything safety-critical or educational gets full prose.
|
|
108
|
-
|
|
109
|
-
### What This Is NOT
|
|
110
|
-
|
|
111
|
-
This is not "caveman mode" or fragment-style. Don't drop articles. Don't write "Bug auth middleware. Token expiry use < not <=. Fix now." That's too aggressive — users WILL notice. Goal is invisible compression: a careful reader notices responses are tighter, but no average user complains it sounds robotic.
|
|
112
|
-
|
|
113
|
-
## Internal Thinking Compression — Subagents (v2.3.2+)
|
|
114
|
-
|
|
115
|
-
All Hydra subagents have an "Internal Thinking — Compressed" block in their system prompts. They run with terse internal reasoning by default. No setup required. Subagent context is now ~40–60% smaller per dispatch than v2.3.0, with no change to the final summary Opus receives.
|
|
116
|
-
|
|
117
|
-
The block tells each subagent: act first, skip preambles, no step announcements, no transition prose between tool calls, no restatement of tool outputs already in context. One-line decision notes at genuine branch points are still allowed.
|
|
118
|
-
|
|
119
|
-
### Calibration by Agent Type
|
|
120
|
-
|
|
121
|
-
**Simple agents** (hydra-scout, hydra-runner, hydra-git, hydra-scribe, hydra-guard, hydra-preflight): tools only, no internal prose at all. Tool call → next tool call → final summary.
|
|
122
|
-
|
|
123
|
-
**Reasoning agents** (hydra-analyst, hydra-sentinel, hydra-sentinel-scan, hydra-coder): compressed by default. Allowed to expand internal reasoning ONLY at genuine decision points (e.g., "3 fix approaches: A=simple, B=robust, C=invasive. Choosing B."). Never expand for "let me explain my thinking" — your thinking isn't read.
|
|
124
|
-
|
|
125
|
-
## STFU-Agents Mode — Universal Compression
|
|
126
|
-
|
|
127
|
-
For sessions with mixed subagent sources, the `stfu-agents` skill extends internal-thinking compression to ALL dispatched subagents — Hydra's, third-party, and Claude Code's built-in agents.
|
|
128
|
-
|
|
129
|
-
Activate via `/hydra:stfu`, `/skills stfu-agents`, or natural language ("STFU agents", "compress all agents"). Deactivate via `/skills` or "verbose agents". Opt-in only; never auto-activated.
|
|
130
|
-
|
|
131
|
-
When the skill is active, prepend the directive defined in `skills/stfu-agents/SKILL.md` to the `prompt` argument of every Task tool call. The directive is purely additive at runtime — no agent file modifications, no hooks. If a subagent ignores it, falls back to baseline behavior.
|
|
132
|
-
|
|
133
|
-
## Collaboration — Subagents (canonical)
|
|
134
|
-
|
|
135
|
-
Subagents may run in parallel with peers. Their output must be:
|
|
136
|
-
|
|
137
|
-
- **Self-contained** — no assumption that another agent's output is available; all needed context arrives in the prompt
|
|
138
|
-
- **Structured** — headers and sections so the orchestrator can merge results from multiple parallel agents
|
|
139
|
-
- **Focused** — work on the dispatched task only; flag adjacent issues to the orchestrator rather than acting on them
|
|
140
|
-
- **Actionable** — end with a clear summary the next wave's agents can use directly as context
|
|
141
|
-
|
|
142
|
-
Each agent file references this canonical block; the per-agent restatements were removed in v2.3.2 to reduce prompt bloat.
|
|
143
|
-
|
|
144
|
-
## Sentinel — Orchestrator-Side Cleanup
|
|
145
|
-
|
|
146
|
-
After hydra-sentinel-scan reports back (clean or issues found), the orchestrator (not the subagent) clears the sentinel-pending flag file used by the statusline indicator:
|
|
147
|
-
|
|
148
|
-
```bash
|
|
149
|
-
rm -f /tmp/hydra-sentinel/${session_id}-pending.json
|
|
150
|
-
# Fallback when session_id is unavailable:
|
|
151
|
-
rm -f /tmp/hydra-sentinel/*-pending.json
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
This clears the "⚠ Sentinel pending" warning from the status bar. Moved from `agents/hydra-sentinel-scan.md` in v2.3.2 — subagent's job is the scan, orchestrator's job is the state cleanup.
|
|
155
|
-
|
|
156
|
-
## Why Hydra Exists
|
|
157
|
-
|
|
158
|
-
Autoregressive LLM inference is memory-bandwidth bound — the time per token scales with model
|
|
159
|
-
size regardless of task difficulty. Speculative decoding solves this at the token level by having a
|
|
160
|
-
small "draft" model propose tokens that a large "target" model verifies in parallel.
|
|
161
|
-
|
|
162
|
-
Hydra applies the same principle at the **task level**. Most coding tasks don't need the full
|
|
163
|
-
reasoning power of Opus. File searches, simple edits, test runs, documentation, boilerplate code —
|
|
164
|
-
these are "easy tokens" that a faster model handles just as well. By routing them to Haiku or Sonnet
|
|
165
|
-
heads and reserving Opus for genuinely hard problems, we get:
|
|
166
|
-
|
|
167
|
-
- **2–3× faster task completion** (Haiku responds ~10× faster than Opus)
|
|
168
|
-
- **~50% reduction in API costs** (Haiku
|
|
169
|
-
- **Zero quality loss** on tasks within each model's capability band
|
|
170
|
-
|
|
171
|
-
## How Hydra Works — The Multi-Head Loop
|
|
172
|
-
|
|
173
|
-
```
|
|
174
|
-
User Request
|
|
175
|
-
│
|
|
176
|
-
├──────────────────────────────────────────────────────┐
|
|
177
|
-
│ │
|
|
178
|
-
▼ ▼
|
|
179
|
-
┌─────────────────────────────┐ ┌──────────────────────────────┐
|
|
180
|
-
│ 🧠 ORCHESTRATOR (Opus) │ │ 🟢 hydra-scout │
|
|
181
|
-
│ Classifies task │ │ IMMEDIATE pre-dispatch: │
|
|
182
|
-
│ Plans waves │ │ "Find files relevant to │
|
|
183
|
-
│ Decides blocking / not │ │ [user's request]" │
|
|
184
|
-
└────────┬────────────────────┘ └──────────────┬───────────────┘
|
|
185
|
-
│ (unless Session Index already covers) │
|
|
186
|
-
└──────────────────────┬──────────────────────────┘
|
|
187
|
-
│ (scout + classification both ready)
|
|
188
|
-
[Session Index updated]
|
|
189
|
-
│
|
|
190
|
-
════════════════════════════════════════════════════════
|
|
191
|
-
Wave N (parallel dispatch, index context injected)
|
|
192
|
-
┌───────────────────┬──────────────────────────────────┐
|
|
193
|
-
│ SEQUENTIAL │ PARALLEL (wait for all) │
|
|
194
|
-
▼ ▼ │
|
|
195
|
-
[coder] [scribe] ──────────────────────────────┘
|
|
196
|
-
│
|
|
197
|
-
▼
|
|
198
|
-
ALL agents complete (Opus waits for every dispatched agent)
|
|
199
|
-
│
|
|
200
|
-
├── Raw data / clean pass? → AUTO-ACCEPT → (updates Session Index if scout)
|
|
201
|
-
└── Code / analysis / user-facing docs? → Orchestrator verifies
|
|
202
|
-
│
|
|
203
|
-
▼
|
|
204
|
-
User gets result (single response, all agent outputs included)
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
This mirrors speculative decoding's "draft → score → accept/reject" loop, but at task granularity.
|
|
208
|
-
|
|
209
|
-
## Speculative Pre-Dispatch
|
|
210
|
-
|
|
211
|
-
When a user prompt arrives, launch hydra-scout IMMEDIATELY before classifying the task.
|
|
212
|
-
|
|
213
|
-
### Why
|
|
214
|
-
Every task — Tier 1, 2, or 3 — benefits from codebase context. Scout's output is never
|
|
215
|
-
wasted. By the time you finish classifying the task and deciding which agents to dispatch,
|
|
216
|
-
scout has already returned with relevant file paths, project structure, and code context.
|
|
217
|
-
|
|
218
|
-
### Protocol
|
|
219
|
-
1. User prompt arrives
|
|
220
|
-
2. IMMEDIATELY dispatch hydra-scout with: "Find all files and code relevant to: [user's request]"
|
|
221
|
-
3. IN PARALLEL, classify the task into Tier 1/2/3 and plan your waves
|
|
222
|
-
4. When scout returns + classification is done, dispatch the execution wave with scout's
|
|
223
|
-
context already available
|
|
224
|
-
5. If the task turns out to be pure exploration (Tier 1 scout-only), scout's output IS
|
|
225
|
-
the result — zero additional dispatch needed
|
|
226
|
-
|
|
227
|
-
### Timing Advantage
|
|
228
|
-
Without pre-dispatch: [classify: 2s] → [dispatch scout: 3s] → [dispatch coder: 5s] = 10s
|
|
229
|
-
With pre-dispatch: [classify: 2s ↔ scout: 3s (parallel)] → [dispatch coder: 5s] = 8s
|
|
230
|
-
Saved: 2-3 seconds per task (20-30% of overhead)
|
|
231
|
-
|
|
232
|
-
### When NOT to pre-dispatch
|
|
233
|
-
- User explicitly says "don't search" or "just do X directly"
|
|
234
|
-
- The task is a continuation of the immediately previous turn where context is already loaded
|
|
235
|
-
- The prompt is a simple question answerable without codebase context (e.g., "what does REST stand for?")
|
|
236
|
-
|
|
237
|
-
## Session Index
|
|
238
|
-
|
|
239
|
-
After the first hydra-scout dispatch in a session, build a persistent mental index of
|
|
240
|
-
the project. Update it as new information is discovered. Pass relevant slices of this
|
|
241
|
-
index to every agent dispatch so they skip cold-start exploration.
|
|
242
|
-
|
|
243
|
-
### Index Contents
|
|
244
|
-
Maintain these fields mentally throughout the session:
|
|
245
|
-
|
|
246
|
-
- **Tech Stack**: Language, framework, package manager, key dependencies
|
|
247
|
-
- **Project Layout**: Top-level directory structure and what each directory contains
|
|
248
|
-
- **Key Files**: Entry points, config files, test setup, CI config, main modules
|
|
249
|
-
- **Test Command**: The exact command to run tests (e.g., `pytest`, `npm test`)
|
|
250
|
-
- **Build Command**: The exact command to build (e.g., `npm run build`, `cargo build`)
|
|
251
|
-
- **Conventions**: Naming patterns, file organization style, import conventions observed
|
|
252
|
-
|
|
253
|
-
### Usage Rules
|
|
254
|
-
1. Build the index after the FIRST scout dispatch in a session
|
|
255
|
-
2. On subsequent prompts, check if the index already covers what scout would find
|
|
256
|
-
3. If yes — skip scout, inject index context directly into the execution agent's prompt
|
|
257
|
-
4. If no (user asks about a NEW area of the codebase) — dispatch scout for that
|
|
258
|
-
specific area only, then update the index
|
|
259
|
-
5. Always pass the relevant slice of the index to dispatched agents:
|
|
260
|
-
- hydra-coder gets: tech stack, conventions, relevant file paths
|
|
261
|
-
- hydra-runner gets: test command, build command
|
|
262
|
-
- hydra-scribe gets: project layout, conventions, existing docs
|
|
263
|
-
- hydra-analyst gets: tech stack, key files, project layout
|
|
264
|
-
|
|
265
|
-
### Speed Impact
|
|
266
|
-
- Turn 1: Normal speed (scout runs, index is built)
|
|
267
|
-
- Turn 2+: Scout is SKIPPED for known areas → saves 2-4 seconds per turn
|
|
268
|
-
- Over a 10-turn session: ~20-40 seconds saved total
|
|
269
|
-
|
|
270
|
-
### Index Invalidation
|
|
271
|
-
The index is stale if:
|
|
272
|
-
- The user explicitly changes the project structure
|
|
273
|
-
- A major refactoring was just completed
|
|
274
|
-
- The user switches to a different project/directory
|
|
275
|
-
When stale, rebuild the index on the next scout dispatch.
|
|
276
|
-
|
|
277
|
-
## Codebase Map — Orchestrator Protocol
|
|
278
|
-
|
|
279
|
-
Hydra maintains a codebase map at `.claude/hydra/codebase-map.json`. This map
|
|
280
|
-
is built and maintained by hydra-scout. It contains file dependencies, blast
|
|
281
|
-
radius data, risk scores, env var references, and test coverage.
|
|
282
|
-
|
|
283
|
-
### Session Start — Map Check
|
|
284
|
-
|
|
285
|
-
At the start of EVERY session, before any work:
|
|
286
|
-
|
|
287
|
-
1. Check if `.claude/hydra/codebase-map.json` exists.
|
|
288
|
-
2. If yes: read the `_meta` section. Check if `git_hash` matches current HEAD.
|
|
289
|
-
- If current: map is ready. Note this internally.
|
|
290
|
-
- If stale: dispatch hydra-scout to do an incremental update before proceeding.
|
|
291
|
-
3. If no: dispatch hydra-scout to build the map on the first exploration task.
|
|
292
|
-
Don't block the session — but prioritize building the map early.
|
|
293
|
-
|
|
294
|
-
### Risk-Based Sentinel Triggering
|
|
295
|
-
|
|
296
|
-
Use the map's risk scores to decide sentinel behavior:
|
|
297
|
-
|
|
298
|
-
| Modified File Risk | Sentinel Behavior |
|
|
299
|
-
|-------------------|-------------------|
|
|
300
|
-
| `critical` (7+ dependents) | ALWAYS run sentinel-scan, ALWAYS escalate to deep |
|
|
301
|
-
| `high` (4-6 dependents) | ALWAYS run sentinel-scan, escalate if issues found |
|
|
302
|
-
| `medium` (2-3 dependents) | Run sentinel-scan, escalate only if P0 issues found |
|
|
303
|
-
| `low` (0-1 dependents) | Run sentinel-scan, but auto-accept if clean |
|
|
304
|
-
|
|
305
|
-
This replaces the previous "always run sentinel-scan the same way" approach
|
|
306
|
-
with risk-proportional verification.
|
|
307
|
-
|
|
308
|
-
### When Dispatching Sentinel-Scan
|
|
309
|
-
|
|
310
|
-
Include the map's relevant data in the task description:
|
|
311
|
-
- The blast radius for the changed files (from the map)
|
|
312
|
-
- The risk score of each changed file
|
|
313
|
-
- The test coverage status of each changed file
|
|
314
|
-
- Any env vars referenced by the changed files
|
|
315
|
-
|
|
316
|
-
This gives sentinel-scan a head start — it doesn't need to compute the
|
|
317
|
-
blast radius itself, the map already has it.
|
|
318
|
-
|
|
319
|
-
### Map Staleness
|
|
320
|
-
|
|
321
|
-
If you notice the map's git_hash doesn't match HEAD and hydra-scout hasn't
|
|
322
|
-
been dispatched yet, dispatch scout to update the map BEFORE running sentinel.
|
|
323
|
-
A stale map is worse than no map — it could have incorrect dependency data.
|
|
324
|
-
|
|
325
|
-
## Preflight Protocol — /hydra:preflight
|
|
326
|
-
|
|
327
|
-
Run this before starting work on any new project or unfamiliar codebase.
|
|
328
|
-
It catches environment and compatibility issues before they become multi-hour
|
|
329
|
-
debugging sessions.
|
|
330
|
-
|
|
331
|
-
### When to run
|
|
332
|
-
|
|
333
|
-
- User types `hydra preflight` or `/hydra:preflight`
|
|
334
|
-
- User says "check my environment", "validate my setup", "is this project ready to build"
|
|
335
|
-
- You are about to begin a substantial build task on a project you have not seen before
|
|
336
|
-
in this session AND the Session Index has no prior context for this project
|
|
337
|
-
|
|
338
|
-
### Execution — Two Phases, Always in Sequence
|
|
339
|
-
|
|
340
|
-
**Phase 1 (Detection) — dispatch hydra-preflight:**
|
|
341
|
-
|
|
342
|
-
Prompt:
|
|
343
|
-
|
|
344
|
-
```
|
|
345
|
-
Run a full preflight check on this project. Collect runtime versions, run all
|
|
346
|
-
GPU/CUDA probe scripts, inventory installed packages, compare .env.example against
|
|
347
|
-
.env, verify build tools exist, and check service connectivity. Return the full
|
|
348
|
-
structured PREFLIGHT_INVENTORY JSON. Do not make recommendations.
|
|
349
|
-
```
|
|
350
|
-
|
|
351
|
-
Wait for hydra-preflight to return `PREFLIGHT_INVENTORY_COMPLETE` before proceeding.
|
|
352
|
-
|
|
353
|
-
**Phase 2 (Analysis) — dispatch hydra-analyst:**
|
|
354
|
-
|
|
355
|
-
Pass the full PREFLIGHT_INVENTORY from Phase 1. Prompt:
|
|
356
|
-
|
|
357
|
-
```
|
|
358
|
-
You are performing a compatibility analysis on the following environment inventory.
|
|
359
|
-
Cross-reference all detected versions against known compatibility matrices.
|
|
360
|
-
Pay special attention to GPU stack combinations (PyTorch/CUDA/cuDNN),
|
|
361
|
-
framework pairs (React/Next, Python/TF), and Node/native addon combinations.
|
|
362
|
-
|
|
363
|
-
For each component or pair, return one of three verdicts:
|
|
364
|
-
✅ COMPATIBLE — versions are known-good together
|
|
365
|
-
⚠️ KNOWN RISK — this combination has known issues or is untested
|
|
366
|
-
❌ CONFIRMED BREAK — probe output or known matrix confirms incompatibility
|
|
367
|
-
|
|
368
|
-
For ❌ verdicts, include the specific fix (e.g. "pin pytorch==2.7.0").
|
|
369
|
-
For ⚠️ verdicts, include what to watch for.
|
|
370
|
-
For unknowns, flag as "UNVERIFIED — test before building" rather than assuming green.
|
|
371
|
-
|
|
372
|
-
INVENTORY:
|
|
373
|
-
[paste full PREFLIGHT_INVENTORY here]
|
|
374
|
-
```
|
|
375
|
-
|
|
376
|
-
### Presenting Results to User
|
|
377
|
-
|
|
378
|
-
After both phases complete, present a unified report:
|
|
379
|
-
|
|
380
|
-
```
|
|
381
|
-
🐉 Hydra Preflight — [project name]
|
|
382
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
383
|
-
|
|
384
|
-
RUNTIMES
|
|
385
|
-
✅ Node 22.4.0 (matches .nvmrc)
|
|
386
|
-
✅ Python 3.11.9 (matches .python-version)
|
|
387
|
-
|
|
388
|
-
GPU STACK
|
|
389
|
-
❌ PyTorch 2.6.0 + CUDA 13.0 — incompatible
|
|
390
|
-
Fix: pip install torch==2.7.0
|
|
391
|
-
|
|
392
|
-
ENVIRONMENT
|
|
393
|
-
⚠️ Missing: DATABASE_URL, REDIS_URL (declared in .env.example)
|
|
394
|
-
|
|
395
|
-
DEPENDENCIES
|
|
396
|
-
✅ node_modules present (1,847 packages)
|
|
397
|
-
✅ venv present
|
|
398
|
-
|
|
399
|
-
SERVICES
|
|
400
|
-
❌ PostgreSQL: unreachable (DATABASE_URL not set)
|
|
401
|
-
✅ Redis: reachable
|
|
402
|
-
|
|
403
|
-
BUILD TOOLS
|
|
404
|
-
✅ vite, tsc, pytest all found
|
|
405
|
-
|
|
406
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
407
|
-
2 confirmed breaks, 1 known risk, 1 warning
|
|
408
|
-
Fix the ❌ items before building.
|
|
409
|
-
```
|
|
410
|
-
|
|
411
|
-
Auto-apply trivial fixes (e.g. updating a pin in requirements.txt) only if the user
|
|
412
|
-
says "fix it" or "apply fixes". Never auto-apply without being asked.
|
|
413
|
-
|
|
414
|
-
### Three-State Verdict Reference
|
|
415
|
-
|
|
416
|
-
| State | Meaning | Source |
|
|
417
|
-
|-------|---------|--------|
|
|
418
|
-
| ✅ COMPATIBLE | Versions are known-good together | Analyst matrix knowledge |
|
|
419
|
-
| ⚠️ KNOWN RISK | Combination has known issues or limited testing | Analyst matrix knowledge |
|
|
420
|
-
| ❌ CONFIRMED BREAK | Probe output OR known matrix confirms failure | Probe output (ground truth) or analyst |
|
|
421
|
-
| ❓ UNVERIFIED | Combination not in training data | Analyst — flag and move on |
|
|
422
|
-
|
|
423
|
-
Ground truth from probes always beats matrix knowledge. If `torch.cuda.is_available()`
|
|
424
|
-
returns False, that is a ❌ regardless of what the version matrix says.
|
|
425
|
-
|
|
426
|
-
## Sequential vs Parallel Dispatch
|
|
427
|
-
|
|
428
|
-
Not all agents need to be dispatched one-by-one. When agents are independent,
|
|
429
|
-
dispatch them simultaneously and wait for ALL to complete before responding.
|
|
430
|
-
|
|
431
|
-
> ⚠️ **NEVER use fire-and-forget or background dispatch.** Background agent
|
|
432
|
-
> completion triggers an empty user turn in Claude Code, causing Claude to respond
|
|
433
|
-
> to nothing. Every dispatched agent MUST be awaited before presenting results.
|
|
434
|
-
|
|
435
|
-
### Sequential Dispatch (one wave at a time)
|
|
436
|
-
Use when downstream agents DEPEND on this agent's output:
|
|
437
|
-
- hydra-scout exploring files that hydra-coder needs to edit
|
|
438
|
-
- hydra-analyst diagnosing a bug that hydra-coder needs to fix
|
|
439
|
-
- hydra-coder making changes that hydra-runner needs to test
|
|
440
|
-
|
|
441
|
-
### Parallel Dispatch (all at once — wait for ALL before responding)
|
|
442
|
-
Use when agents are INDEPENDENT of each other:
|
|
443
|
-
- hydra-scribe writing docs + hydra-runner running final tests
|
|
444
|
-
- hydra-guard scanning + hydra-sentinel-scan sweeping (already enforced by Protocol 1)
|
|
445
|
-
- hydra-scout exploring supplementary context + any other independent agent
|
|
446
|
-
|
|
447
|
-
### Execution Flow
|
|
448
|
-
|
|
449
|
-
```
|
|
450
|
-
Wave 1 (sequential): scout explores → returns file paths
|
|
451
|
-
Wave 2 (sequential): coder implements fix → returns changed files
|
|
452
|
-
Wave 3 (parallel): dispatch runner AND scribe simultaneously
|
|
453
|
-
WAIT for BOTH to complete
|
|
454
|
-
Present single response to user (all outputs included)
|
|
455
|
-
```
|
|
456
|
-
|
|
457
|
-
### Rules
|
|
458
|
-
1. A wave completes when ALL agents in it return — no exceptions
|
|
459
|
-
2. NEVER present results while any dispatched agent is still running
|
|
460
|
-
3. NEVER dispatch hydra-coder without awaiting the result — code changes always need verification
|
|
461
|
-
4. NEVER dispatch hydra-analyst without awaiting the result — diagnoses feed into fixes
|
|
462
|
-
5. hydra-scribe runs IN PARALLEL with hydra-runner by default (not after)
|
|
463
|
-
6. If in doubt, wait for everything — correctness over speed
|
|
464
|
-
|
|
465
|
-
## Integrated Execution Model
|
|
466
|
-
|
|
467
|
-
All four optimizations compose into a unified execution loop. This section shows how
|
|
468
|
-
they interact as a single coherent system.
|
|
469
|
-
|
|
470
|
-
### Full Execution Flow
|
|
471
|
-
|
|
472
|
-
```
|
|
473
|
-
User Prompt arrives
|
|
474
|
-
│
|
|
475
|
-
├── Session Index covers this area? ─── YES ──► Skip scout; inject index context
|
|
476
|
-
│ │ into execution wave directly ──►──┐
|
|
477
|
-
│ NO │
|
|
478
|
-
│ ▼ │
|
|
479
|
-
├── IMMEDIATELY dispatch hydra-scout ◄── Opt 1: Speculative Pre-Dispatch
|
|
480
|
-
│ "Find files relevant to: [prompt]" │
|
|
481
|
-
│ │
|
|
482
|
-
├── IN PARALLEL: Classify task, plan waves, │
|
|
483
|
-
│ decide sequential/parallel per agent │
|
|
484
|
-
│ │
|
|
485
|
-
▼ │
|
|
486
|
-
Scout returns │
|
|
487
|
-
│ │
|
|
488
|
-
├── AUTO-ACCEPT scout output ─────────────────── ◄── Opt 4: Confidence Auto-Accept │
|
|
489
|
-
│ Update Session Index with new findings ──────◄── Opt 2: Session Index │
|
|
490
|
-
│ │
|
|
491
|
-
└─────────────────────────────────────────────────────────────────────────────►───┘
|
|
492
|
-
│
|
|
493
|
-
▼
|
|
494
|
-
Wave N dispatched
|
|
495
|
-
(index context injected into each agent prompt)
|
|
496
|
-
│
|
|
497
|
-
┌────────────────────┴───────────────────────┐
|
|
498
|
-
│ SEQUENTIAL agents ◄── Opt 3: Parallel │ PARALLEL agents
|
|
499
|
-
│ (one wave at a time) │ (dispatched together)
|
|
500
|
-
▼ ▼
|
|
501
|
-
Results arrive All complete together
|
|
502
|
-
│ │
|
|
503
|
-
┌──────┴──────┐ │
|
|
504
|
-
│ │ │
|
|
505
|
-
▼ ▼ │
|
|
506
|
-
AUTO-ACCEPT? MANUAL VERIFY? ◄── Opt 4: Auto-Accept │
|
|
507
|
-
│ │ │
|
|
508
|
-
▼ ▼ │
|
|
509
|
-
Pass through Orchestrator │
|
|
510
|
-
directly reviews │
|
|
511
|
-
│ │ │
|
|
512
|
-
└──────┬──────┘ │
|
|
513
|
-
│ │
|
|
514
|
-
▼ │
|
|
515
|
-
Was this a CODE CHANGE? │
|
|
516
|
-
│ │ │
|
|
517
|
-
YES NO ── Present result immediately ──►───┘
|
|
518
|
-
│ │
|
|
519
|
-
▼ │
|
|
520
|
-
Dispatch sentinel-scan + guard ◄── Sentinel Protocol │
|
|
521
|
-
IN PARALLEL (both blocking) │
|
|
522
|
-
│ │
|
|
523
|
-
▼ │
|
|
524
|
-
Both return │
|
|
525
|
-
│ │
|
|
526
|
-
├── All clean → Present result to user │
|
|
527
|
-
└── Issues found → hydra-sentinel (deep analysis) │
|
|
528
|
-
→ Wait → Decision tree → Present to user │
|
|
529
|
-
│
|
|
530
|
-
Next wave OR present result ◄──────────────────────────►┘
|
|
531
|
-
(all parallel agents completed before this point)
|
|
532
|
-
```
|
|
533
|
-
|
|
534
|
-
### Optimization Interaction Rules
|
|
535
|
-
|
|
536
|
-
#### Rule 1: Session Index OVERRIDES Speculative Pre-Dispatch
|
|
537
|
-
When the Session Index already covers the relevant area, skip pre-dispatch entirely.
|
|
538
|
-
The index IS the scout output — use it directly and save the full scout dispatch time.
|
|
539
|
-
|
|
540
|
-
```
|
|
541
|
-
New prompt arrives → Check Session Index coverage
|
|
542
|
-
├── Covered: Use index → Skip scout → Wave 1 starts immediately
|
|
543
|
-
└── Not covered: Pre-dispatch scout → Update index → Wave 1 starts
|
|
544
|
-
```
|
|
545
|
-
|
|
546
|
-
#### Rule 2: Parallel + Auto-Accept = Zero-Overhead Path
|
|
547
|
-
When an agent runs in parallel with others AND its output qualifies for auto-accept:
|
|
548
|
-
- Dispatch it alongside other parallel agents
|
|
549
|
-
- When it returns: auto-accept without orchestrator review
|
|
550
|
-
- Append result to response (all parallel agents finish before the response is sent)
|
|
551
|
-
- **Total orchestrator overhead: 0 seconds**
|
|
552
|
-
|
|
553
|
-
This is the highest-throughput path. Common cases:
|
|
554
|
-
- Parallel hydra-runner (final validation) reporting all-pass → zero overhead
|
|
555
|
-
- Parallel hydra-scribe (internal docstrings) → zero overhead
|
|
556
|
-
- Parallel hydra-scout (supplementary context) → zero overhead, index updated
|
|
557
|
-
|
|
558
|
-
#### Rule 3: Auto-Accepted Scout Output ALWAYS Updates Session Index
|
|
559
|
-
Every scout output that passes auto-accept is immediately folded into the Session Index.
|
|
560
|
-
No separate step. The act of auto-accepting IS the index update.
|
|
561
|
-
|
|
562
|
-
#### Rule 4: Parallel Dispatch Does Not Override Verification Requirements
|
|
563
|
-
Parallel dispatch governs TIMING (run together), not VERIFICATION (do review).
|
|
564
|
-
If scribe writes user-facing docs (README, API docs), verification is still required —
|
|
565
|
-
it happens when all parallel agents complete, before the response is sent.
|
|
566
|
-
Opus always waits for every dispatched agent before presenting results.
|
|
567
|
-
|
|
568
|
-
### Timing Profile: Optimized vs Baseline
|
|
569
|
-
|
|
570
|
-
```
|
|
571
|
-
BASELINE (4-agent task, no optimizations):
|
|
572
|
-
t=0s Classify task [1s]
|
|
573
|
-
t=1s Dispatch scout, wait [3s]
|
|
574
|
-
t=4s Verify scout (manual) [1s]
|
|
575
|
-
t=5s Dispatch coder, wait [5s]
|
|
576
|
-
t=10s Verify coder (manual) [2s]
|
|
577
|
-
t=12s Dispatch runner + scribe, wait for BOTH [4s]
|
|
578
|
-
t=16s Verify scribe output (user-facing docs) [2s]
|
|
579
|
-
t=18s Present result
|
|
580
|
-
Total wall-clock: ~18 seconds
|
|
581
|
-
|
|
582
|
-
OPTIMIZED (all 4 optimizations active):
|
|
583
|
-
t=0s Pre-dispatch scout + classify (parallel) [3s max]
|
|
584
|
-
t=3s Scout auto-accepted, index built [0s overhead]
|
|
585
|
-
t=3s Dispatch coder (index context injected), wait [5s]
|
|
586
|
-
t=8s Quick-scan coder (code → verify) [1s]
|
|
587
|
-
t=9s Dispatch runner (parallel) + scribe (parallel) [3s — both run at once]
|
|
588
|
-
Scribe and runner run simultaneously, Opus waits for both
|
|
589
|
-
t=12s Runner: all-pass → auto-accept [0s overhead]
|
|
590
|
-
Scribe: internal docs → auto-accept [0s overhead]
|
|
591
|
-
t=12s Present result to user (single response, all outputs included)
|
|
592
|
-
Total wall-clock: ~12 seconds (33% faster, zero quality loss)
|
|
593
|
-
```
|
|
594
|
-
|
|
595
|
-
### Override Cases
|
|
596
|
-
|
|
597
|
-
Deviate from this model only when:
|
|
598
|
-
|
|
599
|
-
| Situation | Override |
|
|
600
|
-
|-----------|---------|
|
|
601
|
-
| User says "don't search" | Skip pre-dispatch; skip session index injection |
|
|
602
|
-
| Pure factual question (no codebase) | Skip all scout steps |
|
|
603
|
-
| Docs-only task | Make scribe BLOCKING (it's the primary deliverable) |
|
|
604
|
-
| Catastrophic test failure | Make final runner BLOCKING (something is fundamentally broken) |
|
|
605
|
-
| Stale Session Index detected | Rebuild index; treat as Turn 1 |
|
|
606
|
-
|
|
607
|
-
##
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
###
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
|
616
|
-
|
|
617
|
-
|
|
|
618
|
-
|
|
|
619
|
-
|
|
|
620
|
-
|
|
|
621
|
-
|
|
|
622
|
-
|
|
|
623
|
-
|
|
|
624
|
-
|
|
|
625
|
-
|
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
-
|
|
696
|
-
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
###
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
###
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
###
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
-
|
|
785
|
-
→
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
-
|
|
790
|
-
-
|
|
791
|
-
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
-
|
|
820
|
-
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
-
|
|
835
|
-
-
|
|
836
|
-
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
-
|
|
846
|
-
-
|
|
847
|
-
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
-
|
|
890
|
-
-
|
|
891
|
-
-
|
|
892
|
-
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
(
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
hydra-coder
|
|
921
|
-
hydra-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
###
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
-
|
|
946
|
-
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
|
981
|
-
|
|
982
|
-
|
|
|
983
|
-
|
|
|
984
|
-
|
|
|
985
|
-
|
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
The
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
When
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
If
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
- **
|
|
1149
|
-
- **
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
| Head | Model | Role | Tools |
|
|
1175
|
-
|------|-------|------|-------|
|
|
1176
|
-
| `hydra-scout` | 🟢 Haiku 4.5 | Codebase exploration, file search, reading, map building | Read, Grep, Glob, Bash, Write |
|
|
1177
|
-
| `hydra-runner` | 🟢 Haiku 4.5 | Test execution, builds, linting, validation | Read, Bash, Glob, Grep |
|
|
1178
|
-
| `hydra-scribe` | 🟢 Haiku 4.5 | Documentation, READMEs, comments, changelogs | Read, Write, Edit, Glob, Grep |
|
|
1179
|
-
| `hydra-guard` | 🟢 Haiku 4.5 | Security/quality gate after code changes | Read, Grep, Glob, Bash |
|
|
1180
|
-
| `hydra-git` | 🟢 Haiku 4.5 | Git operations: commit, branch, diff, log | Read, Bash, Glob, Grep |
|
|
1181
|
-
| `hydra-sentinel-scan` | 🟢 Haiku 4.5 | Fast integration sweep after code changes | Read, Grep, Glob |
|
|
1182
|
-
| `hydra-preflight` | 🟢 Haiku 4.5 | Environment detection, version probing, dep inventory | Read, Bash, Glob |
|
|
1183
|
-
| `hydra-coder` | 🔵 Sonnet 4.6 | Code writing, implementation, refactoring | Read, Write, Edit, Bash, Glob, Grep |
|
|
1184
|
-
| `hydra-analyst` | 🔵 Sonnet 4.6 | Code review, debugging, architecture analysis | Read, Grep, Glob, Bash |
|
|
1185
|
-
| `hydra-sentinel` | 🔵 Sonnet 4.6 | Deep integration analysis (when scan flags issues) | Read, Grep, Glob, Write |
|
|
1186
|
-
|
|
1187
|
-
## Measuring Impact
|
|
1188
|
-
|
|
1189
|
-
Track these mentally to calibrate:
|
|
1190
|
-
|
|
1191
|
-
- **Delegation rate**: What % of tasks go to heads? Target: 60–70%.
|
|
1192
|
-
- **Preflight rate**: Are you running `/hydra:preflight` on new projects? Target: 100% of new project sessions.
|
|
1193
|
-
- **Rejection rate**: How often does a draft need Opus intervention? Target: <15%.
|
|
1194
|
-
- **User complaints**: Zero. If the user notices quality issues, tune the classification.
|
|
1195
|
-
|
|
1196
|
-
If rejection rate > 20%, you're too aggressive — shift borderline tasks up one tier.
|
|
1197
|
-
If rejection rate < 5%, you're too conservative — delegate more.
|
|
1198
|
-
|
|
1199
|
-
## Task Completion Notification
|
|
1200
|
-
|
|
1201
|
-
After completing a user's task (the final response you present to the user),
|
|
1202
|
-
run this command as the LAST action:
|
|
1203
|
-
```bash
|
|
1204
|
-
node ~/.claude/hooks/hydra-notify.js < /dev/null
|
|
1205
|
-
```
|
|
1206
|
-
|
|
1207
|
-
This plays a short notification sound so the user knows you're done —
|
|
1208
|
-
especially useful when they've tabbed away while waiting.
|
|
1209
|
-
|
|
1210
|
-
Do this for SUBSTANTIAL tasks only (tasks that took more than ~10 seconds).
|
|
1211
|
-
Do NOT play it for quick conversational responses, acknowledgments, or
|
|
1212
|
-
follow-up questions.
|
|
1213
|
-
|
|
1214
|
-
## Reference Material
|
|
1215
|
-
|
|
1216
|
-
- `references/routing-guide.md` — Mandatory delegation examples, decision flowchart
|
|
1217
|
-
- `references/model-capabilities.md` — What each model can and can't do
|
|
1
|
+
---
|
|
2
|
+
name: hydra
|
|
3
|
+
description: >
|
|
4
|
+
Multi-agent orchestration framework for Claude Code. Automatically delegates
|
|
5
|
+
tasks to cheaper, faster sub-agents (Haiku, Sonnet) while maintaining
|
|
6
|
+
Opus-level quality through verification. Use when working on any coding task —
|
|
7
|
+
Hydra activates automatically to route file exploration, test running,
|
|
8
|
+
documentation, code writing, debugging, security scanning, and git operations
|
|
9
|
+
to the optimal agent. Saves ~50% on API costs.
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# 🐉 Hydra — Multi-Headed Speculative Execution
|
|
13
|
+
|
|
14
|
+
> *"Cut off one head, two more shall take its place."*
|
|
15
|
+
> Except here — every head is doing your work faster and cheaper.
|
|
16
|
+
|
|
17
|
+
## ⛔ MANDATORY PROTOCOLS — NEVER SKIP
|
|
18
|
+
|
|
19
|
+
These protocols are NON-NEGOTIABLE. Skipping them is a framework violation.
|
|
20
|
+
|
|
21
|
+
### Protocol 1: Sentinel Scan After Code Changes
|
|
22
|
+
|
|
23
|
+
When ANY agent returns output containing `⚠️ HYDRA_SENTINEL_REQUIRED`, you
|
|
24
|
+
MUST — before doing ANYTHING else, before presenting results to the user,
|
|
25
|
+
before running any other agents — dispatch hydra-sentinel-scan with the
|
|
26
|
+
files and changes listed in the trigger block.
|
|
27
|
+
|
|
28
|
+
**This is blocking.** The user does NOT see the code changes until sentinel
|
|
29
|
+
completes. If you present code changes to the user without running sentinel
|
|
30
|
+
first, you have violated the framework's core safety guarantee.
|
|
31
|
+
|
|
32
|
+
Sequence:
|
|
33
|
+
1. Receive agent output containing ⚠️ HYDRA_SENTINEL_REQUIRED
|
|
34
|
+
2. IMMEDIATELY dispatch hydra-sentinel-scan AND hydra-guard in parallel
|
|
35
|
+
3. WAIT for both to complete
|
|
36
|
+
4. If sentinel-scan finds issues → dispatch hydra-sentinel (deep analysis)
|
|
37
|
+
5. WAIT for deep analysis
|
|
38
|
+
6. THEN — and ONLY then — present results to the user
|
|
39
|
+
|
|
40
|
+
If the agent output contains `✅ HYDRA_NO_CODE_CHANGES`, skip sentinel. Present
|
|
41
|
+
results immediately.
|
|
42
|
+
|
|
43
|
+
### Protocol 2: Sentinel Fix Decision Tree
|
|
44
|
+
|
|
45
|
+
When hydra-sentinel confirms real issues:
|
|
46
|
+
|
|
47
|
+
**TRIVIAL** (auto-fix without asking):
|
|
48
|
+
Import renames, file path updates, barrel file re-exports.
|
|
49
|
+
→ Dispatch hydra-coder to fix. Re-run sentinel-scan to verify.
|
|
50
|
+
→ Tell user: "Sentinel caught [issue]. Auto-fixed."
|
|
51
|
+
|
|
52
|
+
**MEDIUM** (present to user, offer to fix):
|
|
53
|
+
API contract mismatches, missing env vars, signature mismatches.
|
|
54
|
+
→ Show the sentinel report. Ask: "Want me to fix these?"
|
|
55
|
+
|
|
56
|
+
**COMPLEX** (report only):
|
|
57
|
+
Architectural changes, migration needed, business logic decisions.
|
|
58
|
+
→ Show the report. Let user decide.
|
|
59
|
+
|
|
60
|
+
## Response Compression Protocol — Orchestrator
|
|
61
|
+
|
|
62
|
+
Apply light compression to your responses to the user. This is NOT
|
|
63
|
+
caveman-speak or fragmented language. Keep full grammar and natural prose.
|
|
64
|
+
Just remove waste.
|
|
65
|
+
|
|
66
|
+
### Drop These (Always)
|
|
67
|
+
|
|
68
|
+
- **Filler words**: just, really, basically, actually, simply, quite, very, totally
|
|
69
|
+
- **Pleasantries**: "Sure!", "Of course!", "Happy to help!", "Great question!"
|
|
70
|
+
- **Hedging**: "I think maybe", "It might be that", "Perhaps we could"
|
|
71
|
+
- **Throat-clearing**: "Let me explain...", "What I'll do is...", "Here's what I'll do..."
|
|
72
|
+
- **Signoffs**: "Let me know if you'd like me to adjust anything!", "Feel free to ask if...", "Hope this helps!"
|
|
73
|
+
- **Restating the question**: Don't repeat what the user asked back at them.
|
|
74
|
+
- **Apologetic preambles**: "Sorry for the confusion", "My apologies" (only apologize when you actually made an error, not as filler)
|
|
75
|
+
|
|
76
|
+
### Keep These (Always)
|
|
77
|
+
|
|
78
|
+
- Full grammar and articles (a, an, the)
|
|
79
|
+
- Natural sentence structure
|
|
80
|
+
- Code explanations when genuinely needed
|
|
81
|
+
- Reasoning when the user asks "why"
|
|
82
|
+
- Warnings about destructive operations
|
|
83
|
+
- Onboarding/learning explanations when the user is new to a concept
|
|
84
|
+
|
|
85
|
+
### Examples
|
|
86
|
+
|
|
87
|
+
**WRONG (verbose):**
|
|
88
|
+
> Sure! I'd be happy to help you fix that auth bug. Let me take a look at the
|
|
89
|
+
> code. Looking at this, I think the issue is that the token expiry check is
|
|
90
|
+
> using `<` instead of `<=`. I'll go ahead and fix that for you. Let me know
|
|
91
|
+
> if you'd like me to adjust anything!
|
|
92
|
+
|
|
93
|
+
**RIGHT (compressed):**
|
|
94
|
+
> The token expiry check uses `<` instead of `<=`. Fixing it now.
|
|
95
|
+
|
|
96
|
+
Same information. ~70% fewer tokens. User barely notices.
|
|
97
|
+
|
|
98
|
+
### Auto-Clarity — When to Drop Compression
|
|
99
|
+
|
|
100
|
+
Resume normal verbose prose for:
|
|
101
|
+
- **Security warnings** ("This will permanently delete...", "Cannot be undone")
|
|
102
|
+
- **Destructive operations** that need explicit user confirmation
|
|
103
|
+
- **Multi-step instructions** where compression risks misreading
|
|
104
|
+
- **User confused or asking follow-up clarification** — they need detail
|
|
105
|
+
- **Onboarding** — explaining new concepts the user is learning
|
|
106
|
+
|
|
107
|
+
Compression is for normal task completion. Anything safety-critical or educational gets full prose.
|
|
108
|
+
|
|
109
|
+
### What This Is NOT
|
|
110
|
+
|
|
111
|
+
This is not "caveman mode" or fragment-style. Don't drop articles. Don't write "Bug auth middleware. Token expiry use < not <=. Fix now." That's too aggressive — users WILL notice. Goal is invisible compression: a careful reader notices responses are tighter, but no average user complains it sounds robotic.
|
|
112
|
+
|
|
113
|
+
## Internal Thinking Compression — Subagents (v2.3.2+)
|
|
114
|
+
|
|
115
|
+
All Hydra subagents have an "Internal Thinking — Compressed" block in their system prompts. They run with terse internal reasoning by default. No setup required. Subagent context is now ~40–60% smaller per dispatch than v2.3.0, with no change to the final summary Opus receives.
|
|
116
|
+
|
|
117
|
+
The block tells each subagent: act first, skip preambles, no step announcements, no transition prose between tool calls, no restatement of tool outputs already in context. One-line decision notes at genuine branch points are still allowed.
|
|
118
|
+
|
|
119
|
+
### Calibration by Agent Type
|
|
120
|
+
|
|
121
|
+
**Simple agents** (hydra-scout, hydra-runner, hydra-git, hydra-scribe, hydra-guard, hydra-preflight): tools only, no internal prose at all. Tool call → next tool call → final summary.
|
|
122
|
+
|
|
123
|
+
**Reasoning agents** (hydra-analyst, hydra-sentinel, hydra-sentinel-scan, hydra-coder): compressed by default. Allowed to expand internal reasoning ONLY at genuine decision points (e.g., "3 fix approaches: A=simple, B=robust, C=invasive. Choosing B."). Never expand for "let me explain my thinking" — your thinking isn't read.
|
|
124
|
+
|
|
125
|
+
## STFU-Agents Mode — Universal Compression
|
|
126
|
+
|
|
127
|
+
For sessions with mixed subagent sources, the `stfu-agents` skill extends internal-thinking compression to ALL dispatched subagents — Hydra's, third-party, and Claude Code's built-in agents.
|
|
128
|
+
|
|
129
|
+
Activate via `/hydra:stfu`, `/skills stfu-agents`, or natural language ("STFU agents", "compress all agents"). Deactivate via `/skills` or "verbose agents". Opt-in only; never auto-activated.
|
|
130
|
+
|
|
131
|
+
When the skill is active, prepend the directive defined in `skills/stfu-agents/SKILL.md` to the `prompt` argument of every Task tool call. The directive is purely additive at runtime — no agent file modifications, no hooks. If a subagent ignores it, falls back to baseline behavior.
|
|
132
|
+
|
|
133
|
+
## Collaboration — Subagents (canonical)
|
|
134
|
+
|
|
135
|
+
Subagents may run in parallel with peers. Their output must be:
|
|
136
|
+
|
|
137
|
+
- **Self-contained** — no assumption that another agent's output is available; all needed context arrives in the prompt
|
|
138
|
+
- **Structured** — headers and sections so the orchestrator can merge results from multiple parallel agents
|
|
139
|
+
- **Focused** — work on the dispatched task only; flag adjacent issues to the orchestrator rather than acting on them
|
|
140
|
+
- **Actionable** — end with a clear summary the next wave's agents can use directly as context
|
|
141
|
+
|
|
142
|
+
Each agent file references this canonical block; the per-agent restatements were removed in v2.3.2 to reduce prompt bloat.
|
|
143
|
+
|
|
144
|
+
## Sentinel — Orchestrator-Side Cleanup
|
|
145
|
+
|
|
146
|
+
After hydra-sentinel-scan reports back (clean or issues found), the orchestrator (not the subagent) clears the sentinel-pending flag file used by the statusline indicator:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
rm -f /tmp/hydra-sentinel/${session_id}-pending.json
|
|
150
|
+
# Fallback when session_id is unavailable:
|
|
151
|
+
rm -f /tmp/hydra-sentinel/*-pending.json
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
This clears the "⚠ Sentinel pending" warning from the status bar. Moved from `agents/hydra-sentinel-scan.md` in v2.3.2 — subagent's job is the scan, orchestrator's job is the state cleanup.
|
|
155
|
+
|
|
156
|
+
## Why Hydra Exists
|
|
157
|
+
|
|
158
|
+
Autoregressive LLM inference is memory-bandwidth bound — the time per token scales with model
|
|
159
|
+
size regardless of task difficulty. Speculative decoding solves this at the token level by having a
|
|
160
|
+
small "draft" model propose tokens that a large "target" model verifies in parallel.
|
|
161
|
+
|
|
162
|
+
Hydra applies the same principle at the **task level**. Most coding tasks don't need the full
|
|
163
|
+
reasoning power of Opus. File searches, simple edits, test runs, documentation, boilerplate code —
|
|
164
|
+
these are "easy tokens" that a faster model handles just as well. By routing them to Haiku or Sonnet
|
|
165
|
+
heads and reserving Opus for genuinely hard problems, we get:
|
|
166
|
+
|
|
167
|
+
- **2–3× faster task completion** (Haiku responds ~10× faster than Opus)
|
|
168
|
+
- **~50% reduction in API costs** (Haiku is 5× cheaper per token than Opus)
|
|
169
|
+
- **Zero quality loss** on tasks within each model's capability band
|
|
170
|
+
|
|
171
|
+
## How Hydra Works — The Multi-Head Loop
|
|
172
|
+
|
|
173
|
+
```
|
|
174
|
+
User Request
|
|
175
|
+
│
|
|
176
|
+
├──────────────────────────────────────────────────────┐
|
|
177
|
+
│ │
|
|
178
|
+
▼ ▼
|
|
179
|
+
┌─────────────────────────────┐ ┌──────────────────────────────┐
|
|
180
|
+
│ 🧠 ORCHESTRATOR (Opus) │ │ 🟢 hydra-scout │
|
|
181
|
+
│ Classifies task │ │ IMMEDIATE pre-dispatch: │
|
|
182
|
+
│ Plans waves │ │ "Find files relevant to │
|
|
183
|
+
│ Decides blocking / not │ │ [user's request]" │
|
|
184
|
+
└────────┬────────────────────┘ └──────────────┬───────────────┘
|
|
185
|
+
│ (unless Session Index already covers) │
|
|
186
|
+
└──────────────────────┬──────────────────────────┘
|
|
187
|
+
│ (scout + classification both ready)
|
|
188
|
+
[Session Index updated]
|
|
189
|
+
│
|
|
190
|
+
════════════════════════════════════════════════════════
|
|
191
|
+
Wave N (parallel dispatch, index context injected)
|
|
192
|
+
┌───────────────────┬──────────────────────────────────┐
|
|
193
|
+
│ SEQUENTIAL │ PARALLEL (wait for all) │
|
|
194
|
+
▼ ▼ │
|
|
195
|
+
[coder] [scribe] ──────────────────────────────┘
|
|
196
|
+
│
|
|
197
|
+
▼
|
|
198
|
+
ALL agents complete (Opus waits for every dispatched agent)
|
|
199
|
+
│
|
|
200
|
+
├── Raw data / clean pass? → AUTO-ACCEPT → (updates Session Index if scout)
|
|
201
|
+
└── Code / analysis / user-facing docs? → Orchestrator verifies
|
|
202
|
+
│
|
|
203
|
+
▼
|
|
204
|
+
User gets result (single response, all agent outputs included)
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
This mirrors speculative decoding's "draft → score → accept/reject" loop, but at task granularity.
|
|
208
|
+
|
|
209
|
+
## Speculative Pre-Dispatch
|
|
210
|
+
|
|
211
|
+
When a user prompt arrives, launch hydra-scout IMMEDIATELY before classifying the task.
|
|
212
|
+
|
|
213
|
+
### Why
|
|
214
|
+
Every task — Tier 1, 2, or 3 — benefits from codebase context. Scout's output is never
|
|
215
|
+
wasted. By the time you finish classifying the task and deciding which agents to dispatch,
|
|
216
|
+
scout has already returned with relevant file paths, project structure, and code context.
|
|
217
|
+
|
|
218
|
+
### Protocol
|
|
219
|
+
1. User prompt arrives
|
|
220
|
+
2. IMMEDIATELY dispatch hydra-scout with: "Find all files and code relevant to: [user's request]"
|
|
221
|
+
3. IN PARALLEL, classify the task into Tier 1/2/3 and plan your waves
|
|
222
|
+
4. When scout returns + classification is done, dispatch the execution wave with scout's
|
|
223
|
+
context already available
|
|
224
|
+
5. If the task turns out to be pure exploration (Tier 1 scout-only), scout's output IS
|
|
225
|
+
the result — zero additional dispatch needed
|
|
226
|
+
|
|
227
|
+
### Timing Advantage
|
|
228
|
+
Without pre-dispatch: [classify: 2s] → [dispatch scout: 3s] → [dispatch coder: 5s] = 10s
|
|
229
|
+
With pre-dispatch: [classify: 2s ↔ scout: 3s (parallel)] → [dispatch coder: 5s] = 8s
|
|
230
|
+
Saved: 2-3 seconds per task (20-30% of overhead)
|
|
231
|
+
|
|
232
|
+
### When NOT to pre-dispatch
|
|
233
|
+
- User explicitly says "don't search" or "just do X directly"
|
|
234
|
+
- The task is a continuation of the immediately previous turn where context is already loaded
|
|
235
|
+
- The prompt is a simple question answerable without codebase context (e.g., "what does REST stand for?")
|
|
236
|
+
|
|
237
|
+
## Session Index
|
|
238
|
+
|
|
239
|
+
After the first hydra-scout dispatch in a session, build a persistent mental index of
|
|
240
|
+
the project. Update it as new information is discovered. Pass relevant slices of this
|
|
241
|
+
index to every agent dispatch so they skip cold-start exploration.
|
|
242
|
+
|
|
243
|
+
### Index Contents
|
|
244
|
+
Maintain these fields mentally throughout the session:
|
|
245
|
+
|
|
246
|
+
- **Tech Stack**: Language, framework, package manager, key dependencies
|
|
247
|
+
- **Project Layout**: Top-level directory structure and what each directory contains
|
|
248
|
+
- **Key Files**: Entry points, config files, test setup, CI config, main modules
|
|
249
|
+
- **Test Command**: The exact command to run tests (e.g., `pytest`, `npm test`)
|
|
250
|
+
- **Build Command**: The exact command to build (e.g., `npm run build`, `cargo build`)
|
|
251
|
+
- **Conventions**: Naming patterns, file organization style, import conventions observed
|
|
252
|
+
|
|
253
|
+
### Usage Rules
|
|
254
|
+
1. Build the index after the FIRST scout dispatch in a session
|
|
255
|
+
2. On subsequent prompts, check if the index already covers what scout would find
|
|
256
|
+
3. If yes — skip scout, inject index context directly into the execution agent's prompt
|
|
257
|
+
4. If no (user asks about a NEW area of the codebase) — dispatch scout for that
|
|
258
|
+
specific area only, then update the index
|
|
259
|
+
5. Always pass the relevant slice of the index to dispatched agents:
|
|
260
|
+
- hydra-coder gets: tech stack, conventions, relevant file paths
|
|
261
|
+
- hydra-runner gets: test command, build command
|
|
262
|
+
- hydra-scribe gets: project layout, conventions, existing docs
|
|
263
|
+
- hydra-analyst gets: tech stack, key files, project layout
|
|
264
|
+
|
|
265
|
+
### Speed Impact
|
|
266
|
+
- Turn 1: Normal speed (scout runs, index is built)
|
|
267
|
+
- Turn 2+: Scout is SKIPPED for known areas → saves 2-4 seconds per turn
|
|
268
|
+
- Over a 10-turn session: ~20-40 seconds saved total
|
|
269
|
+
|
|
270
|
+
### Index Invalidation
|
|
271
|
+
The index is stale if:
|
|
272
|
+
- The user explicitly changes the project structure
|
|
273
|
+
- A major refactoring was just completed
|
|
274
|
+
- The user switches to a different project/directory
|
|
275
|
+
When stale, rebuild the index on the next scout dispatch.
|
|
276
|
+
|
|
277
|
+
## Codebase Map — Orchestrator Protocol
|
|
278
|
+
|
|
279
|
+
Hydra maintains a codebase map at `.claude/hydra/codebase-map.json`. This map
|
|
280
|
+
is built and maintained by hydra-scout. It contains file dependencies, blast
|
|
281
|
+
radius data, risk scores, env var references, and test coverage.
|
|
282
|
+
|
|
283
|
+
### Session Start — Map Check
|
|
284
|
+
|
|
285
|
+
At the start of EVERY session, before any work:
|
|
286
|
+
|
|
287
|
+
1. Check if `.claude/hydra/codebase-map.json` exists.
|
|
288
|
+
2. If yes: read the `_meta` section. Check if `git_hash` matches current HEAD.
|
|
289
|
+
- If current: map is ready. Note this internally.
|
|
290
|
+
- If stale: dispatch hydra-scout to do an incremental update before proceeding.
|
|
291
|
+
3. If no: dispatch hydra-scout to build the map on the first exploration task.
|
|
292
|
+
Don't block the session — but prioritize building the map early.
|
|
293
|
+
|
|
294
|
+
### Risk-Based Sentinel Triggering
|
|
295
|
+
|
|
296
|
+
Use the map's risk scores to decide sentinel behavior:
|
|
297
|
+
|
|
298
|
+
| Modified File Risk | Sentinel Behavior |
|
|
299
|
+
|-------------------|-------------------|
|
|
300
|
+
| `critical` (7+ dependents) | ALWAYS run sentinel-scan, ALWAYS escalate to deep |
|
|
301
|
+
| `high` (4-6 dependents) | ALWAYS run sentinel-scan, escalate if issues found |
|
|
302
|
+
| `medium` (2-3 dependents) | Run sentinel-scan, escalate only if P0 issues found |
|
|
303
|
+
| `low` (0-1 dependents) | Run sentinel-scan, but auto-accept if clean |
|
|
304
|
+
|
|
305
|
+
This replaces the previous "always run sentinel-scan the same way" approach
|
|
306
|
+
with risk-proportional verification.
|
|
307
|
+
|
|
308
|
+
### When Dispatching Sentinel-Scan
|
|
309
|
+
|
|
310
|
+
Include the map's relevant data in the task description:
|
|
311
|
+
- The blast radius for the changed files (from the map)
|
|
312
|
+
- The risk score of each changed file
|
|
313
|
+
- The test coverage status of each changed file
|
|
314
|
+
- Any env vars referenced by the changed files
|
|
315
|
+
|
|
316
|
+
This gives sentinel-scan a head start — it doesn't need to compute the
|
|
317
|
+
blast radius itself, the map already has it.
|
|
318
|
+
|
|
319
|
+
### Map Staleness
|
|
320
|
+
|
|
321
|
+
If you notice the map's git_hash doesn't match HEAD and hydra-scout hasn't
|
|
322
|
+
been dispatched yet, dispatch scout to update the map BEFORE running sentinel.
|
|
323
|
+
A stale map is worse than no map — it could have incorrect dependency data.
|
|
324
|
+
|
|
325
|
+
## Preflight Protocol — /hydra:preflight
|
|
326
|
+
|
|
327
|
+
Run this before starting work on any new project or unfamiliar codebase.
|
|
328
|
+
It catches environment and compatibility issues before they become multi-hour
|
|
329
|
+
debugging sessions.
|
|
330
|
+
|
|
331
|
+
### When to run
|
|
332
|
+
|
|
333
|
+
- User types `hydra preflight` or `/hydra:preflight`
|
|
334
|
+
- User says "check my environment", "validate my setup", "is this project ready to build"
|
|
335
|
+
- You are about to begin a substantial build task on a project you have not seen before
|
|
336
|
+
in this session AND the Session Index has no prior context for this project
|
|
337
|
+
|
|
338
|
+
### Execution — Two Phases, Always in Sequence
|
|
339
|
+
|
|
340
|
+
**Phase 1 (Detection) — dispatch hydra-preflight:**
|
|
341
|
+
|
|
342
|
+
Prompt:
|
|
343
|
+
|
|
344
|
+
```
|
|
345
|
+
Run a full preflight check on this project. Collect runtime versions, run all
|
|
346
|
+
GPU/CUDA probe scripts, inventory installed packages, compare .env.example against
|
|
347
|
+
.env, verify build tools exist, and check service connectivity. Return the full
|
|
348
|
+
structured PREFLIGHT_INVENTORY JSON. Do not make recommendations.
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
Wait for hydra-preflight to return `PREFLIGHT_INVENTORY_COMPLETE` before proceeding.
|
|
352
|
+
|
|
353
|
+
**Phase 2 (Analysis) — dispatch hydra-analyst:**
|
|
354
|
+
|
|
355
|
+
Pass the full PREFLIGHT_INVENTORY from Phase 1. Prompt:
|
|
356
|
+
|
|
357
|
+
```
|
|
358
|
+
You are performing a compatibility analysis on the following environment inventory.
|
|
359
|
+
Cross-reference all detected versions against known compatibility matrices.
|
|
360
|
+
Pay special attention to GPU stack combinations (PyTorch/CUDA/cuDNN),
|
|
361
|
+
framework pairs (React/Next, Python/TF), and Node/native addon combinations.
|
|
362
|
+
|
|
363
|
+
For each component or pair, return one of three verdicts:
|
|
364
|
+
✅ COMPATIBLE — versions are known-good together
|
|
365
|
+
⚠️ KNOWN RISK — this combination has known issues or is untested
|
|
366
|
+
❌ CONFIRMED BREAK — probe output or known matrix confirms incompatibility
|
|
367
|
+
|
|
368
|
+
For ❌ verdicts, include the specific fix (e.g. "pin pytorch==2.7.0").
|
|
369
|
+
For ⚠️ verdicts, include what to watch for.
|
|
370
|
+
For unknowns, flag as "UNVERIFIED — test before building" rather than assuming green.
|
|
371
|
+
|
|
372
|
+
INVENTORY:
|
|
373
|
+
[paste full PREFLIGHT_INVENTORY here]
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
### Presenting Results to User
|
|
377
|
+
|
|
378
|
+
After both phases complete, present a unified report:
|
|
379
|
+
|
|
380
|
+
```
|
|
381
|
+
🐉 Hydra Preflight — [project name]
|
|
382
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
383
|
+
|
|
384
|
+
RUNTIMES
|
|
385
|
+
✅ Node 22.4.0 (matches .nvmrc)
|
|
386
|
+
✅ Python 3.11.9 (matches .python-version)
|
|
387
|
+
|
|
388
|
+
GPU STACK
|
|
389
|
+
❌ PyTorch 2.6.0 + CUDA 13.0 — incompatible
|
|
390
|
+
Fix: pip install torch==2.7.0
|
|
391
|
+
|
|
392
|
+
ENVIRONMENT
|
|
393
|
+
⚠️ Missing: DATABASE_URL, REDIS_URL (declared in .env.example)
|
|
394
|
+
|
|
395
|
+
DEPENDENCIES
|
|
396
|
+
✅ node_modules present (1,847 packages)
|
|
397
|
+
✅ venv present
|
|
398
|
+
|
|
399
|
+
SERVICES
|
|
400
|
+
❌ PostgreSQL: unreachable (DATABASE_URL not set)
|
|
401
|
+
✅ Redis: reachable
|
|
402
|
+
|
|
403
|
+
BUILD TOOLS
|
|
404
|
+
✅ vite, tsc, pytest all found
|
|
405
|
+
|
|
406
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
407
|
+
2 confirmed breaks, 1 known risk, 1 warning
|
|
408
|
+
Fix the ❌ items before building.
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
Auto-apply trivial fixes (e.g. updating a pin in requirements.txt) only if the user
|
|
412
|
+
says "fix it" or "apply fixes". Never auto-apply without being asked.
|
|
413
|
+
|
|
414
|
+
### Three-State Verdict Reference
|
|
415
|
+
|
|
416
|
+
| State | Meaning | Source |
|
|
417
|
+
|-------|---------|--------|
|
|
418
|
+
| ✅ COMPATIBLE | Versions are known-good together | Analyst matrix knowledge |
|
|
419
|
+
| ⚠️ KNOWN RISK | Combination has known issues or limited testing | Analyst matrix knowledge |
|
|
420
|
+
| ❌ CONFIRMED BREAK | Probe output OR known matrix confirms failure | Probe output (ground truth) or analyst |
|
|
421
|
+
| ❓ UNVERIFIED | Combination not in training data | Analyst — flag and move on |
|
|
422
|
+
|
|
423
|
+
Ground truth from probes always beats matrix knowledge. If `torch.cuda.is_available()`
|
|
424
|
+
returns False, that is a ❌ regardless of what the version matrix says.
|
|
425
|
+
|
|
426
|
+
## Sequential vs Parallel Dispatch
|
|
427
|
+
|
|
428
|
+
Not all agents need to be dispatched one-by-one. When agents are independent,
|
|
429
|
+
dispatch them simultaneously and wait for ALL to complete before responding.
|
|
430
|
+
|
|
431
|
+
> ⚠️ **NEVER use fire-and-forget or background dispatch.** Background agent
|
|
432
|
+
> completion triggers an empty user turn in Claude Code, causing Claude to respond
|
|
433
|
+
> to nothing. Every dispatched agent MUST be awaited before presenting results.
|
|
434
|
+
|
|
435
|
+
### Sequential Dispatch (one wave at a time)
|
|
436
|
+
Use when downstream agents DEPEND on this agent's output:
|
|
437
|
+
- hydra-scout exploring files that hydra-coder needs to edit
|
|
438
|
+
- hydra-analyst diagnosing a bug that hydra-coder needs to fix
|
|
439
|
+
- hydra-coder making changes that hydra-runner needs to test
|
|
440
|
+
|
|
441
|
+
### Parallel Dispatch (all at once — wait for ALL before responding)
|
|
442
|
+
Use when agents are INDEPENDENT of each other:
|
|
443
|
+
- hydra-scribe writing docs + hydra-runner running final tests
|
|
444
|
+
- hydra-guard scanning + hydra-sentinel-scan sweeping (already enforced by Protocol 1)
|
|
445
|
+
- hydra-scout exploring supplementary context + any other independent agent
|
|
446
|
+
|
|
447
|
+
### Execution Flow
|
|
448
|
+
|
|
449
|
+
```
|
|
450
|
+
Wave 1 (sequential): scout explores → returns file paths
|
|
451
|
+
Wave 2 (sequential): coder implements fix → returns changed files
|
|
452
|
+
Wave 3 (parallel): dispatch runner AND scribe simultaneously
|
|
453
|
+
WAIT for BOTH to complete
|
|
454
|
+
Present single response to user (all outputs included)
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
### Rules
|
|
458
|
+
1. A wave completes when ALL agents in it return — no exceptions
|
|
459
|
+
2. NEVER present results while any dispatched agent is still running
|
|
460
|
+
3. NEVER dispatch hydra-coder without awaiting the result — code changes always need verification
|
|
461
|
+
4. NEVER dispatch hydra-analyst without awaiting the result — diagnoses feed into fixes
|
|
462
|
+
5. hydra-scribe runs IN PARALLEL with hydra-runner by default (not after)
|
|
463
|
+
6. If in doubt, wait for everything — correctness over speed
|
|
464
|
+
|
|
465
|
+
## Integrated Execution Model
|
|
466
|
+
|
|
467
|
+
All four optimizations compose into a unified execution loop. This section shows how
|
|
468
|
+
they interact as a single coherent system.
|
|
469
|
+
|
|
470
|
+
### Full Execution Flow
|
|
471
|
+
|
|
472
|
+
```
|
|
473
|
+
User Prompt arrives
|
|
474
|
+
│
|
|
475
|
+
├── Session Index covers this area? ─── YES ──► Skip scout; inject index context
|
|
476
|
+
│ │ into execution wave directly ──►──┐
|
|
477
|
+
│ NO │
|
|
478
|
+
│ ▼ │
|
|
479
|
+
├── IMMEDIATELY dispatch hydra-scout ◄── Opt 1: Speculative Pre-Dispatch
|
|
480
|
+
│ "Find files relevant to: [prompt]" │
|
|
481
|
+
│ │
|
|
482
|
+
├── IN PARALLEL: Classify task, plan waves, │
|
|
483
|
+
│ decide sequential/parallel per agent │
|
|
484
|
+
│ │
|
|
485
|
+
▼ │
|
|
486
|
+
Scout returns │
|
|
487
|
+
│ │
|
|
488
|
+
├── AUTO-ACCEPT scout output ─────────────────── ◄── Opt 4: Confidence Auto-Accept │
|
|
489
|
+
│ Update Session Index with new findings ──────◄── Opt 2: Session Index │
|
|
490
|
+
│ │
|
|
491
|
+
└─────────────────────────────────────────────────────────────────────────────►───┘
|
|
492
|
+
│
|
|
493
|
+
▼
|
|
494
|
+
Wave N dispatched
|
|
495
|
+
(index context injected into each agent prompt)
|
|
496
|
+
│
|
|
497
|
+
┌────────────────────┴───────────────────────┐
|
|
498
|
+
│ SEQUENTIAL agents ◄── Opt 3: Parallel │ PARALLEL agents
|
|
499
|
+
│ (one wave at a time) │ (dispatched together)
|
|
500
|
+
▼ ▼
|
|
501
|
+
Results arrive All complete together
|
|
502
|
+
│ │
|
|
503
|
+
┌──────┴──────┐ │
|
|
504
|
+
│ │ │
|
|
505
|
+
▼ ▼ │
|
|
506
|
+
AUTO-ACCEPT? MANUAL VERIFY? ◄── Opt 4: Auto-Accept │
|
|
507
|
+
│ │ │
|
|
508
|
+
▼ ▼ │
|
|
509
|
+
Pass through Orchestrator │
|
|
510
|
+
directly reviews │
|
|
511
|
+
│ │ │
|
|
512
|
+
└──────┬──────┘ │
|
|
513
|
+
│ │
|
|
514
|
+
▼ │
|
|
515
|
+
Was this a CODE CHANGE? │
|
|
516
|
+
│ │ │
|
|
517
|
+
YES NO ── Present result immediately ──►───┘
|
|
518
|
+
│ │
|
|
519
|
+
▼ │
|
|
520
|
+
Dispatch sentinel-scan + guard ◄── Sentinel Protocol │
|
|
521
|
+
IN PARALLEL (both blocking) │
|
|
522
|
+
│ │
|
|
523
|
+
▼ │
|
|
524
|
+
Both return │
|
|
525
|
+
│ │
|
|
526
|
+
├── All clean → Present result to user │
|
|
527
|
+
└── Issues found → hydra-sentinel (deep analysis) │
|
|
528
|
+
→ Wait → Decision tree → Present to user │
|
|
529
|
+
│
|
|
530
|
+
Next wave OR present result ◄──────────────────────────►┘
|
|
531
|
+
(all parallel agents completed before this point)
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
### Optimization Interaction Rules
|
|
535
|
+
|
|
536
|
+
#### Rule 1: Session Index OVERRIDES Speculative Pre-Dispatch
|
|
537
|
+
When the Session Index already covers the relevant area, skip pre-dispatch entirely.
|
|
538
|
+
The index IS the scout output — use it directly and save the full scout dispatch time.
|
|
539
|
+
|
|
540
|
+
```
|
|
541
|
+
New prompt arrives → Check Session Index coverage
|
|
542
|
+
├── Covered: Use index → Skip scout → Wave 1 starts immediately
|
|
543
|
+
└── Not covered: Pre-dispatch scout → Update index → Wave 1 starts
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
#### Rule 2: Parallel + Auto-Accept = Zero-Overhead Path
|
|
547
|
+
When an agent runs in parallel with others AND its output qualifies for auto-accept:
|
|
548
|
+
- Dispatch it alongside other parallel agents
|
|
549
|
+
- When it returns: auto-accept without orchestrator review
|
|
550
|
+
- Append result to response (all parallel agents finish before the response is sent)
|
|
551
|
+
- **Total orchestrator overhead: 0 seconds**
|
|
552
|
+
|
|
553
|
+
This is the highest-throughput path. Common cases:
|
|
554
|
+
- Parallel hydra-runner (final validation) reporting all-pass → zero overhead
|
|
555
|
+
- Parallel hydra-scribe (internal docstrings) → zero overhead
|
|
556
|
+
- Parallel hydra-scout (supplementary context) → zero overhead, index updated
|
|
557
|
+
|
|
558
|
+
#### Rule 3: Auto-Accepted Scout Output ALWAYS Updates Session Index
|
|
559
|
+
Every scout output that passes auto-accept is immediately folded into the Session Index.
|
|
560
|
+
No separate step. The act of auto-accepting IS the index update.
|
|
561
|
+
|
|
562
|
+
#### Rule 4: Parallel Dispatch Does Not Override Verification Requirements
|
|
563
|
+
Parallel dispatch governs TIMING (run together), not VERIFICATION (do review).
|
|
564
|
+
If scribe writes user-facing docs (README, API docs), verification is still required —
|
|
565
|
+
it happens when all parallel agents complete, before the response is sent.
|
|
566
|
+
Opus always waits for every dispatched agent before presenting results.
|
|
567
|
+
|
|
568
|
+
### Timing Profile: Optimized vs Baseline
|
|
569
|
+
|
|
570
|
+
```
|
|
571
|
+
BASELINE (4-agent task, no optimizations):
|
|
572
|
+
t=0s Classify task [1s]
|
|
573
|
+
t=1s Dispatch scout, wait [3s]
|
|
574
|
+
t=4s Verify scout (manual) [1s]
|
|
575
|
+
t=5s Dispatch coder, wait [5s]
|
|
576
|
+
t=10s Verify coder (manual) [2s]
|
|
577
|
+
t=12s Dispatch runner + scribe, wait for BOTH [4s]
|
|
578
|
+
t=16s Verify scribe output (user-facing docs) [2s]
|
|
579
|
+
t=18s Present result
|
|
580
|
+
Total wall-clock: ~18 seconds
|
|
581
|
+
|
|
582
|
+
OPTIMIZED (all 4 optimizations active):
|
|
583
|
+
t=0s Pre-dispatch scout + classify (parallel) [3s max]
|
|
584
|
+
t=3s Scout auto-accepted, index built [0s overhead]
|
|
585
|
+
t=3s Dispatch coder (index context injected), wait [5s]
|
|
586
|
+
t=8s Quick-scan coder (code → verify) [1s]
|
|
587
|
+
t=9s Dispatch runner (parallel) + scribe (parallel) [3s — both run at once]
|
|
588
|
+
Scribe and runner run simultaneously, Opus waits for both
|
|
589
|
+
t=12s Runner: all-pass → auto-accept [0s overhead]
|
|
590
|
+
Scribe: internal docs → auto-accept [0s overhead]
|
|
591
|
+
t=12s Present result to user (single response, all outputs included)
|
|
592
|
+
Total wall-clock: ~12 seconds (33% faster, zero quality loss)
|
|
593
|
+
```
|
|
594
|
+
|
|
595
|
+
### Override Cases
|
|
596
|
+
|
|
597
|
+
Deviate from this model only when:
|
|
598
|
+
|
|
599
|
+
| Situation | Override |
|
|
600
|
+
|-----------|---------|
|
|
601
|
+
| User says "don't search" | Skip pre-dispatch; skip session index injection |
|
|
602
|
+
| Pure factual question (no codebase) | Skip all scout steps |
|
|
603
|
+
| Docs-only task | Make scribe BLOCKING (it's the primary deliverable) |
|
|
604
|
+
| Catastrophic test failure | Make final runner BLOCKING (something is fundamentally broken) |
|
|
605
|
+
| Stale Session Index detected | Rebuild index; treat as Turn 1 |
|
|
606
|
+
|
|
607
|
+
## What Hydra Offers
|
|
608
|
+
|
|
609
|
+
Hydra is a curated toolkit of specialized agents and slash commands. Use its capabilities when they genuinely help — not as a forced routing layer.
|
|
610
|
+
|
|
611
|
+
### Slash Commands (User-Invoked)
|
|
612
|
+
|
|
613
|
+
The user can run any of these directly. Don't pre-invoke them on the user's behalf unless they ask:
|
|
614
|
+
|
|
615
|
+
| Command | Purpose |
|
|
616
|
+
|---------|---------|
|
|
617
|
+
| `/hydra:scout` | Codebase exploration via hydra-scout (Haiku) |
|
|
618
|
+
| `/hydra:guard` | Security scan via hydra-guard (Haiku) |
|
|
619
|
+
| `/hydra:preflight` | Environment validation via hydra-preflight + hydra-analyst |
|
|
620
|
+
| `/hydra:stats` | Real token usage and savings from current session |
|
|
621
|
+
| `/hydra:stfu` | Compress internal reasoning across all subagent dispatches |
|
|
622
|
+
| `/hydra:status` | Framework health check |
|
|
623
|
+
| `/hydra:help` | Command reference |
|
|
624
|
+
| `/hydra:map` | Codebase map summary or rebuild |
|
|
625
|
+
| `/hydra:report` | Submit feedback to maintainers |
|
|
626
|
+
| `/hydra:update` | Update Hydra to latest version |
|
|
627
|
+
| `/hydra:config` | View configuration |
|
|
628
|
+
| `/hydra:quiet` / `/hydra:verbose` | Toggle dispatch log verbosity |
|
|
629
|
+
|
|
630
|
+
### Subagents Available for Dispatch (When Genuinely Useful)
|
|
631
|
+
|
|
632
|
+
When a task genuinely benefits from specialized handling, dispatch these agents via the Task tool. Use judgment — for trivial tasks, handling them directly is often more efficient than the dispatch overhead.
|
|
633
|
+
|
|
634
|
+
- **hydra-scout** (Haiku): Multi-file codebase exploration when scope is broad
|
|
635
|
+
- **hydra-runner** (Haiku): Test/build execution that could run in parallel
|
|
636
|
+
- **hydra-coder** (Sonnet): Code changes across 3+ files where parallel dispatch saves real time
|
|
637
|
+
- **hydra-analyst** (Sonnet): Debugging or analysis requiring focused context
|
|
638
|
+
- **hydra-sentinel** (Sonnet): Deep integration analysis after substantial changes
|
|
639
|
+
- **hydra-sentinel-scan** (Haiku): Fast post-change verification — see Auto-Verification below
|
|
640
|
+
|
|
641
|
+
**Key principle:** Dispatch when the task is substantial enough that the subagent overhead is justified by cheaper-model savings, parallelization, or focused context windows. For small tasks (single-file reads, one-line edits, quick conversations), handling them yourself is the right call.
|
|
642
|
+
|
|
643
|
+
### Auto-Verification (The One Automatic Touchpoint)
|
|
644
|
+
|
|
645
|
+
The hydra-auto-guard hook tracks file changes during the session. After **substantial** code edits (new file writes, MultiEdit batches, or edits modifying more than ~5 lines / 200 chars), the hook injects a directive recommending dispatch of hydra-sentinel-scan for integration verification.
|
|
646
|
+
|
|
647
|
+
Comply with that directive when it appears — post-change verification catches bugs the orchestrator alone often misses. This is the one place where Hydra actively nudges regardless of explicit user request.
|
|
648
|
+
|
|
649
|
+
For trivial edits the hook stays silent.
|
|
650
|
+
|
|
651
|
+
## Plan Mode Behavior
|
|
652
|
+
|
|
653
|
+
During planning phase (before execution begins):
|
|
654
|
+
- Using Claude Code's built-in Explore agent is acceptable for quick codebase understanding.
|
|
655
|
+
|
|
656
|
+
Once execution begins (after plan is approved):
|
|
657
|
+
- Dispatch Hydra agents where they pay off (see "What Hydra Offers" above). Don't force dispatch for trivial tasks.
|
|
658
|
+
- Plans may reference specific Hydra agents when helpful. Example format:
|
|
659
|
+
|
|
660
|
+
```
|
|
661
|
+
Step 1: hydra-scout → read auth module structure [parallel with Step 2]
|
|
662
|
+
Step 2: hydra-runner → run existing test suite [parallel with Step 1]
|
|
663
|
+
Step 3: hydra-coder → implement fix using findings from Steps 1-2
|
|
664
|
+
Step 4: hydra-sentinel-scan → verify changes
|
|
665
|
+
Step 5: hydra-runner → run tests to confirm fix
|
|
666
|
+
Step 6: hydra-git → commit with descriptive message
|
|
667
|
+
```
|
|
668
|
+
|
|
669
|
+
## Dispatch Logging
|
|
670
|
+
|
|
671
|
+
After every task completion that involves Hydra subagent dispatches (unless `/hydra:quiet` is active), show a dispatch summary:
|
|
672
|
+
|
|
673
|
+
```
|
|
674
|
+
| Step | Agent | Task | Time |
|
|
675
|
+
|------|-------|------|------|
|
|
676
|
+
| 1 | hydra-scout | Explore auth module | 3.2s |
|
|
677
|
+
| 2 | hydra-runner | Run test suite | 5.1s |
|
|
678
|
+
| 3 | hydra-coder | Fix auth bug | 8.4s |
|
|
679
|
+
| 4 | hydra-guard | Security scan | 2.1s |
|
|
680
|
+
| 5 | hydra-runner | Verify fix | 4.8s |
|
|
681
|
+
```
|
|
682
|
+
|
|
683
|
+
When no dispatches occurred in a turn, no log is shown.
|
|
684
|
+
|
|
685
|
+
## Verification Protocol
|
|
686
|
+
|
|
687
|
+
After an agent returns, determine whether to auto-accept or manually verify.
|
|
688
|
+
|
|
689
|
+
### Auto-Accept (skip verification entirely)
|
|
690
|
+
These output types require no orchestrator judgment — accept and pass through:
|
|
691
|
+
|
|
692
|
+
| Agent | Auto-Accept When |
|
|
693
|
+
|-------|-----------------|
|
|
694
|
+
| hydra-scout | Returns file paths, directory listings, search results, grep output — factual data with no interpretation |
|
|
695
|
+
| hydra-runner | Reports all tests passing, clean build, clean lint — unambiguous pass/fail |
|
|
696
|
+
| hydra-scribe | Produces docs/comments for NON-CRITICAL content (internal docstrings, changelogs) |
|
|
697
|
+
| hydra-sentinel-scan | Returns `"status": "clean"` — no issues found |
|
|
698
|
+
|
|
699
|
+
### Manual Verify (orchestrator reviews before accepting)
|
|
700
|
+
These outputs require judgment — scan before passing to user or downstream agents:
|
|
701
|
+
|
|
702
|
+
| Agent | Always Verify When |
|
|
703
|
+
|-------|-------------------|
|
|
704
|
+
| hydra-coder | ALWAYS — code changes are never auto-accepted |
|
|
705
|
+
| hydra-analyst | ALWAYS — diagnoses and recommendations need validation |
|
|
706
|
+
| hydra-runner | Reports test FAILURES — verify the failures are real and not environment issues |
|
|
707
|
+
| hydra-scribe | Writing user-facing docs (README, API docs) — verify accuracy |
|
|
708
|
+
| hydra-scout | Returns analysis or interpretation (not raw data) — verify conclusions |
|
|
709
|
+
| hydra-sentinel-scan | Returns `"status": "issues_found"` — escalate to hydra-sentinel |
|
|
710
|
+
| hydra-sentinel | ALWAYS — integration analysis requires orchestrator judgment |
|
|
711
|
+
|
|
712
|
+
### Verification Decision Flowchart
|
|
713
|
+
|
|
714
|
+
```
|
|
715
|
+
Agent returns output
|
|
716
|
+
│
|
|
717
|
+
├── Is it raw factual data? (file paths, test pass, grep results)
|
|
718
|
+
│ → AUTO-ACCEPT. Zero overhead.
|
|
719
|
+
│
|
|
720
|
+
├── Is it code changes?
|
|
721
|
+
│ → ALWAYS VERIFY. Scan for correctness, edge cases.
|
|
722
|
+
│
|
|
723
|
+
├── Is it analysis/diagnosis/recommendation?
|
|
724
|
+
│ → ALWAYS VERIFY. Check reasoning, validate conclusions.
|
|
725
|
+
│
|
|
726
|
+
├── Is it documentation?
|
|
727
|
+
│ ├── Internal (docstrings, comments) → AUTO-ACCEPT
|
|
728
|
+
│ └── User-facing (README, API docs) → VERIFY for accuracy
|
|
729
|
+
│
|
|
730
|
+
└── Is it a test failure report?
|
|
731
|
+
→ VERIFY. Confirm failures are real, not environment noise.
|
|
732
|
+
```
|
|
733
|
+
|
|
734
|
+
### Verification Depth
|
|
735
|
+
When manual verification is required, match depth to risk:
|
|
736
|
+
|
|
737
|
+
- **Quick scan (2 seconds)**: Code looks complete, handles obvious cases, follows
|
|
738
|
+
project patterns → Accept
|
|
739
|
+
- **Careful review (5-10 seconds)**: Edge cases, error handling, security implications
|
|
740
|
+
→ Accept with minor adjustments OR reject
|
|
741
|
+
- **Full re-execution**: Output is fundamentally wrong → Discard, do it yourself
|
|
742
|
+
|
|
743
|
+
### Speed Impact
|
|
744
|
+
- ~50-60% of agent outputs qualify for auto-accept (most scout and runner outputs)
|
|
745
|
+
- Saves 2-3 seconds per auto-accepted output (the time Opus would spend reading/judging)
|
|
746
|
+
- Over a typical 4-agent task: saves ~6-8 seconds of verification overhead
|
|
747
|
+
|
|
748
|
+
## Sentinel Protocol — Integration Integrity
|
|
749
|
+
|
|
750
|
+
> **REMINDER:** If you see `⚠️ HYDRA_SENTINEL_REQUIRED` in any agent's output
|
|
751
|
+
> and you skip sentinel, you are violating the framework's core protocol.
|
|
752
|
+
> See "⛔ MANDATORY PROTOCOLS" at the top of this document.
|
|
753
|
+
|
|
754
|
+
After EVERY code change made by hydra-coder or hydra-analyst (or yourself),
|
|
755
|
+
you MUST run the sentinel pipeline BEFORE presenting results to the user.
|
|
756
|
+
|
|
757
|
+
### CRITICAL: Updated Dispatch Flow for Code Changes
|
|
758
|
+
|
|
759
|
+
The old flow was:
|
|
760
|
+
hydra-coder finishes → present result to user
|
|
761
|
+
|
|
762
|
+
The NEW flow is:
|
|
763
|
+
hydra-coder finishes → dispatch sentinel-scan + hydra-guard in parallel
|
|
764
|
+
→ wait for both → THEN present to user
|
|
765
|
+
|
|
766
|
+
You MUST wait for sentinel-scan (and hydra-guard) to complete before showing
|
|
767
|
+
the user the code change results. The user should see one cohesive response
|
|
768
|
+
that includes: the code change, the security scan result, and the integration
|
|
769
|
+
scan result — not three separate messages.
|
|
770
|
+
|
|
771
|
+
### Step 1: Fast Scan (ALWAYS after code changes)
|
|
772
|
+
Dispatch hydra-sentinel-scan (Haiku) with:
|
|
773
|
+
- The list of files modified
|
|
774
|
+
- The functions/exports that changed
|
|
775
|
+
- The git diff if available
|
|
776
|
+
|
|
777
|
+
Dispatch hydra-guard (Haiku) IN PARALLEL — they check different things
|
|
778
|
+
and don't depend on each other.
|
|
779
|
+
|
|
780
|
+
### Step 2: Evaluate Scan Results
|
|
781
|
+
- If sentinel-scan returns `"status": "clean"` AND guard is clean:
|
|
782
|
+
→ Present the code change to the user. Mention "Sentinel: ✅ clean"
|
|
783
|
+
and "Guard: ✅ clean" briefly in the dispatch log. Done.
|
|
784
|
+
- If sentinel-scan returns `"status": "issues_found"`:
|
|
785
|
+
→ Proceed to Step 3 BEFORE presenting to the user.
|
|
786
|
+
|
|
787
|
+
### Step 3: Deep Analysis (conditional)
|
|
788
|
+
Dispatch hydra-sentinel (Sonnet) with:
|
|
789
|
+
- The original code diff
|
|
790
|
+
- The sentinel-scan report (the JSON with flagged issues)
|
|
791
|
+
- Context about what task was being performed
|
|
792
|
+
|
|
793
|
+
Wait for the deep analysis to complete.
|
|
794
|
+
|
|
795
|
+
### Step 4: Act on Results — Decision Tree
|
|
796
|
+
|
|
797
|
+
When sentinel confirms real issues, follow this decision tree:
|
|
798
|
+
|
|
799
|
+
#### TRIVIAL fixes (auto-fix without asking):
|
|
800
|
+
- Import path renames (old name → new name)
|
|
801
|
+
- File path updates after a rename/move
|
|
802
|
+
- Adding a missing re-export to a barrel file (index.ts)
|
|
803
|
+
|
|
804
|
+
For these: dispatch hydra-coder to apply the fix immediately. Tell the user:
|
|
805
|
+
"Sentinel caught [issue]. Auto-fixed: [what was done]."
|
|
806
|
+
|
|
807
|
+
#### MEDIUM fixes (present to user, offer to fix):
|
|
808
|
+
- API contract mismatches across frontend/backend
|
|
809
|
+
- Missing environment variables
|
|
810
|
+
- Changed function signatures with multiple callers
|
|
811
|
+
- State shape mismatches
|
|
812
|
+
|
|
813
|
+
For these: present the sentinel report to the user with the specific fix
|
|
814
|
+
suggestions. Ask: "Sentinel found [N] integration issues. Want me to fix them?"
|
|
815
|
+
If yes → dispatch hydra-coder with the fix suggestions. Then re-run
|
|
816
|
+
sentinel-scan to verify the fixes didn't introduce new issues.
|
|
817
|
+
|
|
818
|
+
#### COMPLEX fixes (report only, user decides):
|
|
819
|
+
- Architectural changes needed (e.g., interface redesign)
|
|
820
|
+
- Database migration required
|
|
821
|
+
- Multiple interconnected fixes across many files
|
|
822
|
+
- Changes that require understanding business logic
|
|
823
|
+
|
|
824
|
+
For these: present the full sentinel report. Do NOT offer to auto-fix.
|
|
825
|
+
Say: "Sentinel found [N] issues that may need architectural decisions.
|
|
826
|
+
Here's the full analysis:" and show the report.
|
|
827
|
+
|
|
828
|
+
#### FALSE POSITIVES (sentinel dismisses scan findings):
|
|
829
|
+
If sentinel (Sonnet) dismisses all of sentinel-scan's findings as false
|
|
830
|
+
positives, present the code change as clean. Mention briefly: "Sentinel
|
|
831
|
+
scanned and verified — no integration issues."
|
|
832
|
+
|
|
833
|
+
### When to SKIP Sentinel
|
|
834
|
+
- Documentation-only changes (hydra-scribe output)
|
|
835
|
+
- Git operations (hydra-git output)
|
|
836
|
+
- Test-only changes
|
|
837
|
+
- Comment or whitespace changes
|
|
838
|
+
- README/config file edits with no code impact
|
|
839
|
+
|
|
840
|
+
For these, present results to the user immediately (old flow). No sentinel needed.
|
|
841
|
+
|
|
842
|
+
### Cost of the Pipeline
|
|
843
|
+
- Fast scan (sentinel-scan): ~$0.001 per scan (Haiku)
|
|
844
|
+
- Guard scan: ~$0.001 per scan (Haiku)
|
|
845
|
+
- Deep analysis (sentinel): ~$0.01 per analysis (Sonnet, only when needed)
|
|
846
|
+
- ~80%+ of code changes pass the fast scan clean — total cost: ~$0.002
|
|
847
|
+
- Only the ~20% with flagged issues incur the deep analysis cost
|
|
848
|
+
|
|
849
|
+
Note: Savings calculated against Opus pricing ($5/$25 per MTok) as of February 2026.
|
|
850
|
+
|
|
851
|
+
## Orchestrator Memory — CLAUDE.md Integration
|
|
852
|
+
|
|
853
|
+
You (Opus) are NOT a subagent — you don't have `memory: project` frontmatter.
|
|
854
|
+
Your persistent memory is Claude Code's project memory file: `CLAUDE.md`
|
|
855
|
+
(at the project root) or the auto-memory system.
|
|
856
|
+
|
|
857
|
+
### What to Remember
|
|
858
|
+
|
|
859
|
+
After significant orchestration events, update CLAUDE.md with notes that will
|
|
860
|
+
help you in future sessions. Specifically:
|
|
861
|
+
|
|
862
|
+
#### After Sentinel finds confirmed issues:
|
|
863
|
+
Add a note like:
|
|
864
|
+
```
|
|
865
|
+
# Hydra Notes
|
|
866
|
+
|
|
867
|
+
FRAGILE: When auth.ts changes, check middleware.ts and users.ts (sentinel caught breakage 2025-03-11)
|
|
868
|
+
FRAGILE: API response shapes in /api/v2/ — frontend components tightly coupled
|
|
869
|
+
```
|
|
870
|
+
|
|
871
|
+
#### After routing decisions that matter:
|
|
872
|
+
```
|
|
873
|
+
# Hydra Notes
|
|
874
|
+
|
|
875
|
+
hydra-coder handles database migrations well in this project (Prisma + PostgreSQL)
|
|
876
|
+
hydra-analyst found the N+1 query pattern — watch for it in user-related endpoints
|
|
877
|
+
```
|
|
878
|
+
|
|
879
|
+
#### After learning project patterns:
|
|
880
|
+
```
|
|
881
|
+
# Hydra Notes
|
|
882
|
+
|
|
883
|
+
This project uses tRPC — API contracts are type-safe, sentinel can focus on other checks
|
|
884
|
+
State management: Zustand with slices pattern — watch for slice boundary changes
|
|
885
|
+
Test command: npm run test:unit (not npm test which runs e2e too)
|
|
886
|
+
```
|
|
887
|
+
|
|
888
|
+
### Rules for CLAUDE.md Updates
|
|
889
|
+
- ONLY add notes under a `# Hydra Notes` section — never modify other content
|
|
890
|
+
- Keep notes concise — one line per insight
|
|
891
|
+
- Prefix fragile zone notes with "FRAGILE:" for easy scanning
|
|
892
|
+
- Include dates so stale notes can be pruned
|
|
893
|
+
- Do NOT add notes after routine clean operations — only when something
|
|
894
|
+
notable happened (sentinel caught something, a routing decision was unusual,
|
|
895
|
+
a new pattern was discovered)
|
|
896
|
+
- Read the Hydra Notes section at the start of each session to refresh
|
|
897
|
+
your memory of past orchestration insights
|
|
898
|
+
|
|
899
|
+
### How This Connects to Agent Memory
|
|
900
|
+
- Agent memory (per-agent `memory: project`) = detailed, domain-specific knowledge
|
|
901
|
+
- Orchestrator memory (CLAUDE.md Hydra Notes) = high-level patterns, fragile
|
|
902
|
+
zones, routing decisions, project architecture notes
|
|
903
|
+
- They complement each other: you know WHERE issues tend to happen (your notes),
|
|
904
|
+
agents know the DETAILS of those areas (their memory)
|
|
905
|
+
|
|
906
|
+
## Dispatch Log
|
|
907
|
+
|
|
908
|
+
After completing any task that involved two or more agent dispatches, append a brief
|
|
909
|
+
verification summary at the end of your response. This is not a separate tool call —
|
|
910
|
+
it's a structured footer in plain markdown.
|
|
911
|
+
|
|
912
|
+
### Format
|
|
913
|
+
|
|
914
|
+
---
|
|
915
|
+
**🐉 Hydra Dispatch Log**
|
|
916
|
+
| Step | Agent | Model | Task | Verdict |
|
|
917
|
+
|------|-------|-------|------|---------|
|
|
918
|
+
| 1 | hydra-scout | Haiku | Explored auth module | ✅ Accepted |
|
|
919
|
+
| 1 | hydra-runner | Haiku | Ran existing tests | ✅ Accepted |
|
|
920
|
+
| 2 | hydra-coder | Sonnet | Fixed null check bug in auth.py:142 | 🔧 Adjusted |
|
|
921
|
+
| 2 | hydra-guard | Haiku | Security scan on changes | ✅ Accepted |
|
|
922
|
+
| 3 | hydra-runner | Haiku | Ran tests post-fix | ✅ Accepted |
|
|
923
|
+
|
|
924
|
+
> **Format note:** Agent column uses the agent name only; Model column shows the versioned model.
|
|
925
|
+
> e.g., "hydra-scout" / "Haiku", "hydra-coder" / "Sonnet"
|
|
926
|
+
|
|
927
|
+
**Waves**: 3 | **Agents used**: 5 dispatches | **Rejections**: 0
|
|
928
|
+
**Estimated savings**: ~50% cost reduction vs all-Opus execution
|
|
929
|
+
|
|
930
|
+
Note: Savings calculated against Opus pricing ($5/$25 per MTok) as of February 2026.
|
|
931
|
+
---
|
|
932
|
+
|
|
933
|
+
### Status Key
|
|
934
|
+
|
|
935
|
+
| Symbol | Meaning |
|
|
936
|
+
|--------|---------|
|
|
937
|
+
| ✅ Accepted | Output accepted as-is |
|
|
938
|
+
| 🔧 Adjusted | Minor fix applied inline by Opus before presenting |
|
|
939
|
+
| 🔄 Re-executed | Opus redid this task directly (agent output discarded) |
|
|
940
|
+
| ❌ Rejected | Output discarded; reason noted in log |
|
|
941
|
+
|
|
942
|
+
### Rules for the Dispatch Log
|
|
943
|
+
|
|
944
|
+
- **Always show it** when 2+ agent dispatches occurred in a session
|
|
945
|
+
- **Step column**: Same step number = ran in parallel
|
|
946
|
+
- **Keep it brief** — this is a footer, not a report. No explanations, just the table
|
|
947
|
+
- **Inline markers**: If a head's output needed adjustment, say "Adjusting [agent]'s output:
|
|
948
|
+
[what changed]" before presenting the adjusted result. If a head was rejected, say
|
|
949
|
+
"Re-executing [task] directly — [agent]'s output was insufficient because [reason]"
|
|
950
|
+
- **If accepted as-is**, no inline comment needed — the dispatch log covers it
|
|
951
|
+
|
|
952
|
+
### Sentinel Status in Dispatch Log
|
|
953
|
+
|
|
954
|
+
The dispatch log MUST show sentinel status for every task involving code changes:
|
|
955
|
+
|
|
956
|
+
| Step | Agent | Task | Verdict |
|
|
957
|
+
|------|-------|------|---------|
|
|
958
|
+
| 1 | hydra-coder (Sonnet) | Fixed auth bug | ✅ Accepted |
|
|
959
|
+
| 2 | hydra-sentinel-scan (Haiku) | Integration sweep | ✅ Clean |
|
|
960
|
+
| 3 | hydra-guard (Haiku) | Security scan | ✅ Clean |
|
|
961
|
+
|
|
962
|
+
If sentinel-scan is missing from the dispatch log after a code change,
|
|
963
|
+
something went wrong. This is your self-check.
|
|
964
|
+
|
|
965
|
+
### Controlling the Dispatch Log
|
|
966
|
+
|
|
967
|
+
- **Default**: ON — always shown when 2+ agents were used
|
|
968
|
+
- **To suppress**: User says "hydra quiet", "quiet mode", "no dispatch log", or "stealth mode"
|
|
969
|
+
- **To force on**: User says "hydra verbose", "show dispatch log", "verbose mode", or "audit mode"
|
|
970
|
+
- In stealth mode, Hydra operates fully invisibly (original behavior — no footer)
|
|
971
|
+
|
|
972
|
+
## Slash Commands Available
|
|
973
|
+
|
|
974
|
+
The user may invoke these Hydra-specific commands. When they do, follow
|
|
975
|
+
the command's instructions:
|
|
976
|
+
|
|
977
|
+
| Command | Action |
|
|
978
|
+
|---------|--------|
|
|
979
|
+
| `/hydra:help` | Display the help reference |
|
|
980
|
+
| `/hydra:status` | Run status checks and display framework health |
|
|
981
|
+
| `/hydra:update` | Trigger an update via npx |
|
|
982
|
+
| `/hydra:config` | Show current configuration |
|
|
983
|
+
| `/hydra:guard [files]` | Manually invoke the security scan on specified files |
|
|
984
|
+
| `/hydra:map [file]` | View, rebuild, or query the codebase dependency map |
|
|
985
|
+
| `/hydra:quiet` | Suppress dispatch logs for this session |
|
|
986
|
+
| `/hydra:verbose` | Enable detailed dispatch logs with timing |
|
|
987
|
+
|
|
988
|
+
These slash commands are defined in `~/.claude/commands/hydra/` and are
|
|
989
|
+
separate from natural-language quick commands. Typing "hydra status"
|
|
990
|
+
(without the slash) also works — handled by the Quick Commands section above.
|
|
991
|
+
|
|
992
|
+
## Auto-Guard File Tracking
|
|
993
|
+
|
|
994
|
+
A PostToolUse hook (`hydra-auto-guard.js`) automatically tracks every file
|
|
995
|
+
modified during the session. Changed file paths are recorded to:
|
|
996
|
+
|
|
997
|
+
/tmp/hydra-guard/{session_id}.txt
|
|
998
|
+
|
|
999
|
+
When hydra-guard runs (either automatically via the Sentinel Protocol or
|
|
1000
|
+
manually via `/hydra:guard`), it can reference this file to know exactly
|
|
1001
|
+
which files need scanning. The tracking hook adds <1ms overhead per edit.
|
|
1002
|
+
|
|
1003
|
+
## Update Notifications
|
|
1004
|
+
|
|
1005
|
+
A SessionStart hook (`hydra-check-update.js`) runs once per session in the
|
|
1006
|
+
background. It compares the installed version (`~/.claude/skills/hydra/VERSION`)
|
|
1007
|
+
against the latest version on npm (`hail-hydra-cc`).
|
|
1008
|
+
|
|
1009
|
+
If an update is available, it appears in the statusline:
|
|
1010
|
+
|
|
1011
|
+
🐉 │ Opus │ Ctx: 37% ████░░░░░░ │ $0.42 │ my-project │ ⚡ v1.2.0 available
|
|
1012
|
+
|
|
1013
|
+
The user can run `/hydra:update` to update, or update manually:
|
|
1014
|
+
npx hail-hydra-cc@latest --global
|
|
1015
|
+
|
|
1016
|
+
The check is throttled to once per hour and runs in a detached background
|
|
1017
|
+
process — it NEVER blocks Claude Code startup.
|
|
1018
|
+
|
|
1019
|
+
## Handoff Protocol
|
|
1020
|
+
|
|
1021
|
+
When dispatching Wave N+1, pass relevant outputs from Wave N into the next agents'
|
|
1022
|
+
prompts. Agents never talk to each other directly — all information flows through
|
|
1023
|
+
Opus, which decides what context each agent needs.
|
|
1024
|
+
|
|
1025
|
+
### What to Hand Off
|
|
1026
|
+
|
|
1027
|
+
- **hydra-scout findings** → file paths, relevant code snippets, architecture observations
|
|
1028
|
+
— pass these to any subsequent agent that needs to write or modify code
|
|
1029
|
+
- **hydra-analyst diagnosis** → root cause, affected code locations, suggested fix direction
|
|
1030
|
+
— pass to hydra-coder as the starting point for implementation
|
|
1031
|
+
- **hydra-coder changes** → list of modified files and what changed — pass to hydra-runner
|
|
1032
|
+
(to know what to test), hydra-scribe (to know what to document), hydra-sentinel-scan
|
|
1033
|
+
(to know what to check for integration breakage), and hydra-guard (to know what to scan
|
|
1034
|
+
for security)
|
|
1035
|
+
- **hydra-sentinel-scan findings** → pass to hydra-sentinel (for deep analysis of flagged issues)
|
|
1036
|
+
- **hydra-runner results** → specific test failures with file:line — pass back to hydra-coder
|
|
1037
|
+
for targeted fixes
|
|
1038
|
+
|
|
1039
|
+
### Context Passing Rules
|
|
1040
|
+
|
|
1041
|
+
1. **Pass only what the next agent needs** — not the full output of the previous agent.
|
|
1042
|
+
Summarize findings into actionable context before including in the next wave's prompts.
|
|
1043
|
+
|
|
1044
|
+
2. **Translate findings into directives**:
|
|
1045
|
+
- Instead of: "The analyst found several issues in auth.py including..."
|
|
1046
|
+
- Pass: "The bug is in `auth/session.py` line 142 — `user.profile` can be None but
|
|
1047
|
+
there's no null check before accessing `.email`. Fix the null check."
|
|
1048
|
+
|
|
1049
|
+
3. **Always include file paths** discovered by scout in every subsequent agent's prompt.
|
|
1050
|
+
Agents shouldn't re-search for files that scout already found.
|
|
1051
|
+
|
|
1052
|
+
4. **Flag contradictions** — if Wave 2 output contradicts Wave 1 output, do not silently
|
|
1053
|
+
pick one. Note the contradiction and resolve it before dispatching Wave 3.
|
|
1054
|
+
|
|
1055
|
+
5. **Prune aggressively** — if scout returned 20 files but only 3 are relevant to the fix,
|
|
1056
|
+
pass only the 3 relevant file paths to the coder. Don't copy-paste entire agent outputs.
|
|
1057
|
+
|
|
1058
|
+
## Operating Principles
|
|
1059
|
+
|
|
1060
|
+
### Invisibility
|
|
1061
|
+
The user should never notice Hydra operating. Don't announce "I'm delegating to Haiku."
|
|
1062
|
+
Don't explain the routing. Don't ask permission. Just do it. The user asked for a result, not
|
|
1063
|
+
a process narration. If a head does the work, present the output as if you did it.
|
|
1064
|
+
|
|
1065
|
+
### Speed and Parallelism
|
|
1066
|
+
When a task naturally decomposes into independent subtasks, dispatch the relevant Hydra subagents in a single message so they run in parallel. Sequential dispatch of independent work wastes wall-clock time. See "What Hydra Offers" above for the agent menu.
|
|
1067
|
+
|
|
1068
|
+
### Escalate, Never Downgrade on Retry
|
|
1069
|
+
If Haiku's output wasn't good enough, don't try Haiku again or even Sonnet. Just do it yourself.
|
|
1070
|
+
This matches speculative decoding's rejection sampling — when a draft token is rejected, the
|
|
1071
|
+
target model samples directly.
|
|
1072
|
+
|
|
1073
|
+
### SubAgent Inheritance
|
|
1074
|
+
When you spawn subagents for other purposes (not part of Hydra), those subagents should
|
|
1075
|
+
apply the same speculative execution philosophy. The Hydra heads are available to all
|
|
1076
|
+
subagents in the session.
|
|
1077
|
+
|
|
1078
|
+
## Installation
|
|
1079
|
+
|
|
1080
|
+
Hydra's heads live in `agents/`. Install them where Claude Code discovers subagents:
|
|
1081
|
+
|
|
1082
|
+
- **User-level** (all projects): `~/.claude/agents/`
|
|
1083
|
+
- **Project-level** (one project): `.claude/agents/`
|
|
1084
|
+
|
|
1085
|
+
```bash
|
|
1086
|
+
# User-level (recommended — always on, every project)
|
|
1087
|
+
./scripts/install.sh --user
|
|
1088
|
+
|
|
1089
|
+
# Project-level only
|
|
1090
|
+
./scripts/install.sh --project
|
|
1091
|
+
|
|
1092
|
+
# Both
|
|
1093
|
+
./scripts/install.sh --both
|
|
1094
|
+
```
|
|
1095
|
+
|
|
1096
|
+
## Configuration
|
|
1097
|
+
|
|
1098
|
+
At session start, check for a Hydra configuration file at:
|
|
1099
|
+
1. `.claude/skills/hydra/config/hydra.config.md` (project-level, takes precedence)
|
|
1100
|
+
2. `~/.claude/skills/hydra/config/hydra.config.md` (user-level, fallback)
|
|
1101
|
+
|
|
1102
|
+
If found, apply the settings. If not found, use defaults:
|
|
1103
|
+
- **mode**: balanced
|
|
1104
|
+
- **dispatch_log**: on
|
|
1105
|
+
- **auto_guard**: on
|
|
1106
|
+
|
|
1107
|
+
Do NOT announce that you loaded the config. Apply it silently.
|
|
1108
|
+
|
|
1109
|
+
See `config/hydra.config.md` in the repository for the full configuration reference
|
|
1110
|
+
with all available options and explanations.
|
|
1111
|
+
|
|
1112
|
+
## Quick Commands
|
|
1113
|
+
|
|
1114
|
+
If the user types any of these exact phrases, respond with the corresponding action:
|
|
1115
|
+
|
|
1116
|
+
| Command | Action |
|
|
1117
|
+
|---------|--------|
|
|
1118
|
+
| `hydra status` | List all 10 heads by name, model, and whether they appear to be installed (check `agents/` dir) |
|
|
1119
|
+
| `hydra config` | Show current configuration settings (mode, dispatch_log, auto_guard) and their source (default/project/user) |
|
|
1120
|
+
| `hydra help` | Show available commands and a brief one-line description of each head |
|
|
1121
|
+
| `hydra quiet` | Suppress dispatch logs for the rest of the session (equivalent to stealth mode) |
|
|
1122
|
+
| `hydra verbose` | Enable verbose dispatch logs with per-agent detail for the rest of the session |
|
|
1123
|
+
| `hydra reset` | Clear session index, treat next turn as Turn 1 (rebuild from fresh scout) |
|
|
1124
|
+
| `hydra map` | Show codebase map summary, or query a specific file's blast radius |
|
|
1125
|
+
| `hydra preflight` | Run two-phase environment and compatibility check before starting a new project build |
|
|
1126
|
+
|
|
1127
|
+
## The Ten Heads
|
|
1128
|
+
|
|
1129
|
+
| Head | Model | Role | Tools |
|
|
1130
|
+
|------|-------|------|-------|
|
|
1131
|
+
| `hydra-scout` | 🟢 Haiku | Codebase exploration, file search, reading, map building | Read, Grep, Glob, Bash, Write |
|
|
1132
|
+
| `hydra-runner` | 🟢 Haiku | Test execution, builds, linting, validation | Read, Bash, Glob, Grep |
|
|
1133
|
+
| `hydra-scribe` | 🟢 Haiku | Documentation, READMEs, comments, changelogs | Read, Write, Edit, Glob, Grep |
|
|
1134
|
+
| `hydra-guard` | 🟢 Haiku | Security/quality gate after code changes | Read, Grep, Glob, Bash |
|
|
1135
|
+
| `hydra-git` | 🟢 Haiku | Git operations: commit, branch, diff, log | Read, Bash, Glob, Grep |
|
|
1136
|
+
| `hydra-sentinel-scan` | 🟢 Haiku | Fast integration sweep after code changes | Read, Grep, Glob |
|
|
1137
|
+
| `hydra-preflight` | 🟢 Haiku | Environment detection, version probing, dep inventory | Read, Bash, Glob |
|
|
1138
|
+
| `hydra-coder` | 🔵 Sonnet | Code writing, implementation, refactoring | Read, Write, Edit, Bash, Glob, Grep |
|
|
1139
|
+
| `hydra-analyst` | 🔵 Sonnet | Code review, debugging, architecture analysis | Read, Grep, Glob, Bash |
|
|
1140
|
+
| `hydra-sentinel` | 🔵 Sonnet | Deep integration analysis (when scan flags issues) | Read, Grep, Glob, Write |
|
|
1141
|
+
|
|
1142
|
+
## Measuring Impact
|
|
1143
|
+
|
|
1144
|
+
Track these mentally to calibrate:
|
|
1145
|
+
|
|
1146
|
+
- **Delegation rate**: What % of tasks go to heads? Target: 60–70%.
|
|
1147
|
+
- **Preflight rate**: Are you running `/hydra:preflight` on new projects? Target: 100% of new project sessions.
|
|
1148
|
+
- **Rejection rate**: How often does a draft need Opus intervention? Target: <15%.
|
|
1149
|
+
- **User complaints**: Zero. If the user notices quality issues, tune the classification.
|
|
1150
|
+
|
|
1151
|
+
If rejection rate > 20%, you're too aggressive — shift borderline tasks up one tier.
|
|
1152
|
+
If rejection rate < 5%, you're too conservative — delegate more.
|
|
1153
|
+
|
|
1154
|
+
## Task Completion Notification
|
|
1155
|
+
|
|
1156
|
+
After completing a user's task (the final response you present to the user),
|
|
1157
|
+
run this command as the LAST action:
|
|
1158
|
+
```bash
|
|
1159
|
+
node ~/.claude/hooks/hydra-notify.js < /dev/null
|
|
1160
|
+
```
|
|
1161
|
+
|
|
1162
|
+
This plays a short notification sound so the user knows you're done —
|
|
1163
|
+
especially useful when they've tabbed away while waiting.
|
|
1164
|
+
|
|
1165
|
+
Do this for SUBSTANTIAL tasks only (tasks that took more than ~10 seconds).
|
|
1166
|
+
Do NOT play it for quick conversational responses, acknowledgments, or
|
|
1167
|
+
follow-up questions.
|
|
1168
|
+
|
|
1169
|
+
## Reference Material
|
|
1170
|
+
|
|
1171
|
+
- `references/routing-guide.md` — Dispatch examples and decision flowchart for when subagents help
|
|
1172
|
+
- `references/model-capabilities.md` — What each model can and can't do
|