.claude/skills/complexity-audit/SKILL.md
Orchestrates the full four-phase complexity audit pipeline for any target path or glob pattern in the Orchestra codebase. Use this skill when a user requests a complexity audit, tech-debt audit, refactor assessment, or complexity analysis. Triggers on: complexity audit, run audit, tech debt audit, audit backend, audit frontend, audit services, audit components, measure complexity, complexity report, refactor audit, code quality audit. Accepts a target path (e.g., `backend/src/services/`, `frontend/src/components/`, or `all`) and an optional existing GitHub issue URL. Handles all setup — issue creation, branch, worktree, .audit/ directory — then delegates execution to the complexity-auditor agent, and finishes with PR reporting.
npx skillsauth add ruska-ai/orchestra complexity-auditInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Runs a four-phase complexity audit (measure, identify patterns, benchmark, draft PR) on a specified
target path. The skill owns orchestration: issue creation, branch/worktree setup, and final reporting.
The complexity-auditor agent owns execution.
TARGET: $ARGUMENTS.target (required — path or glob pattern, e.g., backend/src/services/,
frontend/src/components/, or all)
ISSUE_URL: $ARGUMENTS.url (optional — existing GitHub issue URL to skip issue creation)
ORCHESTRA_PROJECT_ROOT: The orchestra git repository root where .claude/, .worktrees/, and
Makefile live. Resolve via git rev-parse --show-toplevel. All paths anchor to this variable.
MANDATORY first step. Read the issue template before any other work.
.github/ISSUE_TEMPLATE/complexity_audit.md for conventions:
refactor/[issue#]-complexity-audit)FROM refactor/[issue#]-complexity-audit TO development)$ORCHESTRA_PROJECT_ROOT/.worktrees/refactor-[issue#]).audit/ directory deliverables (complexity_ranking.md, pattern_recommendations.yaml, benchmarks/)ORCHESTRA_PROJECT_ROOT:
git rev-parse --show-toplevelbackend/ or *.py patterns → Python (radon)frontend/ or *.ts/*.tsx patterns → TypeScript (escomplex, jscpd)all → both Python and TypeScripthttps://github.com/<owner>/<repo>/issues/<number>)gh issue view <ISSUE_URL> --json number,title,body,labels## Scope
- **Target**: <TARGET>
- **Language(s)**: <determined from TARGET>
- **Reason for audit**: Complexity audit requested via /complexity-audit skill
## Four Mandatory Phases
Follows the complexity audit protocol defined in `.github/ISSUE_TEMPLATE/complexity_audit.md`.
## Acceptance Criteria
- [ ] Phase 1 ranking complete (`.audit/complexity_ranking.md`)
- [ ] Phase 2 recommendations (`.audit/pattern_recommendations.yaml`) with estimated deltas
- [ ] Phase 3 benchmark suite with baseline/current snapshots and PASS/FAIL report
- [ ] Phase 4 draft PR created with full benchmark data in body
- [ ] Test count >= baseline; pass rate = 100%
gh issue create \
--title "audit: <TARGET>" \
--body "<composed body>" \
--label "tech-debt,complexity-audit"
refactor/<issue#>-complexity-audit$ORCHESTRA_PROJECT_ROOT/.worktrees/refactor-<issue#>git fetch origin developmentgit worktree add $ORCHESTRA_PROJECT_ROOT/.worktrees/refactor-<issue#> -b refactor/<issue#>-complexity-audit origin/development.audit/ directory structure:
mkdir -p $ORCHESTRA_PROJECT_ROOT/.worktrees/refactor-<issue#>/.audit/benchmarkscd $ORCHESTRA_PROJECT_ROOT/.worktrees/refactor-<issue#> && bash $ORCHESTRA_PROJECT_ROOT/backend/scripts/changelog.shcd $ORCHESTRA_PROJECT_ROOT/.worktrees/refactor-<issue#> && git add Changelog.md .audit/ && git commit -s -m "init refactor/<issue#>-complexity-audit"cd $ORCHESTRA_PROJECT_ROOT/.worktrees/refactor-<issue#> && git push -u origin refactor/<issue#>-complexity-auditgh issue comment <issue#> --body "$(cat <<'EOF'
## Audit Started
**Branch**: `refactor/<issue#>-complexity-audit`
**Worktree**: `$ORCHESTRA_PROJECT_ROOT/.worktrees/refactor-<issue#>`
**PR title**: `FROM refactor/<issue#>-complexity-audit TO development`
**Target**: `<TARGET>`
EOF
)"
cd $ORCHESTRA_PROJECT_ROOT/.worktrees/refactor-<issue#> && gh pr create \
--draft \
--base development \
--title "FROM refactor/<issue#>-complexity-audit TO development" \
--body "$(cat <<'EOF'
## Summary
Resolves #<issue#>
**Target**: `<TARGET>`
**Language(s)**: <language(s)>
## Status
Audit in progress — this PR will be updated with benchmark results when the complexity-auditor agent completes.
Generated by `/complexity-audit` skill.
EOF
)"
Hand off execution to the complexity-auditor agent. The agent runs all four audit phases inside the
worktree.
Run a complexity audit on <TARGET> in the worktree at
$ORCHESTRA_PROJECT_ROOT/.worktrees/refactor-<issue#> on branch
refactor/<issue#>-complexity-audit.
Issue: #<issue#>
Language(s): <language(s)>
Worktree: $ORCHESTRA_PROJECT_ROOT/.worktrees/refactor-<issue#>
Follow the four-phase audit protocol from .github/ISSUE_TEMPLATE/complexity_audit.md:
- Phase 1: Measure (produce .audit/complexity_ranking.md)
- Phase 2: Identify patterns (produce .audit/pattern_recommendations.yaml)
- Phase 3: Benchmark (produce .audit/benchmarks/ snapshots)
- Phase 4: Apply refactors with atomic commits
Commit and push after each phase. All work inside the worktree only.
ls $ORCHESTRA_PROJECT_ROOT/.worktrees/refactor-<issue#>/.audit/complexity_ranking.md, pattern_recommendations.yaml, benchmarks/cat $ORCHESTRA_PROJECT_ROOT/.worktrees/refactor-<issue#>/.audit/complexity_ranking.mdcat $ORCHESTRA_PROJECT_ROOT/.worktrees/refactor-<issue#>/.audit/pattern_recommendations.yamlls $ORCHESTRA_PROJECT_ROOT/.worktrees/refactor-<issue#>/.audit/benchmarks/## Summary
Resolves #<issue#>
**Target**: `<TARGET>`
**Language(s)**: <language(s)>
## Complexity Ranking (Top 10)
<excerpt from .audit/complexity_ranking.md — top 10 highest-scoring files>
## Pattern Recommendations
<excerpt from .audit/pattern_recommendations.yaml — recommended patterns with estimated impact>
## Benchmark Results
<benchmark gate results: CC delta, duplication delta, test pass rate>
## Phases Completed
- [x] Phase 1: Measure (`.audit/complexity_ranking.md`)
- [x] Phase 2: Identify patterns (`.audit/pattern_recommendations.yaml`)
- [x] Phase 3: Benchmark (`.audit/benchmarks/`)
- [x] Phase 4: Refactors applied with atomic commits
Generated by `/complexity-audit` skill.
cd $ORCHESTRA_PROJECT_ROOT/.worktrees/refactor-<issue#> && gh pr edit --body "<reviewer report>"cd $ORCHESTRA_PROJECT_ROOT/.worktrees/refactor-<issue#> && gh pr ready## Complexity Audit Complete
**Issue**: #<issue#> — audit: <TARGET>
**Branch**: refactor/<issue#>-complexity-audit
**Worktree**: $ORCHESTRA_PROJECT_ROOT/.worktrees/refactor-<issue#>
**PR**: <PR URL> (draft -> ready for review)
**Target**: <TARGET>
**Language(s)**: <language(s)>
### Audit Artifacts
- .audit/complexity_ranking.md — ranked complexity table
- .audit/pattern_recommendations.yaml — pattern recommendations
- .audit/benchmarks/ — baseline and post-refactor snapshots
### Next Steps
- Review PR at <PR URL>
- Check benchmark gate results in PR description
- Merge when all acceptance criteria are satisfied
target argument. Example: /complexity-audit target=backend/src/services/"gh auth status"git worktree remove $ORCHESTRA_PROJECT_ROOT/.worktrees/refactor-<issue#> first."cd $ORCHESTRA_PROJECT_ROOT/.worktrees/refactor-<issue#> && git push -u origin refactor/<issue#>-complexity-audit".audit/ directory creation — the agent writes deliverables there-s flag) per repository guidelinesUser: "Run a complexity audit on backend/src/services/"
Assistant: I'll orchestrate a complexity audit on backend/src/services/.
.github/ISSUE_TEMPLATE/complexity_audit.md for conventionsaudit: backend/src/services/ with labels tech-debt,complexity-auditrefactor/885-complexity-audit and worktree .worktrees/refactor-885User: "Run a complexity audit on frontend/src/components/ — use issue https://github.com/ruska-ai/orchestra/issues/890" Assistant: I'll use existing issue #890 and skip issue creation.
refactor/890-complexity-audit and worktree .worktrees/refactor-890User: "Audit all — I want a complexity report for the entire codebase" Assistant: I'll audit both backend (Python) and frontend (TypeScript) targets.
audit: all.audit/complexity_ranking.md across all filestools
Apply coordinated changes across multiple files efficiently using parallel Edit tool calls. Use when making systematic changes like renaming variables, updating imports, applying pattern changes, or refactoring across files. Triggers on: rename across files, update all imports, change pattern in multiple files, refactor across codebase, batch edit files.
testing
Record browser workflows as video and convert to high-quality GIFs using agent-browser and ffmpeg. Use when users ask to record workflow, create gif, record demo, browser recording, workflow gif, or screen recording.
development
Run and verify frontend tests for the React/Vite application.
development
Run and verify backend tests for the FastAPI/Python application.