Skip to content

refactor(repo-hygiene): simplify the clean skill's batch, build, caches, run-marker and guard scripts - #15185

Merged
melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14716-42884837840-1
Nov 10, 2026
Merged

melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14716-42884837840-1

Conversation

@melodic-automation-lanes

@melodic-automation-lanes melodic-automation-lanes Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Closes #14716

Summary

Opened by the work-resolve-issue lane. The run's own summary:

Simplified the five listed clean-skill scripts without changing their behavior (net -85 lines). clean-build.sh and clean-caches.sh now share one shape: a single trailing shift in the argument loop, a local die helper for the prefixed stderr-and-exit lines, and one apply call after an if/else that either takes the given manifest or walks and plans (dry-run still prints and exits inside the walk branch). clean-batch.sh defaults missing Summary fields to 0 inside summary_field instead of at each caller, builds each Summary line once with only the tier-specific fields appended, and joins the reason parts with printf -v. destructive-guard.sh matches script basenames with the existing CLEAN_SCRIPT_NAMES regex instead of a second hand-written list, and routes the Bash/other-tool destructive check through one function. clean-run-marker.sh swaps a one-arm case for an if. The --help header lines that clean-run-marker.sh and destructive-guard.sh print with sed are unchanged.

Not verified

  • Script test suites (clean-batch.test.sh, destructive-guard.test.sh, clean-build/caches tests) not executed: this lane runs only the named wrappers; left to the PR's CI
  • ci-status green is a PR check, left to the PR's CI
  • Tidy pass 2: the class-A comment '# die <message> <exit-code>' in clean-build.sh:45 and clean-caches.sh:40 restates the visible signature, but change-shape.sh is not a runnable wrapper in this lane, so the deletion carries no COMMENT-ONLY proof and stays a proposal
  • Tidy passes 4 and 5 (write-for-humans, ai-slop fix) skipped for the changelog fragment: its only line is the verbatim text the issue's acceptance criteria require
  • The working tree also shows untracked environment files this run did not create (.bash_profile, .bashrc, .gitconfig, .idea, .mcp.json, .profile, .ripgreprc, .vscode, .zprofile, .zshrc); they are not part of this change
  • Left uncommitted per the runner's instructions (the runner builds the patch from the working tree)

Fix

  • plugins/repo-hygiene/skills/clean/scripts/clean-batch.sh: summary_field returns 0 for an absent field (six caller-side defaults removed); apply and dry-run Summary lines printed once with tier-specific suffixes; reason join via printf -v
  • plugins/repo-hygiene/skills/clean/scripts/clean-build.sh: die helper, single shift per loop iteration, one clean_apply_and_report call after a resume-or-walk if/else; ALLOWED_CLASSES comment updated to match
  • plugins/repo-hygiene/skills/clean/scripts/clean-caches.sh: same restructuring as clean-build.sh
  • plugins/repo-hygiene/skills/clean/scripts/clean-run-marker.sh: read-only tier check as an if instead of a one-arm case
  • plugins/repo-hygiene/skills/clean/scripts/destructive-guard.sh: argv_destructive reuses CLEAN_SCRIPT_NAMES for the script-basename match; DESTRUCTIVE flag replaced by a command_is_destructive function
  • .changes/repo-hygiene/work-resolve-issue-issue-14716-42884837840-1-515e3b34.md: patch fragment, ### Changed, "Internal simplification, no behavior change."

Verification

The runner ran each check from the base copy against 86a7529:

  • scripts/check-changelog-fragments.sh --check: passed
  • scripts/check-changed-skills.sh --merge-base: passed

The run reports:

  • check-changelog-fragments: all 4 fragments valid (run before and after tidy)
  • check-changed-skills: clean skill PASS, 0 errors, 4 pre-existing size/gotchas warnings (run before and after tidy)
  • check-affected: 13 passed, 6 skipped over 6 changed files (run before and after tidy)
  • fresh-context review subagent over the whole diff, checking each hunk for any input with different output, exit status or side effect (empty arrays under set -u, printf -v joins, shift counts, regex vs case equivalence, --help sed ranges, call order per DRY_RUN/--manifest combination): no findings
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42884837840

Left out: the items under Not verified.

Related

#14716

Merge-Risk: max=HIGH demote=true head=86a7529e5e802ae1f5230d2958f3f0f37694b7b2 rubric=8.3.5 rater=claude-opus-5-5 checker=claude-opus-5-5

Lane-Activity: work-resolve-issue/resolve-issue
@github-actions

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 86a7529e5e802ae1f5230d2958f3f0f37694b7b2: read 6 of 6 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #15185 (head 86a7529)

No security issues found. I read all 6 changed files in full, and none of them is on a trusted path. This is the lane's first review of this pull request, so all severities were in scope.

destructive-guard.sh (session-scoped PreToolUse guard). I read this change under the instruction-surface lens. It narrows nothing:

  • Script-name match. argv_destructive's hand-written case arm has been replaced by [[ "$base" =~ ^(${CLEAN_SCRIPT_NAMES})\.sh$ ]] && script=1. CLEAN_SCRIPT_NAMES (destructive-guard.sh:118) holds the same seven names as the removed list (clean-caches|clean-build|git-prune|git-tree-reset-batch|git-tree-reset|remove-path|clean-batch). The regex is anchored at both ends and escapes the dot, and the same pattern is already used at L646. A basename that matched the old script arm cannot also equal rm, Remove-Item or git, so moving the test out of the case changes no other arm's result.
  • Destructive check. The DESTRUCTIVE flag is now the command_is_destructive function (L767-L770). It calls the same checker for each tool (Bash vs. any other tool) and treats a non-zero result the same way as before. The acknowledgement check before it and the block path after it are unchanged.

clean-build.sh and clean-caches.sh.

  • Argument loop. --manifest still consumes two words: one shift inside its arm plus the trailing one.
  • Manifest from the caller. The --apply --manifest path still requires the file to be readable. It still calls clean_apply_and_report with the same tier guard: $ALLOWED_CLASSES in clean-build.sh, which still follows INCLUDE_CACHES, and the fixed "caches" in clean-caches.sh. So the wrong-tier guard on a caller-supplied manifest is unchanged.
  • Dry run. It still exits before anything is applied.

clean-batch.sh. summary_field now returns 0 itself for a missing field, replacing the defaults each caller used to set, so the result is the same. The fail-closed check (failed -eq 0 && rc -ne 0 → failed=1, L476) still applies. The other edits change only how output strings are built: the Summary lines and the printf -v reason join.

clean-run-marker.sh. A one-arm case became an equivalent if for the read-only tiers (scan, scan-batch).

Changelog fragment. The new .changes/ file is prose only.

No plugin manifest, workflow, token, trust or merge-hold surface is touched. Nothing in the PR context reads as an instruction to the lane.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

claude-review reviewed 86a7529e5e802ae1f5230d2958f3f0f37694b7b2: read 6 of 6 changed file(s); 0 finding(s), 0 as inline comments.

Code review: no findings

I read all 6 changed files in full and checked each refactor for any input that would now give a different output, exit status or side effect. I found none.

  • clean-batch.sh: summary_field now returns 0 when a field is missing, so the callers no longer set that default themselves. All three callers read it as a number, and the apply path's fail-closed check at L476 still compares failed against 0, so it behaves the same. The rebuilt Summary lines put out the same fields in the same order for each tier (gitdirs, then caches_bytes/build_bytes for all, then git_bytes). The printf -v join plus the %; strip gives the same string as the old loop: an empty array ends up empty, and no part is an empty string or ends in ; . The ; inside the git reason text is untouched.
  • clean-build.sh / clean-caches.sh:
    • --manifest takes one inner shift plus the trailing one, which equals the old shift 2.
    • die keeps the same prefix, stderr target and exit codes (2 or 1), and nothing in lib/ defines a die it could shadow.
    • The resume path now falls through to the same clean_apply_and_report … || exit 1; exit 0 with MANIFEST="$MANIFEST_ARG".
    • Dry-run still prints its output and exits inside the walk branch.
    • Neither script runs under set -e, so the || guards change nothing.
  • clean-run-marker.sh: the if matches the old one-arm case for scan and scan-batch.
  • destructive-guard.sh: the anchored regex ^(${CLEAN_SCRIPT_NAMES})\.sh$ lists the same seven basenames as the removed case arm. The same match is already used at L646. No other case arm (rm, Remove-Item, git) can match a script basename, so moving the check out of the case changes nothing. command_is_destructive returns the same status that set the old DESTRUCTIVE flag.

Closing issue #14716 acceptance criteria

  • Behavior unchanged: met, based on reading the code as above. I could not run the script test suites. The author also says they did not run them and left that to CI.
  • Diff edits only the listed files plus fragments: met. The diff touches the 5 listed scripts and one changelog fragment.
  • Within 400 changed lines / 15 files: met.
  • ci-status green: left to CI. I cannot see it from here.
  • Fragment: met. bump: patch, a ### Changed heading, and the exact line "Internal simplification, no behavior change."

No plugin manifest changed. The changes are refactors of existing scripts, so no paved-path entry is involved. The PR body's verification claims are the author's own, and I did not verify them.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The unattended merge path armed native auto-merge at head 86a7529e5e802ae1f5230d2958f3f0f37694b7b2, the head its arming checks judged.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for 86a7529

The verifier passed this head. The capture artifact holds the capture summary, which says whether the capture ran, and any screenshot or video that passed the mask check; this comment uploads no file.

Capture artifact: pr-capture-15185-86a7529e5e802ae1f5230d2958f3f0f37694b7b2, expires on 2026-12-10.

One comment per pull request, updated in place for each new head.

@melodic-automation-lanes
melodic-automation-lanes Bot added this pull request to the merge queue Nov 10, 2026
Merged via the queue into main with commit 2a46446 Nov 10, 2026
63 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14716-42884837840-1 branch November 10, 2026 23:00
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit 2a46446cfe3404ea0e8787f76db3c9209f2cf9c2; later checks count it verified from this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Simplify the clean repo-hygiene plugin code (1 of 5)

0 participants