CCS Delegation
Delegate deterministic tasks to cost-optimized models via CCS CLI.
Core Concept
Execute tasks via alternative models using:
- Initial delegation:
ccs {profile} -p "task"
- Session continuation:
ccs {profile}:continue -p "follow-up"
Profile Selection:
- Auto-select from
~/.ccs/config.json via task analysis
- Profiles: glm (cost-optimized), kimi (long-context/reasoning), custom profiles
- Override:
--{profile} flag forces specific profile
User Invocation Patterns
Users trigger delegation naturally:
- "use ccs [task]" - Auto-select best profile
- "use ccs --glm [task]" - Force GLM profile
- "use ccs --kimi [task]" - Force Kimi profile
- "use ccs:continue [task]" - Continue last session
Examples:
- "use ccs to fix typos in README.md"
- "use ccs to analyze the entire architecture"
- "use ccs --glm to add unit tests"
- "use ccs:continue to commit the changes"
Agent Response Protocol
For /ccs [task]:
Parse override flag
- Scan task for pattern:
--(\w+)
- If match:
profile = match[1], remove flag from task, skip to step 5
- If no match: continue to step 2
Discover profiles
- Read
~/.ccs/config.json using Read tool
- Extract
Object.keys(config.profiles) → availableProfiles[]
- If file missing → Error: "CCS not configured. Run: ccs doctor"
- If empty → Error: "No profiles in config.json"
Analyze task requirements
- Scan task for keywords:
/(think|analyze|reason|debug|investigate|evaluate)/i → needsReasoning = true
/(architecture|entire|all files|codebase|analyze all)/i → needsLongContext = true
/(typo|test|refactor|update|fix)/i → preferCostOptimized = true
Select profile
- For each profile in
availableProfiles: classify by name pattern (see Profile Characteristic Inference table)
- If
needsReasoning: filter profiles where reasoning=true → prefer kimi
- Else if
needsLongContext: filter profiles where context=long → prefer kimi
- Else: filter profiles where
cost=low → prefer glm
selectedProfile = filteredProfiles[0]
- If
filteredProfiles.length === 0: fallback to glm if exists, else first available
- If no profiles: Error
Enhance prompt
- If task mentions files: gather context using Read tool
- Add: file paths, current implementation, expected behavior, success criteria
- Preserve slash commands at task start (e.g.,
/cook, /commit)
Execute delegation
- Run:
ccs {selectedProfile} -p "$enhancedPrompt" via Bash tool
Report results
- Log: "Selected {profile} (reason: {reasoning/long-context/cost-optimized})"
- Report: Cost (USD), Duration (sec), Session ID, Exit code
For /ccs:continue [follow-up]:
Detect profile
- Read
~/.ccs/delegation-sessions.json using Read tool
- Find most recent session (latest timestamp)
- Extract profile name from session data
- If no sessions → Error: "No previous delegation. Use /ccs first"
Parse override flag
- Scan follow-up for pattern:
--(\w+)
- If match:
profile = match[1], remove flag from follow-up, log profile switch
- If no match: use detected profile from step 1
Enhance prompt
- Review previous work (check what was accomplished)
- Add: previous context, incomplete tasks, validation criteria
- Preserve slash commands at start
Execute continuation
- Run:
ccs {profile}:continue -p "$enhancedPrompt" via Bash tool
Report results
- Report: Profile, Session #, Incremental cost, Total cost, Duration, Exit code
Decision Framework
Delegate when:
- Simple refactoring, tests, typos, documentation
- Deterministic, well-defined scope
- No discussion/decisions needed
Keep in main when:
- Architecture/design decisions
- Security-critical code
- Complex debugging requiring investigation
- Performance optimization
- Breaking changes/migrations
Profile Selection Logic
Task Analysis Keywords (scan task string with regex):
| Pattern |
Variable |
Example |
/(think|analyze|reason|debug|investigate|evaluate)/i |
needsReasoning = true |
"think about caching" |
/(architecture|entire|all files|codebase|analyze all)/i |
needsLongContext = true |
"analyze all files" |
/(typo|test|refactor|update|fix)/i |
preferCostOptimized = true |
"fix typo in README" |
Profile Characteristic Inference (classify by name pattern):
| Profile Pattern |
Cost |
Context |
Reasoning |
/^glm/i |
low |
standard |
false |
/^kimi/i |
medium |
long |
true |
/^claude/i |
high |
standard |
false |
| others |
low |
standard |
false |
Selection Algorithm (apply filters sequentially):
profiles = Object.keys(config.profiles)
classified = profiles.map(p => ({name: p, ...inferCharacteristics(p)}))
if (needsReasoning):
filtered = classified.filter(p => p.reasoning === true).sort(['kimi'])
else if (needsLongContext):
filtered = classified.filter(p => p.context === 'long').sort(['kimi'])
else:
filtered = classified.filter(p => p.cost === 'low').sort(['glm', ...])
selected = filtered[0] || profiles.find(p => p === 'glm') || profiles[0]
if (!selected): throw Error("No profiles configured")
log("Selected {selected} (reason: {reasoning|long-context|cost-optimized})")
Override Logic:
- Parse task for
/--(\w+)/. If match: profile = match[1], remove from task, skip selection
Example Delegation Tasks
Good candidates:
- "/ccs add unit tests for UserService using Jest"
→ Auto-selects: glm (simple task)
- "/ccs analyze entire architecture in src/"
→ Auto-selects: kimi (long-context)
- "/ccs think about the best database schema design"
→ Auto-selects: kimi (reasoning)
- "/ccs --glm refactor parseConfig to use destructuring"
→ Forces: glm (override)
Bad candidates (keep in main):
- "implement OAuth" (too complex, needs design)
- "improve performance" (requires profiling)
- "fix the bug" (needs investigation)
Execution
Commands:
/ccs "task" - Intelligent delegation (auto-select profile)
/ccs --{profile} "task" - Force specific profile
/ccs:continue "follow-up" - Continue last session (auto-detect profile)
/ccs:continue --{profile} "follow-up" - Continue with profile switch
Agent via Bash:
- Auto:
ccs {auto-selected} -p "task"
- Continue:
ccs {detected}:continue -p "follow-up"
References
Template: CLAUDE.md.template - Copy to user's CLAUDE.md for auto-delegation config
Troubleshooting: references/troubleshooting.md
Source: kaitranntt/ccs — distributed by TomeVault.
1---2name: kaitranntt-ccs-ccs3description: CCS Delegation4---56# CCS Delegation78Delegate deterministic tasks to cost-optimized models via CCS CLI.910## Core Concept1112Execute tasks via alternative models using:13- **Initial delegation**: `ccs {profile} -p "task"`14- **Session continuation**: `ccs {profile}:continue -p "follow-up"`1516**Profile Selection:**17- Auto-select from `~/.ccs/config.json` via task analysis18- Profiles: glm (cost-optimized), kimi (long-context/reasoning), custom profiles19- Override: `--{profile}` flag forces specific profile2021## User Invocation Patterns2223Users trigger delegation naturally:24- "use ccs [task]" - Auto-select best profile25- "use ccs --glm [task]" - Force GLM profile26- "use ccs --kimi [task]" - Force Kimi profile27- "use ccs:continue [task]" - Continue last session2829**Examples:**30- "use ccs to fix typos in README.md"31- "use ccs to analyze the entire architecture"32- "use ccs --glm to add unit tests"33- "use ccs:continue to commit the changes"3435## Agent Response Protocol3637**For `/ccs [task]`:**38391. **Parse override flag**40 - Scan task for pattern: `--(\w+)`41 - If match: `profile = match[1]`, remove flag from task, skip to step 542 - If no match: continue to step 243442. **Discover profiles**45 - Read `~/.ccs/config.json` using Read tool46 - Extract `Object.keys(config.profiles)` → `availableProfiles[]`47 - If file missing → Error: "CCS not configured. Run: ccs doctor"48 - If empty → Error: "No profiles in config.json"49503. **Analyze task requirements**51 - Scan task for keywords:52 - `/(think|analyze|reason|debug|investigate|evaluate)/i` → `needsReasoning = true`53 - `/(architecture|entire|all files|codebase|analyze all)/i` → `needsLongContext = true`54 - `/(typo|test|refactor|update|fix)/i` → `preferCostOptimized = true`55564. **Select profile**57 - For each profile in `availableProfiles`: classify by name pattern (see Profile Characteristic Inference table)58 - If `needsReasoning`: filter profiles where `reasoning=true` → prefer kimi59 - Else if `needsLongContext`: filter profiles where `context=long` → prefer kimi60 - Else: filter profiles where `cost=low` → prefer glm61 - `selectedProfile = filteredProfiles[0]`62 - If `filteredProfiles.length === 0`: fallback to `glm` if exists, else first available63 - If no profiles: Error64655. **Enhance prompt**66 - If task mentions files: gather context using Read tool67 - Add: file paths, current implementation, expected behavior, success criteria68 - Preserve slash commands at task start (e.g., `/cook`, `/commit`)69706. **Execute delegation**71 - Run: `ccs {selectedProfile} -p "$enhancedPrompt"` via Bash tool72737. **Report results**74 - Log: "Selected {profile} (reason: {reasoning/long-context/cost-optimized})"75 - Report: Cost (USD), Duration (sec), Session ID, Exit code7677**For `/ccs:continue [follow-up]`:**78791. **Detect profile**80 - Read `~/.ccs/delegation-sessions.json` using Read tool81 - Find most recent session (latest timestamp)82 - Extract profile name from session data83 - If no sessions → Error: "No previous delegation. Use /ccs first"84852. **Parse override flag**86 - Scan follow-up for pattern: `--(\w+)`87 - If match: `profile = match[1]`, remove flag from follow-up, log profile switch88 - If no match: use detected profile from step 189903. **Enhance prompt**91 - Review previous work (check what was accomplished)92 - Add: previous context, incomplete tasks, validation criteria93 - Preserve slash commands at start94954. **Execute continuation**96 - Run: `ccs {profile}:continue -p "$enhancedPrompt"` via Bash tool97985. **Report results**99 - Report: Profile, Session #, Incremental cost, Total cost, Duration, Exit code100101## Decision Framework102103**Delegate when:**104- Simple refactoring, tests, typos, documentation105- Deterministic, well-defined scope106- No discussion/decisions needed107108**Keep in main when:**109- Architecture/design decisions110- Security-critical code111- Complex debugging requiring investigation112- Performance optimization113- Breaking changes/migrations114115## Profile Selection Logic116117**Task Analysis Keywords** (scan task string with regex):118119| Pattern | Variable | Example |120|---------|----------|---------|121| `/(think\|analyze\|reason\|debug\|investigate\|evaluate)/i` | `needsReasoning = true` | "think about caching" |122| `/(architecture\|entire\|all files\|codebase\|analyze all)/i` | `needsLongContext = true` | "analyze all files" |123| `/(typo\|test\|refactor\|update\|fix)/i` | `preferCostOptimized = true` | "fix typo in README" |124125**Profile Characteristic Inference** (classify by name pattern):126127| Profile Pattern | Cost | Context | Reasoning |128|----------------|------|---------|-----------|129| `/^glm/i` | low | standard | false |130| `/^kimi/i` | medium | long | true |131| `/^claude/i` | high | standard | false |132| others | low | standard | false |133134**Selection Algorithm** (apply filters sequentially):135136```137profiles = Object.keys(config.profiles)138classified = profiles.map(p => ({name: p, ...inferCharacteristics(p)}))139140if (needsReasoning):141 filtered = classified.filter(p => p.reasoning === true).sort(['kimi'])142else if (needsLongContext):143 filtered = classified.filter(p => p.context === 'long').sort(['kimi'])144else:145 filtered = classified.filter(p => p.cost === 'low').sort(['glm', ...])146147selected = filtered[0] || profiles.find(p => p === 'glm') || profiles[0]148if (!selected): throw Error("No profiles configured")149150log("Selected {selected} (reason: {reasoning|long-context|cost-optimized})")151```152153**Override Logic**:154- Parse task for `/--(\w+)/`. If match: `profile = match[1]`, remove from task, skip selection155156## Example Delegation Tasks157158**Good candidates:**159- "/ccs add unit tests for UserService using Jest"160 → Auto-selects: glm (simple task)161- "/ccs analyze entire architecture in src/"162 → Auto-selects: kimi (long-context)163- "/ccs think about the best database schema design"164 → Auto-selects: kimi (reasoning)165- "/ccs --glm refactor parseConfig to use destructuring"166 → Forces: glm (override)167168**Bad candidates (keep in main):**169- "implement OAuth" (too complex, needs design)170- "improve performance" (requires profiling)171- "fix the bug" (needs investigation)172173## Execution174175**Commands:**176- `/ccs "task"` - Intelligent delegation (auto-select profile)177- `/ccs --{profile} "task"` - Force specific profile178- `/ccs:continue "follow-up"` - Continue last session (auto-detect profile)179- `/ccs:continue --{profile} "follow-up"` - Continue with profile switch180181**Agent via Bash:**182- Auto: `ccs {auto-selected} -p "task"`183- Continue: `ccs {detected}:continue -p "follow-up"`184185## References186187Template: `CLAUDE.md.template` - Copy to user's CLAUDE.md for auto-delegation config188Troubleshooting: `references/troubleshooting.md`189190---191> Source: [kaitranntt/ccs](https://github.com/kaitranntt/ccs) — distributed by [TomeVault](https://tomevault.io).192<!-- tomevault:4.0:skill_md:2026-06-27 -->