config-audit/commands/cleanup.md
Kjell Tore Guttormsen caee558e79 feat(ultraplan-local): v1.6.0 — /ultraresearch-local deep research command
Add /ultraresearch-local for structured research combining local codebase
analysis with external knowledge via parallel agent swarms. Produces research
briefs with triangulation, confidence ratings, and source quality assessment.

New command: /ultraresearch-local with modes --quick, --local, --external, --fg.
New agents: research-orchestrator (opus), docs-researcher, community-researcher,
security-researcher, contrarian-researcher, gemini-bridge (all sonnet).
New template: research-brief-template.md.

Integration: --research flag in /ultraplan-local accepts pre-built research
briefs (up to 3), enriches the interview and exploration phases. Planning
orchestrator cross-references brief findings during synthesis.

Design principle: Context Engineering — right information to right agent at
right time. Research briefs are structured artifacts in the pipeline:
ultraresearch → brief → ultraplan --research → plan → ultraexecute.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-08 08:58:35 +02:00

3.5 KiB

name description allowed-tools model
config-audit:cleanup Clean up old config-audit sessions to reclaim disk space Read, Write, Glob, Bash, AskUserQuestion sonnet

Config-Audit: Session Cleanup

Manage and clean up accumulated config-audit sessions in ~/.claude/config-audit/sessions/.

Usage

/config-audit cleanup

Implementation Steps

  1. List all sessions:

    • Glob ~/.claude/config-audit/sessions/*/state.yaml
    • For each session, read state.yaml and extract:
      • Session ID
      • Created timestamp
      • Current phase
      • Whether session is active (has next_phase and current_phase is not verify or complete)
  2. Calculate disk usage:

    • Use du -sh ~/.claude/config-audit/sessions/{session-id}/ for each session
    • Calculate total usage
  3. Display session table:

    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
    Config-Audit Sessions
    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
    
    | # | Session ID | Age | Phase | Status | Size |
    |---|------------|-----|-------|--------|------|
    | 1 | 20260127_102527 | 15d | implement | active | 12K |
    | 2 | quick-20260126 | 16d | analyze | complete | 8K |
    | 3 | 20260120_091500 | 22d | analyze | complete | 6K |
    
    Total: 3 sessions, 26K disk usage
    
  4. Ask cleanup action:

    AskUserQuestion:
      question: "Which sessions should I clean up?"
      header: "Cleanup"
      options:
        - label: "Completed sessions only (Recommended)"
          description: "Delete sessions where phase is verify/complete. Keeps active sessions safe."
        - label: "Older than 14 days"
          description: "Delete all sessions older than 14 days, regardless of status."
        - label: "All except current"
          description: "Delete everything except the most recent active session."
        - label: "Cancel"
          description: "Don't delete anything."
    
  5. Safety guards:

    • NEVER delete sessions where current_phase is not verify or complete AND next_phase exists, unless user explicitly chose age-based or all-except-current
    • Warn before deleting active sessions: "Session {id} is still active (phase: {phase}). Delete anyway?"
  6. Execute cleanup:

    • For each session to delete: rm -rf ~/.claude/config-audit/sessions/{session-id}/
    • Track deleted count and freed space
  7. Output summary:

    ✓ Cleanup complete
    
    Deleted: 2 sessions
    Freed: 14K disk space
    Remaining: 1 session (active)
    

Session Status Detection

A session is considered active if ALL of these are true:

  • current_phase is not verify and not complete
  • next_phase exists and is not empty

A session is considered complete if ANY of these are true:

  • current_phase is verify or complete
  • next_phase is empty or null

Error Handling

  • Legacy path: Also check ~/.config-audit/sessions/ for sessions created before v2.2.0. If found, include them in the session list and note: "Found {n} session(s) at legacy path (~/.config-audit/). These will be cleaned up normally."
  • If ~/.claude/config-audit/sessions/ doesn't exist (and no legacy sessions): "No sessions found. Nothing to clean up."
  • If no sessions match criteria: "No sessions match the selected criteria."
  • If deletion fails: Log error, continue with other sessions