Skip to content

fix: subagent skill preload#184

Merged
dean0x merged 11 commits intomainfrom
fix/subagent-skill-preload
Apr 18, 2026
Merged

fix: subagent skill preload#184
dean0x merged 11 commits intomainfrom
fix/subagent-skill-preload

Conversation

@dean0x
Copy link
Copy Markdown
Owner

@dean0x dean0x commented Apr 17, 2026

Fixes skill preload behavior for subagents.

Dean Sharon and others added 11 commits April 17, 2026 10:05
…ck-list

Update parseFrontmatterSkills() in skill-references.test.ts to parse
YAML block-list format (`- devflow:name` entries) instead of comma-
separated strings. Convert all 12 shared agents to use the new format.

Block-list YAML is the correct frontmatter format for multi-value arrays
and enables Claude Code to preload skills into subagent context at spawn
time via the platform's skill injection mechanism.

Co-Authored-By: Claude <noreply@anthropic.com>
…er mode skills

- designer.md: preload gap-analysis and design-review into frontmatter
  block-list (eliminating the conditional Read of mode skills at runtime);
  update Modes table header from "Read this first" to "preloaded"
- coder.md: replace install-path Read instructions with Skill tool
  invocations for domain skill loading; fail BLOCKED on Skill error
- reviewer.md: replace install-path Read instruction with Skill tool
  invocation for focus skill loading; update Focus Areas table to use
  devflow:X references instead of ~/.claude/skills paths
- tests: update parseReviewerFocusAreas() regex and coder domain skill
  check to match new formats; lower Format 3 install-path threshold
  to >=0 since agents now use Skill tool invocations

Co-Authored-By: Claude <noreply@anthropic.com>
Add getLatestSubagentPreloadedSkills() to integration test helpers —
walks ~/.claude/projects/{encoded-path}/*/subagents/agent-*.jsonl to
find the most recent subagent transcript after a given timestamp and
extracts skill names from <command-name> tags in the first user message.

Add subagent-skill-preload.test.ts with 6 smoke tests verifying that
skills declared in agent frontmatter block-lists are injected into
subagent context at spawn time. Tests are guarded by isClaudeAvailable()
and run under npm run test:integration only (not npm test).

Assertions validated:
- Simplifier: software-design + worktree-support, no apply-knowledge
- Scrutinizer: quality-gates, software-design, worktree-support, apply-knowledge
- Reviewer: review-methodology, worktree-support, apply-knowledge
- Coder: all 8 core skills
- Designer: worktree-support, apply-knowledge, gap-analysis, design-review
- Git: git + worktree-support

Co-Authored-By: Claude <noreply@anthropic.com>
- Replace __dirname with import.meta.dirname for ESM consistency
- Remove debug console.log statements from integration tests
- Remove dead code (empty if-block for tool_result events)
- Reuse CLASSIFICATION_PATTERN constant in hasDevFlowBranding
- Remove always-true assertion (count >= 0)
- Use explicit length check instead of toBeTruthy for string assertion
Domain skills in Coder and focus skills in Reviewer are optional
enhancements — missing optional plugins should not block task completion.

- Coder step 2: skip failed domain skill invocations and continue rather
  than reporting BLOCKED; remove misleading "First action —" prefix
- Reviewer step 1: fall back to built-in knowledge if focus skill load
  fails rather than reporting BLOCKED
- Both: add inline rationale comment explaining why dynamic loading is
  used (unbounded domain/focus set vs preloading all variants)
- Restore hasDevFlowBranding export in integration helpers (accidentally
  deleted in prior working-tree edit, breaking ambient unit tests)

Co-Authored-By: Claude <noreply@anthropic.com>
- Fix timing race: use >= instead of > for mtime comparison so
  transcripts written at the same millisecond as the marker are
  not dropped (Issue 1)
- Decompose getLatestSubagentPreloadedSkills into three focused
  functions: findRecentSubagentTranscripts, parsePreloadedSkills,
  and a thin orchestrator (Issue 2)
- Add COUPLING comment documenting dependency on Claude Code's
  internal transcript format (Issue 3)
- Bound session directory scan to most recent 20 entries to avoid
  O(N) walk on machines with hundreds of sessions (Issue 4)
- Add unknown type annotation and type guards for both JSON.parse
  call sites to satisfy TypeScript strict null checking (Issue 5)
- Document hasDevFlowBranding as intentional alias of hasClassification
  via @see JSDoc — function is used in ambient.test.ts (Issue 6)

Co-Authored-By: Claude <noreply@anthropic.com>
Add non-empty guard before arrayContaining in all 6 subagent skill
preload integration tests so a missing transcript produces a clear
diagnostic instead of a cryptic arrayContaining failure.

Add a new Format 2 test that asserts every shared agent declares at
least one skill in frontmatter, guarding against silent regressions
where parseFrontmatterSkills returns [] for a malformed block.

Co-Authored-By: Claude <noreply@anthropic.com>
…ious async

- Collapse 6 repetitive test scaffolds into shared helper with centralized
  guard assertion
- Remove async keyword from 5 synchronous test functions (sync I/O by design)
- Rename Promise callback parameter from `resolve` to `done` in
  helpers.ts to avoid shadowing the path.resolve import
- Reorder simplifier.md and skimmer.md frontmatter so model: precedes
  skills:, matching the other 10 agents
- Add runClaudeAndWait helper for subagent tests (waits for completion
  instead of early-exit on Skill detection)
- Use --dangerously-skip-permissions so subagent tools execute in
  non-interactive -p mode
- Fix parsePreloadedSkills to scan all isMeta user messages (skills are
  injected as separate messages, not in the first prompt message)
- Add allowedTools/systemPrompt options to runClaudeStreaming for
  non-ambient test scenarios

All 6 integration tests pass: Simplifier, Scrutinizer, Reviewer, Coder,
Designer, Git — confirming YAML block-list skills are preloaded correctly.
build-hud.js previously copied only dist/hud/ to scripts/hud/, leaving
imports to sibling directories (e.g. ../utils/notifications-shape.js)
unresolvable at install time. Now walks the ESM import graph from the
entry point and copies every reachable file to scripts/ at the matching
relative path. Also adds scripts/utils/ to .gitignore.
@dean0x dean0x merged commit 48d2221 into main Apr 18, 2026
4 checks passed
@dean0x dean0x deleted the fix/subagent-skill-preload branch April 18, 2026 19:58
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