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
1---
2name: ccs-delegation
3description: >-
4 Auto-activate CCS CLI delegation for deterministic tasks. Parses user input,
5 auto-selects optimal profile (glm/kimi/custom) from ~/.ccs/config.json,
6 enhances prompts with context, executes via `ccs {profile} -p "task"` or
7 `ccs {profile}:continue`, and reports results. Triggers on "use ccs [task]"
8 patterns, typo/test/refactor keywords. Excludes complex architecture,
9 security-critical code, performance optimization, breaking changes.
10version: 3.0.0
11metadata:
12 source: https://skillmd.com/skills/aibot88/ccs-delegation
13---
14
15# CCS Delegation
16
17Delegate deterministic tasks to cost-optimized models via CCS CLI.
18
19## Core Concept
20
21Execute tasks via alternative models using:
22- **Initial delegation**: `ccs {profile} -p "task"`
23- **Session continuation**: `ccs {profile}:continue -p "follow-up"`
24
25**Profile Selection:**
26- Auto-select from `~/.ccs/config.json` via task analysis
27- Profiles: glm (cost-optimized), kimi (long-context/reasoning), custom profiles
28- Override: `--{profile}` flag forces specific profile
29
30## User Invocation Patterns
31
32Users trigger delegation naturally:
33- "use ccs [task]" - Auto-select best profile
34- "use ccs --glm [task]" - Force GLM profile
35- "use ccs --kimi [task]" - Force Kimi profile
36- "use ccs:continue [task]" - Continue last session
37
38**Examples:**
39- "use ccs to fix typos in README.md"
40- "use ccs to analyze the entire architecture"
41- "use ccs --glm to add unit tests"
42- "use ccs:continue to commit the changes"
43
44## Agent Response Protocol
45
46**For `/ccs [task]`:**
47
481. **Parse override flag**
49 - Scan task for pattern: `--(\w+)`
50 - If match: `profile = match[1]`, remove flag from task, skip to step 5
51 - If no match: continue to step 2
52
532. **Discover profiles**
54 - Read `~/.ccs/config.json` using Read tool
55 - Extract `Object.keys(config.profiles)` → `availableProfiles[]`
56 - If file missing → Error: "CCS not configured. Run: ccs doctor"
57 - If empty → Error: "No profiles in config.json"
58
593. **Analyze task requirements**
60 - Scan task for keywords:
61 - `/(think|analyze|reason|debug|investigate|evaluate)/i` → `needsReasoning = true`
62 - `/(architecture|entire|all files|codebase|analyze all)/i` → `needsLongContext = true`
63 - `/(typo|test|refactor|update|fix)/i` → `preferCostOptimized = true`
64
654. **Select profile**
66 - For each profile in `availableProfiles`: classify by name pattern (see Profile Characteristic Inference table)
67 - If `needsReasoning`: filter profiles where `reasoning=true` → prefer kimi
68 - Else if `needsLongContext`: filter profiles where `context=long` → prefer kimi
69 - Else: filter profiles where `cost=low` → prefer glm
70 - `selectedProfile = filteredProfiles[0]`
71 - If `filteredProfiles.length === 0`: fallback to `glm` if exists, else first available
72 - If no profiles: Error
73
745. **Enhance prompt**
75 - If task mentions files: gather context using Read tool
76 - Add: file paths, current implementation, expected behavior, success criteria
77 - Preserve slash commands at task start (e.g., `/cook`, `/commit`)
78
796. **Execute delegation**
80 - Run: `ccs {selectedProfile} -p "$enhancedPrompt"` via Bash tool
81
827. **Report results**
83 - Log: "Selected {profile} (reason: {reasoning/long-context/cost-optimized})"
84 - Report: Cost (USD), Duration (sec), Session ID, Exit code
85
86**For `/ccs:continue [follow-up]`:**
87
881. **Detect profile**
89 - Read `~/.ccs/delegation-sessions.json` using Read tool
90 - Find most recent session (latest timestamp)
91 - Extract profile name from session data
92 - If no sessions → Error: "No previous delegation. Use /ccs first"
93
942. **Parse override flag**
95 - Scan follow-up for pattern: `--(\w+)`
96 - If match: `profile = match[1]`, remove flag from follow-up, log profile switch
97 - If no match: use detected profile from step 1
98
993. **Enhance prompt**
100 - Review previous work (check what was accomplished)
101 - Add: previous context, incomplete tasks, validation criteria
102 - Preserve slash commands at start
103
1044. **Execute continuation**
105 - Run: `ccs {profile}:continue -p "$enhancedPrompt"` via Bash tool
106
1075. **Report results**
108 - Report: Profile, Session #, Incremental cost, Total cost, Duration, Exit code
109
110## Decision Framework
111
112**Delegate when:**
113- Simple refactoring, tests, typos, documentation
114- Deterministic, well-defined scope
115- No discussion/decisions needed
116
117**Keep in main when:**
118- Architecture/design decisions
119- Security-critical code
120- Complex debugging requiring investigation
121- Performance optimization
122- Breaking changes/migrations
123
124## Profile Selection Logic
125
126**Task Analysis Keywords** (scan task string with regex):
127
128| Pattern | Variable | Example |
129|---------|----------|---------|
130| `/(think\|analyze\|reason\|debug\|investigate\|evaluate)/i` | `needsReasoning = true` | "think about caching" |
131| `/(architecture\|entire\|all files\|codebase\|analyze all)/i` | `needsLongContext = true` | "analyze all files" |
132| `/(typo\|test\|refactor\|update\|fix)/i` | `preferCostOptimized = true` | "fix typo in README" |
133
134**Profile Characteristic Inference** (classify by name pattern):
135
136| Profile Pattern | Cost | Context | Reasoning |
137|----------------|------|---------|-----------|
138| `/^glm/i` | low | standard | false |
139| `/^kimi/i` | medium | long | true |
140| `/^claude/i` | high | standard | false |
141| others | low | standard | false |
142
143**Selection Algorithm** (apply filters sequentially):
144
145```
146profiles = Object.keys(config.profiles)
147classified = profiles.map(p => ({name: p, ...inferCharacteristics(p)}))
148
149if (needsReasoning):
150 filtered = classified.filter(p => p.reasoning === true).sort(['kimi'])
151else if (needsLongContext):
152 filtered = classified.filter(p => p.context === 'long').sort(['kimi'])
153else:
154 filtered = classified.filter(p => p.cost === 'low').sort(['glm', ...])
155
156selected = filtered[0] || profiles.find(p => p === 'glm') || profiles[0]
157if (!selected): throw Error("No profiles configured")
158
159log("Selected {selected} (reason: {reasoning|long-context|cost-optimized})")
160```
161
162**Override Logic**:
163- Parse task for `/--(\w+)/`. If match: `profile = match[1]`, remove from task, skip selection
164
165## Example Delegation Tasks
166
167**Good candidates:**
168- "/ccs add unit tests for UserService using Jest"
169 → Auto-selects: glm (simple task)
170- "/ccs analyze entire architecture in src/"
171 → Auto-selects: kimi (long-context)
172- "/ccs think about the best database schema design"
173 → Auto-selects: kimi (reasoning)
174- "/ccs --glm refactor parseConfig to use destructuring"
175 → Forces: glm (override)
176
177**Bad candidates (keep in main):**
178- "implement OAuth" (too complex, needs design)
179- "improve performance" (requires profiling)
180- "fix the bug" (needs investigation)
181
182## Execution
183
184**Commands:**
185- `/ccs "task"` - Intelligent delegation (auto-select profile)
186- `/ccs --{profile} "task"` - Force specific profile
187- `/ccs:continue "follow-up"` - Continue last session (auto-detect profile)
188- `/ccs:continue --{profile} "follow-up"` - Continue with profile switch
189
190**Agent via Bash:**
191- Auto: `ccs {auto-selected} -p "task"`
192- Continue: `ccs {detected}:continue -p "follow-up"`
193
194## References
195
196Template: `CLAUDE.md.template` - Copy to user's CLAUDE.md for auto-delegation config
197Troubleshooting: `references/troubleshooting.md`