Skip to content

Require Every CLI Script to Answer Help and Refuse Unknown Arguments - #2832

Merged
ptr727 merged 3 commits into
developfrom
feature/auto-2285
Oct 11, 2026
Merged

ptr727 merged 3 commits into
developfrom
feature/auto-2285

Conversation

@ptr727

@ptr727 ptr727 commented Oct 11, 2026

Copy link
Copy Markdown
Owner

Adds the CODESTYLE.md General "Command-Line Arguments" rule (every CLI script answers --help and refuses unknown arguments before it reads or writes anything) and the tests/test_cli_usage.py gate that enforces it, and brings the existing scripts into line.

Closes on promotion: #2285

Known items, each with its class:

Local gates run: ruff format and check, mypy, prose gate, repo_gate.py, spec/validate.py, build_dist.py --check, and the full unittest suite (2550 tests, OK).

🤖 Generated with Claude Code

ptr727 and others added 3 commits October 11, 2026 02:32
CODESTYLE.md General now states that every command-line script answers
--help and -h with its usage and exit 0, and refuses an argument it does
not recognize before any read or write. The shell-codestyle Skill carries
that section as a generated include.

tests/test_cli_usage.py discovers every tracked shell, PowerShell, and
Python entry point and runs each with --help and --bogus-flag beside
recording stubs for gh, curl, and the other network or host-changing
commands, asserting help exits 0 with usage, the flag is refused, no
stub is reached, and the tree is unchanged.

The scripts the gate found breaking the rule are fixed: spec/validate.py,
spec/workflow_reuse.py, spec/fidelity_honesty.py,
spec/resolve_description.py, and the python-directories action now parse
their arguments with argparse. hub-fetch-run.py answers help and refuses
an option before any fetch. install-tools.ps1 and setup-wsl.ps1 refuse a
dash-prefixed positional before any read, and setup-wsl.ps1 refuses a
distribution name outside -Install.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The gate's proxy is now a local listener recording every connection, so
a script that takes an unknown flag as a target and fetches it fails the
gate rather than passing on the fetch's own failure. Help is asked with
-h as well as --help, and the case skips on Windows, where a stub with
no executable extension shadows nothing.

python-codestyle carries the Command-Line Arguments section as a
generated include beside shell-codestyle, and the rule says help
changes nothing rather than writes nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings October 11, 2026 18:04
@coderabbitai

coderabbitai Bot commented Oct 11, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Repository: ptr727/ProjectTemplate/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 596fa07b-0f91-45ad-8e0a-ca0927c5ab0b

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 14.81481% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.26%. Comparing base (65c14a2) to head (8d0648f).
⚠️ Report is 2 commits behind head on develop.

Files with missing lines Patch % Lines
spec/workflow_reuse.py 0.00% 9 Missing ⚠️
spec/fidelity_honesty.py 0.00% 6 Missing ⚠️
spec/resolve_description.py 25.00% 6 Missing ⚠️
spec/validate.py 50.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2832      +/-   ##
===========================================
- Coverage    60.31%   60.26%   -0.05%     
===========================================
  Files           16       16              
  Lines         8479     8489      +10     
===========================================
+ Hits          5114     5116       +2     
- Misses        3365     3373       +8     
Flag Coverage Δ
python-3.13 60.26% <14.81%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The gate skips Windows entirely and cannot discover extensionless command-line scripts.

2 open findings
What changed in this PR

This PR adds a fleet-wide command-line argument rule and a test gate for scripts shipped by ProjectTemplate. It also updates existing entry points to answer help requests and reject unknown arguments.

Changes:

  • Define the rule in CODESTYLE.md and distribute it through the Python and shell skills.
  • Add a test gate for help and unknown-argument behavior.
  • Update Python and PowerShell entry points to parse or reject arguments.
File Description
tests/​test_cli_usage.py Adds the CLI argument gate.
spec/​workflow_reuse.py Parses CLI options.
spec/​validate.py Parses CLI arguments.
spec/​resolve_description.py Parses required arguments.
spec/​fidelity_honesty.py Parses the report option.
host-setup/​windows/​setup-wsl.ps1 Rejects unknown or misplaced arguments.
host-setup/​windows/​install-tools.ps1 Rejects unknown options.
CODESTYLE.md Defines the command-line rule.
catalog/​snippets/​hub-fetch-run.py Adds help and first-argument validation.
.github/​skills/​shell-codestyle/​SKILL.md Distributes the shell rule.
.github/​skills/​python-codestyle/​SKILL.md Distributes the Python rule.
.github/​actions/​python-directories/​python_directories.py Parses CLI arguments.
.claude-plugin/​fleet-skills/​skills/​shell-codestyle/​SKILL.md Distributes the shell rule.
.claude-plugin/​fleet-skills/​skills/​python-codestyle/​SKILL.md Distributes the Python rule.
.claude-plugin/​fleet-skills/​.source-digests/​shell-codestyle Updates the generated source digest.
.claude-plugin/​fleet-skills/​.source-digests/​python-codestyle Updates the generated source digest.
.agents/​skills/​shell-codestyle/​SKILL.md Adds the rule to the shell skill source.
.agents/​skills/​python-codestyle/​SKILL.md Adds the rule to the Python skill source.

🧠 Review effort: Lite


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/test_cli_usage.py
Comment thread tests/test_cli_usage.py
@ptr727
ptr727 merged commit 3bb3c95 into develop Oct 11, 2026
14 checks passed
@ptr727
ptr727 deleted the feature/auto-2285 branch October 11, 2026 18:14
ptr727 added a commit that referenced this pull request Oct 11, 2026
…ilure Reporting Fixes to Main (#2816)

## Summary

Promotes these pull requests from develop to main:

- #2832 Require Every CLI Script to Answer Help and Refuse Unknown
Arguments
- #2833 Exempt nopep8 as a Leading Directive in the Prose Gate
- #2815 Bind the Workspace-Edit Rule Only to an Agent Running Inside VS
Code
- #2813 Record HomeAssistant-Config's Incidental Python as a driftNote
- #2827 Read nopep8 in Any Letter Case in the Prose Gate
- #2825 Spend a Head Refusal a Later Genuine Round on That Head Answers
- #2819 Read noqa and CSpell Directives in Any Letter Case
- #2814 Judge the Prose in Front of a Trailing noqa or pylint Directive
- #2811 Name Why a Windows Tool Install Failed and Print Docker's Status
in UTF-8
- #2808 Read a Tool Name as a Prose Gate Directive Only Where It Opens
the Comment
- #2802 Name a File the Prose Gate Cannot Decode in Its Scope Line
- #2800 Read a First-Line Comment After a Byte Order Mark as Leading in
Every Language
- #2797 Name a Python File the Prose Gate Cannot Parse in Its Scope Line
- #2794 Let the Unattended Orchestrator Retry a Transient Dispatch
Failure
- #2792 Close the Remaining Blocked-Promotion Gaps in the Unattended
Worker
- #2790 Read a Carried Change Set Past the Compare Endpoint's 300-File
Ceiling
- #2784 Let a Round on the Head Outrank pr_review.py wait's Repo-Wide
Quota Reading
- #2782 Say What pr_review.py wait --min-rounds Counts and Name It at
the Timeout
- #2778 Share the Bounded Step Reader Across the Test Harnesses
- #2776 Pin the Prose Gate's Override Wiring by Structure
- #2773 Exempt a List Item's Label Separator from the Dash Rule for
Every Marker and Bold Spelling
- #2771 Strip a List Item's Opening Label for Every Marker and Bold
Spelling in the Prose Gate
- #2768 Page pr_review.py's Changed-File List Past 100 So a Large
Promotion Can State Coverage
- #2765 Let an Attested Local Pass Cover a Head Beside a Table-Less
Copilot Round

Closes #2285
Closes #2820
Closes #2818
Closes #2809
Closes #2807
Closes #1659
Closes #2796
Closes #2798
Closes #2163
Closes #1984
Closes #2614
Closes #2767
Closes #2781
Closes #2741
Closes #2775
Closes #1665
Closes #2770
Closes #2738
Closes #2758
Closes #2739

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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.

2 participants