Help us improve
Share bugs, ideas, or general feedback.
From cwf
Reviews Claude Code plugins, skills, codebases, and docs in modes like quick scans, git commit tidying, deep skill analysis, holistic cross-plugin checks, and docs consistency.
How this skill is triggered — by the user, by Claude, or both
Slash command
/cwf:refactorThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Control drift across code, skills, and docs as teams install and author more capabilities.
README.mdreferences/codebase-contract.mdreferences/codebase-deep-review-flow.mdreferences/deep-review-flow.mdreferences/docs-contract.mdreferences/docs-criteria.mdreferences/docs-criteria.provenance.yamlreferences/docs-review-flow.mdreferences/holistic-criteria.mdreferences/holistic-criteria.provenance.yamlreferences/holistic-review-flow.mdreferences/review-criteria.mdreferences/review-criteria.provenance.yamlreferences/session-bootstrap.mdreferences/tidying-guide.mdscripts/bootstrap-codebase-contract.shscripts/bootstrap-docs-contract.shscripts/check-codebase-contract-runtime.shscripts/check-docs-contract-runtime.shscripts/check-links.shShare bugs, ideas, or general feedback.
Control drift across code, skills, and docs as teams install and author more capabilities.
cwf:refactor Quick scan all marketplace skills
cwf:refactor --include-local-skills Quick scan marketplace + local skills
cwf:refactor --tidy [branch] Commit-based tidying (parallel sub-agents)
cwf:refactor --codebase Contract-driven whole-codebase quick scan
cwf:refactor --codebase --deep Codebase deep review with 4 expert sub-agents
cwf:refactor --skill <name> Deep review of a single skill (parallel sub-agents)
cwf:refactor --skill --holistic Cross-plugin analysis (parallel sub-agents)
cwf:refactor --docs Documentation consistency review
Philosophy:
cwf:refactor (no args) is a maintenance heartbeat for ecosystem-level drift detection.cwf:refactor --skill <name> is for focused diagnosis when one authored/installed skill needs targeted correction without paying the cost of full holistic analysis.Parse the user's input:
| Input | Mode |
|---|---|
| No args | Quick Scan |
--tidy or --tidy <branch> | Code Tidying |
--codebase | Codebase Quick Scan |
--codebase --deep | Codebase Deep Review |
--include-local-skills (no other mode flags) | Quick Scan + local skills |
--skill <name> | Deep Review |
--skill --holistic or --holistic | Holistic Analysis |
--docs | Docs Review |
Before using any criteria document, verify its provenance sidecar against the current live repository state (current skill/hook counts).
| Criteria | Provenance sidecar |
|---|---|
| review-criteria.md | review-criteria.provenance.yaml |
| holistic-criteria.md | holistic-criteria.provenance.yaml |
| docs-criteria.md | docs-criteria.provenance.yaml |
Verification command:
bash {CWF_PLUGIN_DIR}/scripts/provenance-check.sh --level inform --json
Provenance verification rules:
skill_count/hook_count with checker current.skills/current.hooks.Resolve session directory (for deterministic artifact persistence) using references/session-bootstrap.md with bootstrap key refactor-quick-scan.
Run the structural scan script and persist raw output:
bash {SKILL_DIR}/scripts/quick-scan.sh {REPO_ROOT} > {session_dir}/refactor-quick-scan.json
{REPO_ROOT} is the git repository root (5 levels up from SKILL.md in marketplace path, or use git rev-parse --show-toplevel).
Optional local-skill scope (portability hardening):
bash {SKILL_DIR}/scripts/quick-scan.sh \
{REPO_ROOT} \
--include-local-skills \
--local-skill-glob ".claude/skills/*/SKILL.md" > {session_dir}/refactor-quick-scan.json
Parse the JSON output and present a summary table. Also persist a concise summary to {session_dir}/refactor-summary.md:
| Plugin | Skill | Words | Lines | Flags |
|---|
cwf:refactor --skill <name> for a deep review."Mode: cwf:refactor (Quick Scan) and the scan command in the summary file.After writing summary artifacts, run deterministic gate:
bash {CWF_PLUGIN_DIR}/scripts/check-run-gate-artifacts.sh \
--session-dir "{session_dir}" \
--stage refactor \
--strict \
--record-lessons
--tidy [branch])Analyze recent commits for safe tidying opportunities — guard clauses, dead code removal, explaining variables. Based on Kent Beck's "Tidy First?" philosophy.
Run the script to get recent non-tidying commits:
bash {SKILL_DIR}/scripts/tidy-target-commits.sh 5 [branch]
cwf:refactor --tidy develop), pass it to the script.Resolve session directory using references/session-bootstrap.md with bootstrap key refactor-tidy.
Apply the context recovery protocol — for each commit N (1-indexed), check {session_dir}/refactor-tidy-commit-{N}.md.
For each commit hash that needs analysis, launch a parallel sub-agent using Task tool:
Task tool:
subagent_type: general-purpose
max_turns: 12
Each sub-agent prompt:
{SKILL_DIR}/references/tidying-guide.md for techniques, constraints, and output formatgit show {commit_hash}git diff {commit_hash}..HEAD -- {file} (skip modified regions){session_dir}/refactor-tidy-commit-{N}.md. At the very end of the file, append this sentinel marker on its own line: <!-- AGENT_COMPLETE -->Read all result files from the session directory ({session_dir}/refactor-tidy-commit-{N}.md for each commit) and present:
# Tidying Analysis Results
## Commit: {hash} - {message}
- suggestion 1
- suggestion 2
## Commit: {hash} - {message}
- No tidying opportunities
--codebase)Run a contract-driven quick scan across the repository codebase.
Before scanning, resolve the repository-local codebase contract:
bash {SKILL_DIR}/scripts/bootstrap-codebase-contract.sh --json
Behavior:
{artifact_root}/codebase-contract.yamlstatus=fallback with non-zero exit): stop this mode and fix bootstrap/path issues before scanningCapture metadata for final summary:
CONTRACT_STATUS: created, existing, updated, or fallback (fallback is fail-safe and must halt the stage)CONTRACT_PATHCONTRACT_WARNING (optional)Contract spec: references/codebase-contract.md
For shell strict-mode exceptions, use contract + file pragma dual control:
checks.shell_strict_mode.file_overrides# cwf: shell-strict-mode relax reason="..." ticket="..." expires="YYYY-MM-DD"For implementation/regression checks of codebase-contract behavior, run:
bash {SKILL_DIR}/scripts/check-codebase-contract-runtime.sh
Use references/session-bootstrap.md with bootstrap key refactor-codebase.
bash {SKILL_DIR}/scripts/codebase-quick-scan.sh \
{REPO_ROOT} \
--contract "{CONTRACT_PATH}" > {session_dir}/refactor-codebase-scan.json
{REPO_ROOT} is the git repository root (git rev-parse --show-toplevel).
scripts/codebase-quick-scan.sh delegates contract evaluation and findings aggregation to scripts/codebase-quick-scan.py as the backend implementation.
Read {session_dir}/refactor-codebase-scan.json and write {session_dir}/refactor-summary.md with:
Mode: cwf:refactor --codebaseCONTRACT_STATUS, CONTRACT_PATH, optional CONTRACT_WARNING)After writing summary artifacts, run deterministic gate:
bash {CWF_PLUGIN_DIR}/scripts/check-run-gate-artifacts.sh \
--session-dir "{session_dir}" \
--stage refactor \
--strict \
--record-lessons
--codebase --deep)Run codebase quick scan first, then add expert-lens deep review using 4 parallel expert sub-agents.
Full procedure: references/codebase-deep-review-flow.md
Execution contract:
bootstrap-codebase-contract.sh --json)refactor-codebase-deep){session_dir}/refactor-codebase-scan.json{session_dir}/refactor-codebase-experts.json<!-- AGENT_COMPLETE -->{session_dir}/refactor-summary.md, then run gate--skill <name>)Full procedure: references/deep-review-flow.md
Execution contract:
SKILL.md + references/ + scripts/ + assets/review-criteria.provenance.yaml)refactor-skill)--skill --holistic or --holistic)Cross-plugin analysis for global optimization. Read ALL skills and hooks, then analyze inter-plugin relationships.
Full procedure: references/holistic-review-flow.md
Execution contract:
holistic-criteria.provenance.yaml)refactor-holistic)--docs)Review documentation consistency with this fixed flow:
bootstrap-docs-contract.sh)markdownlint, local link check, doc-graph)Deterministic tool pass uses scripts/check-links.sh and scripts/doc-graph.mjs with markdownlint; for docs-contract runtime regression checks, run scripts/check-docs-contract-runtime.sh.
Use {SKILL_DIR}/references/docs-criteria.md for evaluation criteria, references/docs-contract.md for contract schema, and references/docs-review-flow.md for full --docs procedure (commands, sequence, and reporting scope).
npx claudepluginhub corca-ai/claude-plugins --plugin cwfSystem-level reorganization scan that detects shallow modules, cross-skill duplication, unused code, and vault drift. Outputs a report with structural proposals requiring human judgment for multi-file changes.
Conducts tiered code reviews for security (OWASP top 10), performance, and quality on staged git changes, PRs, or files before commits or releases.
Runs comprehensive code reviews with specialized agents for architecture, quality, errors, security, performance, accessibility, and 30+ platform-specific checks. Distinguishes new vs pre-existing issues for PRs, branches, changes.