[FEATURE] Command-triggered agent spawning with skill injection

Resolved 💬 5 comments Opened Dec 20, 2025 by jmpascaldoctolib Closed Mar 1, 2026

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-engineer agent: 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:

  1. Which agent to spawn
  2. 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

  1. No agent duplication - One generic agent definition
  2. Context-aware execution - Right skills for right context
  3. Composable architecture - Agents define "what", skills define "how"
  4. Easy to extend - Add new context = add new command + skills (no agent changes)
  5. 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

  1. Skill loading: Skills should be loaded into agent context before execution
  2. Precedence: Command-injected skills should supplement (not replace) agent's native skills
  3. Validation: Warn if specified skill doesn't exist
  4. 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

  1. I have a monorepo with a React frontend (/frontend) and a Rust backend (/backend)
  2. I've created a generic code-engineer agent that writes production-quality code
  3. I've created skills for each stack:
  • react/component-patterns - React best practices
  • react/hooks-usage - Hook patterns
  • rust/error-handling - Rust Result/Option patterns
  • rust/async-patterns - Tokio async patterns
  1. 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)
  1. With this feature, I could:
  • Create /react-coder command that spawns code-engineer + React skills
  • Create /rust-coder command that spawns code-engineer + Rust skills
  • One agent definition, multiple context-aware entry points
  1. 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.

View original on GitHub ↗

This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗