Skip to content

feat: add redact/warn prompt modes - #44

Merged
fahadsiddiqui merged 1 commit into
mainfrom
feat/redact-warn-modes
Jul 22, 2026
Merged

feat: add redact/warn prompt modes#44
fahadsiddiqui merged 1 commit into
mainfrom
feat/redact-warn-modes

Conversation

@fahadsiddiqui

Copy link
Copy Markdown
Member

Summary

  • Adds a mode config option ("block" | "redact" | "warn", default "block") so a detected prompt can be blocked, blocked-with-a-copy-pasteable-redacted-version, or allowed through with a non-blocking warning.
  • redact still blocks the original prompt - confirmed that Claude Code's UserPromptSubmit hook API has no way to rewrite/replace a submitted prompt - but the block reason includes a cleaned copy you can paste back in instead of manually retyping around the sensitive parts.
  • warn lets the prompt through unmodified and surfaces a non-blocking systemMessage listing what was found.
  • Pulls the hook response-building logic out of the plain-JS hook script into a new, unit-testable src/hook/response.ts module.
  • Invalid mode values fall back to "block" with a console warning.

Closes #12

Test plan

  • npm run build
  • npm test - 347 tests pass, including new tests/hook-response.test.ts and tests/config-mode.test.ts
  • npm run lint
  • Manually ran scripts/prompt-guard.js against a sample prompt for all three modes and confirmed the JSON output/exit behavior for each

UserPromptSubmit hooks can't rewrite the submitted prompt, only block
it or allow it with an added message, so a new "mode" config option
(block | redact | warn) picks between the current hard-block behavior,
a block whose reason includes a copy-pasteable redacted prompt, and a
non-blocking systemMessage warning.
@fahadsiddiqui
fahadsiddiqui merged commit ff3e561 into main Jul 22, 2026
3 checks passed
@fahadsiddiqui
fahadsiddiqui deleted the feat/redact-warn-modes branch July 22, 2026 18:29
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.

Redact-and-continue mode instead of hard blocking

1 participant