Skip to content

fix: standardize subagent types and add agent frontmatter#805

Closed
Tibsfox wants to merge 5 commits intogsd-build:mainfrom
Tibsfox:fix/mcp-subagent-types
Closed

fix: standardize subagent types and add agent frontmatter#805
Tibsfox wants to merge 5 commits intogsd-build:mainfrom
Tibsfox:fix/mcp-subagent-types

Conversation

@Tibsfox
Copy link
Contributor

@Tibsfox Tibsfox commented Feb 28, 2026

Summary

  • Revert general-purpose workaround: Replace subagent_type="general-purpose" + "First, read agent .md" prompt prefix with proper named subagent types (gsd-phase-researcher, gsd-planner, gsd-project-researcher, gsd-debugger) across all workflows — named types auto-load their .md as system prompt, making the workaround redundant
  • Add skills/hooks frontmatter to all 11 agents: Per Claude Code docs, subagents don't inherit skills or hooks from the parent conversation — they must be explicitly listed in frontmatter. Adds skills: field and commented hooks: examples (PostToolUse for project-specific linting)
  • Extend anti-heredoc instruction to all file-writing agents: Prevents settings.local.json corruption from heredoc permission entries (Verifier/executor agents pollute settings.local.json with heredoc permissions #526) in 6 agents that were missing it
  • Document mcpServers frontmatter findings: Analysis of Claude Code mcpServers: frontmatter behavior — works for project-specific agents but not GSD's globally-installed templates. Strategy: users should migrate MCP to global scope
  • Add 47 agent frontmatter and spawn consistency tests: Validates anti-heredoc, skills frontmatter, hooks patterns, spawn type consistency (no stale workarounds), and required frontmatter fields

Context

The original fix (#161, 314916b) switched MCP-dependent subagents to general-purpose as a workaround for Claude Code bug #13898 (custom subagents can't access project-scoped MCP tools). This PR supersedes that workaround — named agent types provide better role isolation, model control, and frontmatter features. Users needing MCP in subagents should migrate to global MCP scope.

Test plan

  • Run node --test tests/agent-frontmatter.test.cjs — 47 tests, 0 failures
  • Verify no "First, read ~/.claude/agents/gsd-" patterns remain in workflows/commands
  • Verify all subagent_type= references use valid agent names or general-purpose
  • Spot-check diagnose-issues.md spawns gsd-debugger (not general-purpose)
  • Verify all 11 agents have skills: in frontmatter
  • Verify all 9 file-writing agents have anti-heredoc instruction

🤖 Generated with Claude Code

Tibsfox and others added 5 commits February 28, 2026 02:07
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]>
Document analysis of Claude Code mcpServers frontmatter behavior based on
official documentation. Key finding: frontmatter mcpServers creates
independent connections but cannot solve GSD's problem because agent
definitions are generic templates, not project-specific.

Strategy decision: proceed with MCP migration helper (PR-6) as the
practical solution. General-purpose fallback (PR-5) deprioritized.

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]>
@Tibsfox
Copy link
Contributor Author

Tibsfox commented Feb 28, 2026

PR #812 evolved to cover this scope more thoroughly (anti-heredoc for all agents + skills/hooks frontmatter). Consolidating to make review easier. Thanks for bearing with the iteration!

@Tibsfox Tibsfox closed this Feb 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant