[Feature Request] Skill-as-Agent execution mode to prevent context bloat
Problem
Claude Code sessions become progressively slower over time due to context window bloat. When skills execute inline, everything accumulates in the main session context:
| Factor | Token Impact | Behavior |
|--------|--------------|----------|
| Skill instructions | 2-5K per skill | Loaded into main context |
| File reads during skill | 500-2500 per file | Stays in main context |
| Skill deliberation/output | 1-3K per skill | Never removed |
Result: Sessions that start with ~5s response time degrade to 30-60s+ after 30-60 minutes of heavy skill usage.
Root Cause
Skills and plugins execute in the main session context, but the Task tool spawns agents in isolated context. Heavy skills like code reviewers, documentation generators, and multi-agent validators would benefit from running as agents.
Proposed Solution
Add an execution block to skill YAML schema:
name: my-code-reviewer
description: Reviews code for bugs and security issues
execution:
mode: agent # "inline" | "agent" | "auto"
agent_type: reviewer # Which Task agent to spawn
return_format: structured # Return JSON, not full deliberation
max_return_tokens: 5000
thinking:
enabled: true
budget_tokens: 64000 # Full thinking capacity for agent
style: ultrathink # "quick" | "thorough" | "ultrathink"
include_context:
recent_messages: 5 # Pass recent conversation to agent
files_mentioned: true
todo_list: true
How It Would Work
┌──────────────────────┐ ┌─────────────────────────────┐
│ MAIN SESSION │ │ AGENT (isolated context) │
│ │ │ │
│ User: "/my-skill" │────▶│ [Skill instructions] │
│ │ │ [File reads] │
│ [Waits...] │ │ [64K thinking budget] │
│ │ │ [Full analysis] │
│ ◀────────────────────│─────│ │
│ [Only structured │ │ Returns: JSON summary │
│ result in context] │ └─────────────────────────────┘
└──────────────────────┘
Main session receives ~500 tokens instead of ~10K tokens.
Expected Impact
| Metric | Before | After |
|--------|--------|-------|
| Context after 60 mins | 100K tokens | ~15K tokens |
| Response latency | 45s+ | ~8s |
| Heavy skill quality | Limited by context pressure | Full 64K thinking budget |
Projected improvement: 3-5x faster sessions for heavy skill usage.
Skill Categorization
Should run as agents (heavy processing):
- Code review skills
- Documentation generation skills
- Multi-agent validation skills (BFT, TMR patterns)
- Test fixing and error investigation skills
Should stay inline (interactive):
- Brainstorming skills (needs back-and-forth dialogue)
- Pair programming skills (real-time collaboration)
- Skill builders (collaborative creation)
Implementation Scope
| Component | Owner | Effort |
|-----------|-------|--------|
| Parse execution: from skill YAML | Claude Code core | Small |
| Route mode: agent to Task tool | Claude Code core | Medium |
| Pass thinking budget to agent | Claude Code core | Small |
| Parse structured return | Claude Code core | Small |
| Update skill YAML files | Plugin authors | Incremental |
Backwards Compatibility
- Default
mode: inlinepreserves current behavior - Skills without
execution:block work unchanged - Plugin authors opt-in per skill
Questions for the Team
- Is this architecture direction aligned with Claude Code's roadmap?
- Are there existing plans for skill execution isolation?
- Would you prefer a simpler initial implementation (just
mode: agentwithout thinking config)?
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗