[FEATURE] Command-triggered agent spawning with skill injection
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
## Summary
Allow slash commands to spawn specific agents with dynamically injected skills, enabling context-aware agent execution without duplicating agent definitions.
## Related Issues
- #14016 - Skills don't auto-activate in spawned agents (Task tool)
- #14722 - Agent and Skill-Scoped MCP Configurations
- #13636 - Support private/internal agents that can only be invoked by commands
- #14714 - Subagents don't inherit parent conversation's allowed tools
## Problem
In monorepos or projects with multiple contexts (e.g., different apps, different tech stacks, different environments), users need the same agent behaviors but with different skill contexts.
Current options are suboptimal:
| Approach | Problem |
|----------|---------|
| Duplicate agents per context | Maintenance burden, N agents × M contexts |
| Hardcode skills in agent YAML | Not context-aware, wrong skills loaded |
| Include skill refs in command prompt | Not guaranteed, relies on Claude choosing to read |
| Manually instruct "use skill X" | Poor UX, defeats automation purpose |
Example scenario:
code-engineeragent: writes production code- Context A: React frontend (needs React patterns, hooks skills)
- Context B: Rust backend (needs Rust patterns, error handling skills)
Currently you must create code-engineer-react.md AND code-engineer-rust.md with duplicated agent logic.
Summary
This feature enables dependency injection for AI agents - the command provides the configuration, the agent provides the execution logic, and skills provide the domain knowledge. This separation of concerns is essential for scaling Claude Code in complex projects.
Proposed Solution
Allow slash commands to declare:
- Which agent to spawn
- Which skills to inject into that agent
```yaml
# .claude/commands/react-coder.md
---
description: Code with React patterns
agent: code-engineer
skills:
- react/component-patterns
- react/hooks-best-practices
- frontend/accessibility
---
$ARGUMENTS
# .claude/commands/rust-coder.md
---
description: Code with Rust patterns
agent: code-engineer
skills:
- rust/error-handling
- rust/ownership-patterns
- backend/api-design
---
$ARGUMENTS
Usage:
/react-coder Add a new user profile component
/rust-coder Add a new authentication endpoint
Result: Same code-engineer agent spawned, but with different skills loaded based on command.
Benefits
- No agent duplication - One generic agent definition
- Context-aware execution - Right skills for right context
- Composable architecture - Agents define "what", skills define "how"
- Easy to extend - Add new context = add new command + skills (no agent changes)
- Reduced maintenance - Fix agent logic once, applies everywhere
Alternative Syntax Options
Option A: Inline in command frontmatter (proposed above)
---
agent: code-engineer
skills: [skill-a, skill-b]
---
Option B: Reference a skill bundle
---
agent: code-engineer
skill-bundle: react-development
---
Option C: Extend Task tool parameters
Task({
subagent_type: 'code-engineer',
skills: ['react/hooks', 'frontend/testing'], // New parameter
prompt: '...'
})
Implementation Considerations
- Skill loading: Skills should be loaded into agent context before execution
- Precedence: Command-injected skills should supplement (not replace) agent's native skills
- Validation: Warn if specified skill doesn't exist
- Discoverability: /help or /context should show available command+agent+skill combinations
Alternative Solutions
Include skill file paths in command prompt and hope Claude reads them:
# .claude/commands/react-coder.md
---
description: Code with React patterns
---
Before coding, read these skills:
- .claude/skills/react/component-patterns/SKILL.md
- .claude/skills/react/hooks-best-practices/SKILL.md
Then implement: $ARGUMENTS
Problems with workaround:
- Not guaranteed (Claude may skip reading)
- Extra tokens for file reads
- No validation
- Poor developer experience
Priority
Medium - Would be very helpful
Feature Category
CLI commands and flags
Use Case Example
Scenario: Monorepo with multiple tech stacks
- I have a monorepo with a React frontend (
/frontend) and a Rust backend (/backend) - I've created a generic
code-engineeragent that writes production-quality code - I've created skills for each stack:
react/component-patterns- React best practicesreact/hooks-usage- Hook patternsrust/error-handling- Rust Result/Option patternsrust/async-patterns- Tokio async patterns
- Current problem: I must either:
- Duplicate the agent (
code-engineer-react.md,code-engineer-rust.md) - Or hardcode skills in the agent (wrong skills load for wrong context)
- With this feature, I could:
- Create
/react-codercommand that spawnscode-engineer+ React skills - Create
/rust-codercommand that spawnscode-engineer+ Rust skills - One agent definition, multiple context-aware entry points
- This saves time because:
- No agent duplication (fix once, applies everywhere)
- Right skills automatically load for right context
- Adding new context = new command + skills (no agent changes)
- Clean separation: agents = "what to do", skills = "how to do it"
Additional Context
Additional Context
Related issues:
- #14016 - Skills don't auto-activate in spawned agents
- #14722 - Agent and Skill-Scoped MCP Configurations
- #14714 - Subagents don't inherit parent's allowed tools
Proposed syntax:
```yaml
# .claude/commands/react-coder.md
---
description: Code with React patterns
agent: code-engineer
skills:
- react/component-patterns
- react/hooks-usage
---
$ARGUMENTS
Current workaround: Include skill file paths in command prompt and hope Claude reads them - not guaranteed and poor UX.
Design principle: This enables dependency injection for AI agents - commands configure, agents execute, skills provide domain knowledge.
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗