fix(agents): add skills/hooks frontmatter, anti-heredoc rules, and spawn type standardization#5
fix(agents): add skills/hooks frontmatter, anti-heredoc rules, and spawn type standardization#5
Conversation
Code Logic Verification of PR #51. The Before State (Bug Paths)BUG-1 — Hooks don't fire in subagents: Claude Code subagents do not inherit hooks from the parent process. Without BUG-2 — Skills loading unreliable in subagents: Without a BUG-6 — Heredoc file writes corrupt settings (gsd-build#526): When agents use Spawn workaround: 11 spawn calls across 5 files used 2. The After State (Fix Paths)Frontmatter additions (11 agents): Every
Spawn standardization (5 files, 11 spawns fixed):
Two 3. Key Correctness Checks
4. VerdictPASS — All four commits deliver exactly what the PR describes:
No regressions. Merges cleanly to main (no conflicts).
|
Add 'never use heredoc' instruction to 6 agents that were missing it: gsd-codebase-mapper, gsd-debugger, gsd-phase-researcher, gsd-project-researcher, gsd-research-synthesizer, gsd-roadmapper. All 9 file-writing agents now consistently prevent settings.local.json corruption from heredoc permission entries (GSD gsd-build#526). Read-only agents (plan-checker, integration-checker) excluded as they cannot write files. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Add skills: field to all 11 agent frontmatter files with forward-compatible GSD workflow skill references (silently ignored until skill files are created). Add commented hooks: examples to 9 file-writing agents showing PostToolUse hook syntax for project-specific linting/formatting. Read-only agents (plan-checker, integration-checker) skip hooks as they cannot modify files. Per Claude Code docs: subagents don't inherit skills or hooks from the parent conversation — they must be explicitly listed in frontmatter. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Replace general-purpose workaround pattern with named subagent types: - plan-phase: researcher and planner now spawn as gsd-phase-researcher/gsd-planner - new-project: 4 researcher spawns now use gsd-project-researcher - research-phase: researcher spawns now use gsd-phase-researcher - quick: planner revision now uses gsd-planner - diagnose-issues: debug agents now use gsd-debugger (matches template spec) Removes 'First, read agent .md file' prompt prefix — named agent types auto-load their .md file as system prompt, making the workaround redundant. Preserves intentional general-purpose orchestrator spawns in discuss-phase and plan-phase (auto-advance) where the agent runs an entire workflow. Co-Authored-By: Claude Opus 4.6 <[email protected]>
New test suite covering: - HDOC: anti-heredoc instruction present in all 9 file-writing agents - SKILL: skills: frontmatter present in all 11 agents - HOOK: commented hooks pattern in file-writing agents - SPAWN: no stale workaround patterns, valid agent type references - AGENT: required frontmatter fields (name, description, tools, color) 509 total tests (462 existing + 47 new), 0 failures. Co-Authored-By: Claude Opus 4.6 <[email protected]>
1211e74 to
82508a5
Compare
Summary
skills:frontmatter to all 11 agents for declarative skill loading (BUG-2)hooks:examples to 9 file-writing agents showing PostToolUse syntax (BUG-1)settings.local.jsonpollution (BUG-6 / Verifier/executor agents pollute settings.local.json with heredoc permissions gsd-build/get-shit-done#526)subagent_typeacross all workflow spawn calls, replacing stalegeneral-purposeworkarounds with proper named agent typesRoot Cause
Three bugs identified in the GSD Subagent Capability Inheritance analysis:
skills:field in agent frontmatter, skill activation in subagents is unreliable. Declarative frontmatter makes it explicit.settings.local.json(Verifier/executor agents pollute settings.local.json with heredoc permissions gsd-build/get-shit-done#526). When agents useBash(cat << 'EOF' > file)instead of theWritetool, Claude Code's settings can be corrupted. An explicit anti-heredoc instruction prevents this.Additionally, workflow files used a
"First, read ~/.claude/agents/gsd-*.md"workaround withsubagent_type="general-purpose"because named agent types were not originally supported. This workaround is now stale — Claude Code supports namedsubagent_typevalues that map directly to agent definition files.Fix
Agent frontmatter additions (11 agents)
Every
agents/gsd-*.mdfile now includes askills:field referencing agsd-*-workflowskill name. File-writing agents (those withWritein theirtools:list) additionally receive:# hooks:block demonstratingPostToolUsehook syntax forWrite|EditmatchersBash(cat << 'EOF')or heredoc commands for file creation."skills:# hooks:Read-only agents (integration-checker, plan-checker) receive
skills:only — they have noWritetool, so hooks and anti-heredoc are not applicable.Workflow spawn standardization (5 files)
All
Task()spawn calls updated to use namedsubagent_typevalues and remove the"First, read agent .md"prompt prefix:subagent_typesubagent_typecommands/gsd/research-phase.md"general-purpose""gsd-phase-researcher"get-shit-done/workflows/plan-phase.md"general-purpose""gsd-phase-researcher"/"gsd-planner"get-shit-done/workflows/new-project.md"general-purpose""gsd-project-researcher"get-shit-done/workflows/quick.md"general-purpose""gsd-planner"get-shit-done/workflows/diagnose-issues.md"general-purpose""gsd-debugger"Relationship to Other PRs
This is PR #5 of 6 from the
dev-bugfixbranch:<mcp_check>blocks to agent body sections; PR #5 adds frontmatter and anti-heredoc to header sections. Both modify agent files but different regions. Recommend merging #5 before #1.Recommended merge order: #2, #3, #4, #5, #6, #1
Testing
New tests:
tests/agent-frontmatter.test.cjs(47 tests across 5 describe blocks)Full suite results
All 466 tests pass (84 suites), including all 47 new tests. Zero regressions.
Impact
subagent_typevalues cause Claude Code to load the agent definition file directly, which previously happened via prompt instruction. The agent receives the same role and instructions either way — the named type is cleaner and more reliable.Future Considerations
general-purposeworkaround removal becomes even more justified, since named agent types will also inherit MCP server access.skills:frontmatter is forward-compatible. Referenced skills (e.g.,gsd-executor-workflow) do not need to exist at install time — they are resolved at spawn. Users can create matching skill files later.hooks:are commented examples only. Users must uncomment and customize thePostToolUsehook patterns for their project. The examples show the correct YAML structure and a common eslint auto-fix pattern.