Skip to content

feat(cli): add --fail-on flag to make the CI gate threshold configurable#56

Open
dmchaledev wants to merge 1 commit into
mainfrom
claude/nice-mendel-umjEU
Open

feat(cli): add --fail-on flag to make the CI gate threshold configurable#56
dmchaledev wants to merge 1 commit into
mainfrom
claude/nice-mendel-umjEU

Conversation

@dmchaledev
Copy link
Copy Markdown
Contributor

Summary

  • The CLI's exit-code gate was hardcoded to fail only on D or F grades. Teams with stricter security policies had no way to fail a pipeline on a C (or better) without awkward workarounds like || true and manual grade checks.
  • Adds a --fail-on <grade> flag that exits 1 when the result is at or below the specified grade threshold.
  • Default is D, so existing pipelines are fully backward-compatible.

Usage

# Same as before — exits 1 on D or F (default)
security-headers https://staging.example.com

# Stricter gate: fail on C, D, or F
security-headers https://staging.example.com --fail-on C

# Fail on anything below A+
security-headers https://staging.example.com --fail-on A

# Invalid grade prints a clear error and exits 1
security-headers https://example.com --fail-on Z
# → Invalid --fail-on value: "Z". Valid grades: A+, A, B, C, D, F

Changes

  • src/cli.ts: parse --fail-on, validate against the grade list, replace hardcoded D/F check with gradeAtOrBelow(report.grade, failOn)
  • README.md: document the new flag with an example

Test plan

  • All 82 existing tests pass (npm test)
  • TypeScript compiles (pre-existing @types/node errors in cli.ts are unrelated — typecheck was failing before this PR on the same lines)
  • Manual: --fail-on C exits 1 on a C-graded site, 0 on a B-graded site
  • Manual: invalid grade value prints error and exits 1
  • Manual: omitting --fail-on behaves identically to before

https://claude.ai/code/session_01PT1hTSyhxp3S3pjWUmxwvA


Generated by Claude Code

The exit-code gate was hardcoded to D/F. Teams with stricter policies
had no way to fail on C or B without piping through jq or grep.
--fail-on <grade> exits 1 when the result is at or below the given
grade (default: D, preserving current behaviour).

https://claude.ai/code/session_01PT1hTSyhxp3S3pjWUmxwvA
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