Add improve-loop skill for systematic shell feature review#75
Add improve-loop skill for systematic shell feature review#75gh-worker-dd-mergequeue-cf854d[bot] merged 27 commits intomainfrom
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Improve Loop — Review PlanStarting systematic review of 49 targets in randomized order. Review order
Each target will be reviewed for security, bash compatibility, correctness, test coverage, and platform compatibility. Progress updates will be posted after each iteration. |
Improve Loop — Iteration 1:
|
Improve Loop — Iteration 2:
|
Improve Loop — Iteration 3:
|
… delimiter limitation The upstream mvdan.cc/sh library does not produce empty fields for consecutive non-whitespace IFS delimiters (e.g. IFS=: with 'a::b' should yield 'a', '', 'b' but yields 'a', 'b'). Added scenario test with skip_assert_against_bash documenting this known limitation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Improve Loop — Review PlanStarting systematic review of 48 targets in randomized order. Review order
Each target will be reviewed for security, bash compatibility, correctness, test coverage, and platform compatibility. Progress updates will be posted after each iteration. |
…nics The inline variable restoration after r.call() was not protected against panics. If r.call() panics (caught by the top-level recover in Run()), the inline variables would remain set instead of being restored, corrupting shell state for subsequent commands. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Improve Loop — Batch 1
|
Improve Loop — Batch 2
|
Improve Loop — Batch 3
|
Improve Loop — Batch 4
|
Improve Loop — Batch 5
|
- printf: Remove 'q' from C-style length modifiers list where it was incorrectly consumed before reaching the %q format specifier handler, making the "not supported" error unreachable (dead code) - grep: Add --help long flag (RULES.md requires it; -h is taken by --no-filename per POSIX grep) - Add scenario tests for both fixes Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Improve Loop — Batch 6
|
Improve Loop — Batch 7
|
Improve Loop — Batch 8
|
Improve Loop — Batch 9
|
Improve Loop — Batch 10 (Final)
|
Improve Loop Summary
Target results
Changes made
Fixes applied
Key observations
|
Improve Loop (Run 2) — Review PlanStarting systematic review of 48 targets in randomized order. Review order
Each target will be reviewed for security, bash compatibility, correctness, test coverage, and platform compatibility. Progress updates will be posted after each iteration. |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Improve Loop (Run 2) — Batch 1
|
Improve Loop — Review PlanStarting systematic review of 49 targets in randomized order. Review order
Each target will be reviewed for security, bash compatibility, correctness, test coverage, and platform compatibility. Progress updates will be posted after each iteration. |
…Err, ls joinPath - readonly: Add ReadOnly guard before KeepValue branch and unset path to prevent silent bypass of readonly enforcement - errors: Handle UnexpectedCommandError as fatal in expandErr for defense-in-depth command substitution blocking - input_processing: Return exit code 2 for parse errors (matching bash) - ls: Fix joinPath to handle Windows backslash path separator - Add Go tests for readonly runtime enforcement (reassign, unset, KeepValue) - Add Go tests for parse error exit codes (syntax error, unclosed block) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Restore explicit pr.Close() before wg.Wait() instead of using defer. When the right side of a pipeline exits without draining stdin (e.g., yes | head -1), the deferred close causes a deadlock: the left goroutine blocks on write, while the parent blocks on wg.Wait() and never reaches the deferred close. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
I can only run on private repositories. |
AlexandreYang
left a comment
There was a problem hiding this comment.
Code Review — Iteration 6
Result: COMMENT (no blocking issues)
Findings
P3 (nit) — 2 findings:
-
printf --helpexit code inconsistency:printf --helpreturns exit code 2 while every other builtin (cat,tr,sed,grep,ls,strings) returns exit code 0 for--help. Since bash'sprintfdoesn't have--helpat all, exit code 2 is a defensible choice (it matches bash's response to unknown printf flags), but it's inconsistent with the project's own convention for--helpacross builtins. Consider aligning to exit 0 for consistency, or documenting the rationale. -
Minor description mismatch:
if_then_semicolons.yamldescription says "if/then/else/fi" but the test has noelsebranch (it'sif/then/fi). The companionif_else_semicolons.yamlcovers the else case.
Previously addressed (not re-flagged)
- break/continue non-numeric arg exit code 128 — matches bash 5.2 reference
- Pipe reader explicit
pr.Close()beforewg.Wait()— prevents deadlock - Defense-in-depth comment on
vars.goreadonly check — intentional - All prior iteration findings addressed
Summary
The PR is in good shape after 5 iterations of fixes. The code changes are correct: readonly enforcement is solid with defense-in-depth guards, the exit builtin now matches bash behavior for all error cases, the expandErr handler properly blocks command substitution leaks, parse errors return exit code 2, the pipe fd handling avoids deadlocks, the defer for inline variable restoration protects against panics, and test coverage is thorough. The remaining findings are cosmetic nits only.
|
Iteration 6 self-review result: COMMENT
No blocking issues. Proceeding to address cosmetic nits. |
…hen/else/fi Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
I can only run on private repositories. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 35a9be4ec2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
AlexandreYang
left a comment
There was a problem hiding this comment.
Code Review — Iteration 7 (Final Verification)
Result: APPROVE (posted as COMMENT due to self-review restriction)
Summary
Reviewed the full diff (32 files changed, ~860 insertions, ~59 deletions) covering:
- Bash compatibility fixes: exit error messages, parse error exit code 2, loopctl too-many-args exits shell, break/continue non-numeric arg exit code 128
- New features:
--helpfor grep, ls, strings builtins; empty--script ""support - Bug fixes: printf
%qlength modifier conflict, pipe reader deadlock (pr.Close before wg.Wait), inline var restore via defer - Defense-in-depth: readonly variable guards in vars.go, UnexpectedCommandError handling in expandErr
- Test coverage: 15 new/updated scenario YAML files, 4 new Go tests (readonly, expandErr, empty script, parse errors)
Findings by Severity
| Severity | Count |
|---|---|
| P0 (Critical) | 0 |
| P1 (High) | 0 |
| P2 (Medium) | 0 |
| P3 (Nit) | 0 |
All issues from iterations 1-6 have been verified as resolved. Code is clean, tests pass, gofmt is clean.
🤖 Reviewed with Claude Code
|
Iteration 7 self-review result: APPROVE
|
On POSIX systems, backslash is a valid filename character, not a path separator. The joinPath helper in ls was unconditionally treating '\\' as a separator, which would cause incorrect path construction for directories whose names contain backslashes on Linux/macOS. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Review-Fix Loop Summary
Iteration log
Final state
Key fixes made during review loop
Remaining issuesNone — PR is clean. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5a2d60d4fd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
I can only run on private repositories. |
AlexandreYang
left a comment
There was a problem hiding this comment.
Code Review Summary — PR #75
Review result: APPROVE (posted as COMMENT since GitHub disallows self-approval)
This PR adds the improve-loop skill (a Claude Code automation tool) and a substantial batch of shell correctness fixes. After 8 prior review iterations, the code is in good shape. All tests pass.
Changes reviewed
New skill: .claude/skills/improve-loop/SKILL.md — automation tooling for systematic shell feature review. No runtime impact.
Correctness fixes (shell builtins):
exit— bash-compatible error messages and exit behavior for non-numeric/multi argsbreak/continue— bash-compatible exit codes (128 for non-numeric, shell exit for too-many-args)printf— removedqfrom length modifier list (was making%qerror unreachable);--helpexits 2 matching bashgrep/ls/strings— added--helplong flagsls—joinPathbackslash handling gated to Windows viaruntime.GOOS
Interpreter hardening:
runner_exec.go— inline variable restoration viadefer(panic safety)runner_expand.go—UnexpectedCommandErrorhandled as fatal (defense-in-depth)vars.go— readonly guard added beforeKeepValuebranch and unset pathcmd/rshell/main.go— parse errors return exit code 2; empty scripts accepted
Test coverage:
- New Go tests for readonly enforcement, expandErr, parse error exit codes
- New scenario tests for cmd_separator, empty_script, field_splitting, line_continuation, printf %q, grep/ls/strings --help
- Exit error scenarios switched from
skip_assert_against_bashtostderr_contains(better coverage)
Findings
P3 (nit):
printf.godoc comment (line 26) says--helpexits 2, but this is consistent with the implementation. Unusual compared to other builtins in this codebase that return 0 for--help, but intentional bash-compat decision from a prior iteration.
All items flagged in prior iterations (break/continue exit code 128, printf --help exit code 2, vars.go defense-in-depth comment, pipe pr.Close() ordering, ls joinPath Windows gating) have been verified as correct and intentional.
Verdict
The code is clean, well-tested, and all bash-compatibility claims have been verified against the scenario test suite. Recommending approval.
Findings by severity:
- P0 (critical): 0
- P1 (major): 0
- P2 (moderate): 0
- P3 (nit): 1
|
Iteration 1 (run 2) self-review result: APPROVE
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 849519d214
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Review-Fix Loop Summary (Run 2)
Iteration log
Final state
Remaining issuesNone — PR is clean. |
Resolve conflict in interp/runner_exec.go: combine defer-based var restore (our branch, for panic safety) with r.exit.ok() guard and r.setVarRestore (from main). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
improve-loopskill that systematically reviews and improves every shell builtin command and shell featureinterp/builtins/and shell features fromtests/scenarios/shell/as individual review targetsTest plan
/improve-loopon a test PR and verify it enumerates all targets🤖 Generated with Claude Code