agentleFS
thepictishbeastthepictishbeast/claude-tools/skills/fmt-sweep/SKILL.md

fmt-sweep

Skill1 starsChanged 6 months agoMITView on GitHub

Run cargo fmt --all across N Rust workspaces, verify tests still pass, commit per-repo with a uniform body, push to origin. Compresses what would otherwise be 6-8 tool calls per repo into one invocation. Use when the user says "fmt sweep", "canonicalize whitespace", or as a /loop PRIORITY 5 hygiene step.

  • Commits and pushes

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

7 rules. About 0 are common, 4 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    If drift > 0: runs cargo fmt --all to canonicalize

    line 10
  2. Distinctive:

    Default in-scope set (PlausiDen substrate):

    line 29
  3. Very specific:

    If cargo test --workspace returns non-zero post-fmt, revert the fmt changes (git checkout -- '*.rs') and bail.

    line 68
  4. Distinctive:

    No drift in any repo → exit 0 with summary

    line 87
  5. Very specific:

    Don't include any non-.rs files in the commit (generated artifacts under static/, reports/, target/ etc.

    line 99
  6. Distinctive:

    Don't fmt-sweep with uncommitted semantic changes pending in the repo — separate the cleanup pass from the feature pass.

    line 100
  7. Distinctive:

    Don't include LFI repos by default per the dedicated-instance doctrine.

    line 101

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

/fmt-sweep — multi-repo cargo fmt + test + commit + push

Walks a configured list of Rust workspaces and, per repo:

  1. Runs cargo fmt --all --check to count drifted regions
  2. If drift > 0: runs cargo fmt --all to canonicalize
  3. Runs cargo test --workspace to verify no regression
  4. chown -R paul:paul (when running as root) so the autogenerated artifacts have correct ownership before git
  5. Stages only .rs files (filters out generated static/, reports/, etc.)
  6. Commits with an auto-generated body listing the drift count + files touched
  7. Pushes to origin main

LFI repos excluded by default per feedback_lfi_out_of_scope_for_this_instance. Override via --include-lfi.

Why this exists

Surfaced 2026-05-20 during a manual fmt sweep across PlausiDen-Forge / PlausiDen-Crawler / PlausiDen-Loom / Crucible. Per-repo, the manual sequence was: cargo fmt --check → cargo fmt --all → cargo fmt --check again → cargo test --workspace → chown -R paul:paul → sudo -u paul git add (filtered) → sudo -u paul git commit (HEREDOC body) → sudo -u paul git push. That's ~8 tool calls per repo × 4 repos = 32 tool calls plus the verification + chown ceremony. Compresses to one invocation.

This is paul's contribute to claude tools repo any tasks that can be automated that can save tokens directive: each repeated agent workflow is a fmt-sweep waiting to happen.

Steps

1. Read the workspace list

Default in-scope set (PlausiDen substrate):

/home/paul/projects/PlausiDen-Forge
/home/paul/projects/PlausiDen-Loom
/home/paul/projects/PlausiDen-Crawler
/home/paul/projects/Crucible

Same overrides as workspace-tests:

  • $FMT_SWEEP_REPOS env (colon-separated absolute paths)
  • ~/.config/fmt-sweep/repos.txt (one path per line)
  • Positional args
  • --include-lfi flag

2. Per repo: drift check + apply + test

DRIFT=$(sudo -u paul cargo fmt --all --check --manifest-path "$REPO/Cargo.toml" 2>&1 | grep -c '^Diff in')
if [ "$DRIFT" -eq 0 ]; then
    printf '%-32s\tclean\n' "$(basename "$REPO")"
    continue
fi
sudo -u paul cargo fmt --all --manifest-path "$REPO/Cargo.toml"
sudo -u paul cargo test --workspace --manifest-path "$REPO/Cargo.toml" > "$LOG" 2>&1 \
  || { echo "REGRESSION in $REPO post-fmt — reverting"; git -C "$REPO" checkout -- '*.rs'; exit 1; }

3. Per repo: stage filtered + commit + push

cd "$REPO"
sudo -u paul git diff --name-only HEAD | grep '\.rs$' | xargs sudo -u paul git -C "$REPO" add
sudo -u paul git -C "$REPO" commit -m "$(printf 'chore: cargo fmt --all sweep across %s workspace\n\n%d drifted regions across N .rs files canonicalized.\nWorkspace cargo test --workspace passes post-fmt.\ncargo fmt --all --check reports 0 drift after the sweep.\n' "$(basename "$REPO")" "$DRIFT")"
sudo -u paul git -C "$REPO" push origin main

4. Rollback safety

If cargo test --workspace returns non-zero post-fmt, revert the fmt changes (git checkout -- '*.rs') and bail. Pre-existing compile errors (E0063 etc.) are NOT fmt-introduced and surface this way — the script reports the regression repo + tail-50 of the test output for the next agent to investigate.

5. Output format

PlausiDen-Forge       0 drift — clean
PlausiDen-Loom        214 drift → fmt'd → tests pass → committed b4bac18 → pushed
PlausiDen-Crawler     101 drift → fmt'd → tests pass → committed 3a0871a → pushed
Crucible              4 drift → fmt'd → tests pass → committed 6e5d37c → pushed
-----
TOTAL                 319 drifted regions canonicalized across 3 repos

6. Bypass conditions

  • No drift in any repo → exit 0 with summary
  • One repo has uncommitted non-fmt changes → skip that repo with warning
  • cargo not installed → exit 2 with the install URL
  • cargo fmt not installed → exit 2 with rustup component add rustfmt

Companion skills

  • workspace-tests — sibling skill that runs only the test step. fmt-sweep invokes workspace-tests internally as the post-fmt verification gate.
  • regression-guard — adjacent; catches per-PR regressions on a single repo.

Don't

  • Don't include any non-.rs files in the commit (generated artifacts under static/, reports/, target/ etc. drift independently and have their own commit cadence).
  • Don't fmt-sweep with uncommitted semantic changes pending in the repo — separate the cleanup pass from the feature pass.
  • Don't include LFI repos by default per the dedicated-instance doctrine.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.