3.7 KiB
3.7 KiB
Workflow: Cleanup
Model Tier
Haiku - mechanical file operations, no judgment required.
When to Use
Final step of any orchestrated workflow execution. Runs after synthesis has completed and user-facing output is ready.
Inputs
- plan_path: Path to execution plan (e.g.,
.claude/plugin-data/cc-architect/plans/current-plan.md)
Outputs
- None (files deleted)
- Optional: Archived plan in
.claude/plugin-data/cc-architect/plans/archive/
Step 1: Read Execution Plan
Read the plan file at plan_path to identify:
- All temporary files listed in step outputs (paths containing
/tasks/) - The final output path (preserved)
- Any user-requested artifacts (preserved)
Step 2: Identify Files to Delete
Delete (temporary task files):
- Any file in
.claude/plugin-data/cc-architect/tasks/ - These are intermediate outputs between workflow steps
Preserve (permanent artifacts):
- Files in
.claude/plugin-data/cc-architect/output/(synthesis results) - Any paths explicitly listed under
## Artifactsin the plan - Files outside
.claude/plugin-data/(never touch)
Step 3: Safe Deletion
Safety rules (enforced):
- ONLY delete files under
.claude/plugin-data/cc-architect/tasks/ - NEVER delete anything outside
.claude/plugin-data/ - NEVER delete the
output/directory or its contents - Verify each path starts with expected prefix before deletion
Deletion procedure:
For each temp file identified in plan:
1. Verify path contains `.claude/plugin-data/cc-architect/tasks/`
2. Verify file exists
3. Delete file
4. Log deletion
Step 4: Archive Execution Plan (Optional)
When to archive:
- Complex multi-step executions (debugging/audit trail)
- User requests plan preservation
- Execution had errors (for investigation)
Archive procedure:
- Create archive directory:
.claude/plugin-data/cc-architect/plans/archive/ - Generate timestamp:
YYYY-MM-DD-HHMMSS - Move plan:
current-plan.md->archive/{timestamp}-{request-summary}.md
When to delete instead:
- Simple single-workflow executions
- Successful completion with no issues
- User explicitly requests cleanup
Step 5: Directory Cleanup
After file deletion:
- Check if
tasks/directory is empty - If empty, remove the directory
- Leave
output/andplans/directories intact
File Classification Reference
| Path Pattern | Classification | Action |
|---|---|---|
*/tasks/*.md |
Temporary | Delete |
*/output/*.md |
Final artifact | Preserve |
*/output/final.md |
Primary output | Preserve |
*/plans/current-plan.md |
Execution plan | Archive or delete |
*/plans/archive/* |
Archived plans | Preserve |
Anything outside plugin-data/ |
External | Never touch |
Error Handling
File not found:
- Log warning, continue (file may have been manually deleted)
Permission denied:
- Log error, skip file, continue with others
- Report at end: "N files could not be deleted"
Path validation failure:
- STOP immediately
- Report: "Unsafe path detected: {path}"
- Do not delete anything else
Example Execution
Given plan with these steps:
### Step 1: Gather Context
- Output: `.claude/plugin-data/cc-architect/tasks/step-1-context.md`
### Step 2: Draft Structure
- Output: `.claude/plugin-data/cc-architect/tasks/step-2-draft.md`
### Step 3: Synthesize
- Output: `.claude/plugin-data/cc-architect/output/final.md`
Cleanup actions:
- Delete:
.claude/plugin-data/cc-architect/tasks/step-1-context.md - Delete:
.claude/plugin-data/cc-architect/tasks/step-2-draft.md - Preserve:
.claude/plugin-data/cc-architect/output/final.md - Archive or delete:
.claude/plugin-data/cc-architect/plans/current-plan.md - Remove empty
tasks/directory