Skip to content

Commit a20a78f

Browse files
committed
feat: introduce unified /ccp workflow command with automated context management
## Highlights - **New /ccp Command**: All-in-one workflow orchestration replacing separate /plan, /implement, /verify commands - **Automated Context Management**: Built-in context monitoring with automatic session clearing when approaching limits - **Claude Code 2.1.x Compatibility**: Full support for Claude Code 2.1.x versions with new skills system ## New Features - Unified `/ccp` command that orchestrates the complete plan → implement → verify workflow - Context monitor hook that tracks token usage and triggers automatic clearing at 70% threshold - Wrapper script (`wrapper.py`) for enhanced Claude Code session management - Helper utilities (`helper.py`) for context percentage tracking and clear commands - Skills-based architecture: commands migrated to `.claude/skills/` directory structure ## Breaking Changes - Commands restructured: `/plan`, `/implement`, `/verify`, `/setup` moved to skills system - Removed `tweakcc` compatibility layer (no longer needed for 2.1.x) - Settings structure updated for new hooks and skills integration ## Installer Updates - New `launch` command to run Claude Code through the wrapper - Shell alias now uses wrapper by default for context management features - Added `respectGitignore: false` to project and global Claude config - Statusline configuration installation support ## Testing - Added comprehensive unit tests for wrapper, helper, and CLI wrapper modules - Extended test coverage for claude_files and dependencies steps - All 189 unit tests passing BREAKING CHANGE: Command structure migrated from .claude/commands/ to .claude/skills/ system. The /plan, /implement, /verify commands are now skills invoked through the unified /ccp workflow or individually via the Skill tool. Users should use /ccp for the complete workflow experience.
1 parent 642d310 commit a20a78f

File tree

46 files changed

+1735
-413
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1735
-413
lines changed

.claude/commands/ccp.md

Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
---
2+
description: Claude CodePro workflow orchestration - plan, implement, verify, setup in one command
3+
argument-hint: "<task description>" or "<path/to/plan.md>"
4+
model: opus
5+
allowed-tools: Skill
6+
---
7+
# /ccp - Autonomous Workflow Orchestration
8+
9+
**The single entry point for Claude CodePro.** Handles everything: setup → plan → implement → verify.
10+
11+
## Arguments
12+
13+
```
14+
/ccp <task-description> # Start new workflow from task
15+
/ccp <path/to/plan.md> # Continue existing plan
16+
/ccp --continue <path/to/plan.md> # Resume after session clear
17+
```
18+
19+
## CRITICAL: Use the Skill Tool
20+
21+
**You MUST use the Skill tool to invoke /setup, /plan, /implement, and /verify.**
22+
23+
Do NOT just describe what to do - actually invoke the tools like this:
24+
25+
```
26+
To run /setup:
27+
Skill tool with: skill="setup"
28+
29+
To run /plan:
30+
Skill tool with: skill="plan", args="task description here"
31+
32+
To run /implement:
33+
Skill tool with: skill="implement", args="path/to/plan.md"
34+
35+
To run /verify:
36+
Skill tool with: skill="verify", args="path/to/plan.md"
37+
```
38+
39+
## Workflow Logic
40+
41+
Parse the arguments: $ARGUMENTS
42+
43+
### Step 0: ⚙️ Auto-Setup Check (ALWAYS RUN FIRST)
44+
45+
**Before ANY other action, check if setup has been completed:**
46+
47+
```bash
48+
# Check if project.md exists (indicates setup was run)
49+
ls .claude/rules/custom/project.md
50+
```
51+
52+
**If the file does NOT exist:**
53+
1. Inform user: "First-time setup detected. Running /setup to initialize project..."
54+
2. Use Skill tool: `Skill(setup)`
55+
3. After setup completes, continue to Step 1
56+
57+
**If the file exists:**
58+
- Skip setup, proceed directly to Step 1
59+
60+
This ensures the project is always properly initialized before any workflow starts.
61+
62+
### Step 1: Determine Current State
63+
64+
```
65+
IF arguments start with "--continue":
66+
plan_path = extract path after "--continue"
67+
68+
⚠️ IMPORTANT: Wait for Claude MEM to inject context
69+
Run: sleep 5 (gives SessionStart hooks time to complete)
70+
71+
→ Read plan file, check Status AND Approved fields, continue workflow
72+
73+
ELIF arguments end with ".md" AND file exists:
74+
plan_path = arguments
75+
→ Read plan file, check Status AND Approved fields
76+
77+
ELSE:
78+
task_description = arguments
79+
→ Use Skill tool to run /plan with task_description
80+
→ After plan is created, STOP and wait for user approval (see Step 2a)
81+
```
82+
83+
### Session Resume Delay
84+
85+
**When `--continue` is detected, you MUST run this first:**
86+
87+
```bash
88+
# Wait for Claude MEM SessionStart hooks to inject context
89+
sleep 5
90+
```
91+
92+
This ensures Claude MEM has time to load observations from the previous session before you continue work.
93+
94+
### Step 2: Execute Based on Status
95+
96+
After reading the plan file's Status and Approved fields:
97+
98+
| Status | Approved | Action |
99+
|--------|----------|--------|
100+
| PENDING | No | **⛔ STOP** - Request user approval (Step 2a) |
101+
| PENDING | Yes | Use Skill tool to run /implement with plan-path |
102+
| COMPLETE | * | Use Skill tool to run /verify with plan-path |
103+
| VERIFIED | * | Report completion and ask follow-up (Step 4) |
104+
105+
### Step 2a: ⛔ MANDATORY User Approval Gate
106+
107+
**When Status is PENDING and Approved is No (or missing), you MUST:**
108+
109+
1. **Summarize the plan for the user** - Provide a brief overview of what will be implemented
110+
111+
2. **Use AskUserQuestion to request approval:**
112+
```
113+
Question: "Do you approve this plan for implementation?"
114+
Header: "Plan Review"
115+
Options:
116+
- "Yes, proceed with implementation" - I've reviewed the plan and it looks good
117+
- "No, I need to make changes" - I want to edit the plan first
118+
```
119+
120+
3. **Based on user response:**
121+
122+
**If user approves ("Yes, proceed..."):**
123+
- Edit the plan file to change `Approved: No` to `Approved: Yes`
124+
- Immediately proceed to run /implement with Skill tool
125+
- Do NOT ask the user to run another command
126+
127+
**If user wants changes ("No, I need to make changes"):**
128+
- Tell user: "Please edit the plan file at `<plan-path>`, then say 'ready' when done"
129+
- Wait for user to confirm they're done editing
130+
- Re-read the plan file to see their changes
131+
- Ask for approval again using AskUserQuestion
132+
133+
4. **DO NOT proceed to /implement until user explicitly approves**
134+
135+
**This gate is NON-NEGOTIABLE. But Claude handles the file update - user never edits `Approved:` manually.**
136+
137+
### Step 3: Continue Until Done
138+
139+
After each phase completes:
140+
1. Re-read the plan file
141+
2. Check the Status AND Approved fields
142+
3. If approval gate needed, STOP and wait
143+
4. Otherwise, execute the next phase using Skill tool
144+
5. Repeat until Status is VERIFIED
145+
146+
### Step 4: Post-Verification Follow-up
147+
148+
**When Status is VERIFIED, you MUST:**
149+
150+
1. Report completion with summary
151+
2. Ask the user if there's anything else:
152+
```
153+
✅ Workflow complete! Plan status: VERIFIED
154+
155+
Summary:
156+
- [Brief summary of what was implemented]
157+
- [Key files created/modified]
158+
- [Test results]
159+
160+
Is there anything else you'd like me to help with?
161+
```
162+
163+
## Context Monitoring
164+
165+
After each major operation, check context:
166+
167+
```bash
168+
python3 .claude/scripts/helper.py check-context --json
169+
```
170+
171+
If response shows `"status": "CLEAR_NEEDED"` (context >= 95%):
172+
173+
1. Trigger session clear:
174+
```bash
175+
python3 .claude/scripts/helper.py send-clear <plan-path>
176+
```
177+
2. The wrapper will restart with `/ccp --continue <plan-path>`
178+
3. Claude Mem will inject context for the new session
179+
180+
## Error Handling
181+
182+
### Wrapper Not Running
183+
184+
If `send-clear` fails:
185+
- Tell user: "Context at X%. Please run `/clear` manually, then `/ccp --continue <plan-path>`"
186+
187+
### Plan File Not Found
188+
189+
- Tell user: "Plan file not found: <path>"
190+
- Ask if they want to create a new plan
191+
192+
## Execution Flow Example
193+
194+
```
195+
User: /ccp "add calculator with tests"
196+
197+
Claude:
198+
0. Check: Does .claude/rules/custom/project.md exist?
199+
→ NO: Run Skill(setup) first
200+
→ YES: Skip to step 1
201+
202+
1. Use Skill(plan, "add calculator with tests")
203+
→ Plan created at docs/plans/2026-01-07-calculator.md
204+
205+
2. Read plan file, Status: PENDING, Approved: No
206+
→ Summarize the plan for the user
207+
→ Use AskUserQuestion: "Do you approve this plan for implementation?"
208+
209+
User selects: "Yes, proceed with implementation"
210+
211+
3. Edit plan file: change "Approved: No" to "Approved: Yes"
212+
Use Skill(implement, docs/plans/2026-01-07-calculator.md)
213+
→ Implementation complete
214+
215+
4. Read plan file, Status: COMPLETE
216+
Use Skill(verify, docs/plans/2026-01-07-calculator.md)
217+
→ Verification passed
218+
219+
5. Read plan file, Status: VERIFIED
220+
Report: "Workflow complete! Is there anything else?"
221+
```
222+
223+
## Important
224+
225+
1. **Auto-setup on first run** - Automatically runs /setup if project.md missing
226+
2. **Always use Skill tool** - don't just describe, actually invoke
227+
3. **NEVER skip user approval** - Use AskUserQuestion to get approval, then update `Approved: Yes` yourself
228+
4. **Continue automatically after approval** - Don't tell user to run another command
229+
5. **Plan file is source of truth** - survives session clears
230+
6. **Check context regularly** - trigger clear before hitting 100%
231+
7. **Trust the wrapper** - handles session restarts automatically
232+
8. **Always ask follow-up** - After VERIFIED, ask if user needs anything else
233+
234+
ARGUMENTS: $ARGUMENTS

.claude/hooks/context_monitor.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,12 @@ def run_context_monitor() -> int:
130130
print("", file=sys.stderr)
131131
print(f"{RED}CONTEXT LIMIT: {percentage:.0f}% ({total_tokens:,}/200k){NC}", file=sys.stderr)
132132
print(f"{RED}MANDATORY: Wrap up current development NOW and update plan!{NC}", file=sys.stderr)
133-
print(f"{RED}Then ask user to run /clear to reset context.{NC}", file=sys.stderr)
134133
return 2
135134

136135
if percentage >= THRESHOLD_WARN:
137136
print("", file=sys.stderr)
138137
print(f"{YELLOW}Context: {percentage:.0f}% ({total_tokens:,}/200k){NC}", file=sys.stderr)
139-
print(f"{YELLOW} Complete current task, no new feature work{NC}", file=sys.stderr)
140-
print(f"{YELLOW} Continue work and wrap up at 95% maximum{NC}", file=sys.stderr)
138+
print(f"{YELLOW}Complete current task, no new feature work{NC}", file=sys.stderr)
141139
return 2
142140

143141
return 0

0 commit comments

Comments
 (0)