Repository context. Gather first
<!-- BEGIN GENERATED: gather-block. Edit docs/conventions/gather-block/block.md, then run scripts/sync-gather-block.py -->
Run each command below as its own Bash call, all sent together in one message (worktree isolation).
Keep any bound in the command's own pipe (output limits).
Unless this section says otherwise, treat a failure (not a repository, git unavailable) as an unknown value and carry on. Keep these as body calls, never ## Pre-computed context lines (gather-block convention).
<!-- END GENERATED: gather-block -->
- Current branch,
git branch --show-current - Recent commits,
git log --oneline -5 - Working tree status (empty = clean),
git status --porcelain | head -20
Pre-computed context
Open chore/tidy-* PRs: !${CLAUDE_SKILL_DIR}/scripts/open-pr-count.sh 2>/dev/null | grep -E '^(Open tidy|Throttle)' || echo unknown
Comment settings (team then personal layer, one line per key): !${CLAUDE_SKILL_DIR}/scripts/comment-settings.sh 2>/dev/null | grep -E '^comment_(posture|keep_list)' || echo "(settings unavailable)"
Variables
Arguments: $ARGUMENTS
HARD path exclusions: ${user_config.hard_exclusions} (unexpanded, empty, or any value outside enforce and advisory means enforce).
Comment posture: comment_posture resolves through four layers, lowest first, a later one winning:
the default auto, userConfig (${user_config.comment_posture}), the team file
<home>/code-tidying.yaml and the personal override <home>/code-tidying.local.yaml (<home> the
repository's bound convention home, else docs/conventions), the last two from the settings line
above (${CLAUDE_SKILL_DIR}/scripts/comment-settings.sh). auto means necessary; strict, balanced and conservative read as explanatory, aggressive as
necessary. An unexpanded or empty userConfig value is unset, and any other value outside auto,
none, necessary, explanatory is named with its layer and dropped. The posture decides what
tidyings Beck 14 and P-5 may add (reference/tidyings.md).
Purpose
Tidy is the proactive Boy Scout loop: what small structural improvements can one slice of the codebase safely take today, shipped as one tight PR that never mixes structural and behavioral change? It applies Kent Beck's Tidy First? tidyings, separated from behavioral changes by commit and by PR ("Always one or the other, never both at the same time."), under the Boy Scout Rule, and keeps to structure-only work because autonomous agents introduce defects measurably more often in unhealthy code (Tornhill / CodeScene). Its value is rotated lane discipline, a scope budget, structure-only commits, and research before editing.
Not: /simplify, which tightens the conversation's recent diff, while tidy hunts a lane independent of recent activity; batch-simplify, which sweeps a time window, a branch, or the repository in waves (on docs it owns factual staleness across the whole doc set in one pass, while tidy's docs-prose lane owns incremental structural prose work under a scope budget); issue-tracker work, since tidy never starts from a filed item and files its overflow as deferred items; a docs fact-checker, since tidy improves structure, not factual accuracy.
Action Router
Parse $ARGUMENTS to determine the action. The argument hint shows dry-run without its
[<lane>|<glob>...] to stay within its length budget; the table below lists every form.
| Argument | Action | Use case |
|----------|--------|----------|
| (empty) | Smart default | Infer the most appropriate lane from current branch / recent commits / git status. If the inference is ambiguous, pause and ask the user. Otherwise proceed as if <lane> was passed. |
| <lane> (from the catalog below) | Targeted lane run | Load the lane file, run the full Workflow on that lane's scope. |
| <glob>... | Ad hoc scope | No lane covers the files. Run the full Workflow on those globs per Ad hoc scope when no lane fits below. Combines with dry-run. |
| dry-run [<lane>] | Plan + present, no edits | Run Phases A-D (triage, explore, research, hunt). Present the prioritized findings table and the proposed PR scope. No edits, no branch, no push, no tracker items. The user reviews and decides whether to proceed. |
| self-update | Maintainer lane | Shorthand for <lane>=self-update. Operates on this plugin's own files. Valid only in a working-tree checkout of the plugin (marketplace clone or --plugin-dir), never an installed copy. Manual-merge always. |
| help | Print this Action Router + lane catalog | Diagnostic / orientation. |
| override (flag, combines with any row above) | Lift the GLOBAL HARD path list for this run, behind an enumeration gate | The user wants this lane's tidyings to reach a path the HARD list would otherwise drop (agent config, a CI workflow, lint config). Strip the token before reading the rest of $ARGUMENTS; match it whole, never as a substring, and treat ./override as a path. Because a lane is a glob set rather than a named file, Phase D enumerates the specific HARD paths it intends to touch and takes a go-ahead on that list before Phase E edits any of them; non-interactive, the run reports the list and proceeds without those edits (reference/exclusions.md section 4). dry-run override produces the enumeration alone. Path entries only: the behavioral guards, the work-tracking entries, SELF-UPDATE EXTRA HARD, and the override machinery itself hold regardless. Every lifted path is named in Phase H's report with the channel that lifted it. |
| in-place or in-place=commit (flag, combines with the smart default, <lane>, and override) | Run on the current branch, no branch, no PR | A caller already holds the branch and PR (a repo-sweep playbook, a feature branch). Strip the token before reading the rest of $ARGUMENTS, matched whole like override. Phase B stays on the current branch and refuses the default branch; Phase E stages tidyings without committing; Phase H opens no PR and posts no comment, and prints its report to the user instead. in-place leaves the changes staged; in-place=commit makes one commit of them. The backlog throttle does not apply; every other gate (exclusions, scope budget, verification, self-review) still runs, measured on the staged diff. |
| --repo <repo> (and the other target forms; combines with any row above but in-place and help) | The run once per repository | Strip the target-form tokens before reading the rest of $ARGUMENTS, then run per Over several repositories below. |
Over several repositories
With no target form, the run covers this checkout, as it always has. A target form (--repo,
--repos-from, --owner, --fleet, --skip, or the same request in words) selects several
repositories, which resolve, count, fan out and merge as