Repository navigation
Add setup --cli claude --verify static hook check - #283
Merged
Merged
Conversation
Read-only check of the AgentTrace hooks in Claude Code user settings, plus the project, local and managed settings that can turn them off. The hook and executable checks are shared with the Codex verifier. Refs #239 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Claude Code reads user settings from path.resolve(CLAUDE_CONFIG_DIR ?? join(homedir(), ".claude"))/settings.json. A set value is used as is: "~" is not expanded, and an empty value resolves to the current directory. --verify now resolves the directory the same way, so it no longer passes on a file Claude Code never reads. setup --cli claude (and --cli all) now names $CLAUDE_CONFIG_DIR/settings.json when that variable is set, so setup and --verify point at the same file. Refs #239 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Siddhant-K-code
added a commit
that referenced
this pull request
Oct 22, 2026
Bump 0.99.0 to 0.100.0. Includes #280 (verified Copilot CLI capture-matrix entry, Codex verified), #281 (setup: resolve the Codex directory the way Codex does), #282 (health: report event types and redaction state) and #283 (setup --cli claude --verify). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #239
What changed
agent-strace setup --cli claude --verifynow runs a read-only, static check of the Claude Code hooks. It matchessetup --cli codex --verify(#264, #275). Before this change,--verifywith--cli claudeexited 2.setup_verify.py: the hook checks (event, command, type, matcher, duplicates, stale hooks, redaction mode) and the executable check are now shared helpers. The Codex verifier uses them, and its messages are unchanged. The newverify_claude_setupadds the Claude Code checks.cli.py:cmd_setupsends--cli claude --verifyto the new check. New helpers_claude_config_dir,_claude_settings_targetand_claude_managed_settings_dir.setup --cli claudeand--cli allname$CLAUDE_CONFIG_DIR/settings.jsonwhen that variable is set, so setup and--verifypoint at the same file. New--verifyand--globalhelp text. The error for other providers now names both supported providers.docs/setup.md. Updated thesetupparagraph and the--verifyrow indocs/commands.md, the verify step indocs/v1-workflow.md, and one README quick start line. The capture matrix does not describe setup verification, so it is unchanged.tests/test_setup_verify.py.TestCodexSetupintests/test_codex_hooks.pynow clearsCLAUDE_CONFIG_DIR, so its setup output check does not depend on the shell.The check exits 1 with a message that names the file and the fix when:
commandhandler, or narrowed by its matcher;iforargsfield, which stops it from running as generated;agent-straceon PATH is missing or reports another version.On success it prints the user settings path, the event count, the redaction mode, each layer it read, the executable, a "Not checked:" line, and a note that a pass does not prove capture. This keeps "config written" apart from "events observed", as #239 asks. Telemetry already tags these runs
subcommand=verifywithintegration=claude.Decisions
$CLAUDE_CONFIG_DIR/settings.jsonwhen the variable is set, otherwise~/.claude/settings.json.path.resolve(CLAUDE_CONFIG_DIR ?? join(homedir(), ".claude"))/settings.json. I checked this in the Claude Code 2.1.222 bundle. So a set value is used as is:~is not expanded, a relative path starts from the current directory, and an empty value means the current directory. The check resolves it the same way, and setup names the same file..claude/settings.jsonand local.claude/settings.local.jsonin the current directory are read when present. Claude Code reads the shared project file from the session's working directory.managed-settings.jsonandmanaged-settings.d/*.jsonare read when present, in the documented order. Hidden and non.jsonfiles are ignored. A managed file that the OS will not let us read is skipped, as Claude Code skips it.claude doctor), the--settings,--setting-sources,--bareand--safe-modeflags, MDM and server-managed policy, plugin and skill hooks, andsettings.local.jsonat the repository root when Claude Code starts in a subdirectory or worktree. OnlyCLAUDE_CONFIG_DIRfrom the shell is used. A value set in a settingsenvblock is not followed.[features].hooks = falsein Failsetup --cli codex --verifywhen config.toml disables hooks #275.disableAllHooks: truefails when it is in effect. Managed wins, then local, then project, then user.disableAllHooks: truein user settings fails even when a project or local file sets it back tofalse, because other projects then run no hooks.disableAllHooksvalue that is nottrueorfalsefails in user, project or local settings. In managed settings it is ignored, because Claude Code drops it.allowManagedHooksOnlyfails unless it isfalseor"false". Claude Code reads an invalid value astrue. It also fails when managed settings hold AgentTrace hooks, because setup targets user settings and this repo documents no managed install.nullleaves the earlier value in place. The docs say anullremoves the key and do not count it as setting the key. This choice can only fail more, never pass more.{}.--cli all,gemini,cursorandcopilotstill exit 2 and write nothing. A run that checked only some providers could look like a full pass. The message is now "Setup verification supports only --cli codex or --cli claude, one provider per run.""","*",".*"or omitted). Narrower matchers fail. Claude Code ignores matchers on UserPromptSubmit and Stop, so those are not checked. Unrelated user hooks and extra handler fields such astimeoutare allowed.Claude Code docs used
ifandargs, matchers, a handler in several files runs once, workspace trust)CLAUDE_CONFIG_DIR)Testing
TMPDIR=/private/tmp DO_NOT_TRACK=1 AGENT_STRACE_TELEMETRY=0 PYTHONPATH=src python3 -m unittest discover -s tests: 2290 tests, OK (skipped=1). The baseline on 5d5004b is 2263, so this adds 27 tests.tests.test_setup_verifyandtests.test_codex_hookson Python 3.10.20: 79 tests, OK (skipped=1).HOMEand project directory. Missing file, invalid JSON, missing hook, stale hook,disableAllHooksin user, project and local settings all exited 1 with a fix. Unrelated user hooks next to ours and a clean install exited 0.--cli allexited 2. No probe wrote a file.CLAUDE_CONFIG_DIRprobes. Set to~/ccxor empty, hooks under$HOMEexited 1 and named the file Claude Code reads, and hooks at the path that setup printed exited 0. Setup named$CLAUDE_CONFIG_DIR/settings.jsonfor--cli claudeand--cli all, and~/.claude/settings.jsonwhen the variable is unset.Rebased on 5d5004b (#281).
docs/commands.mdkeeps the #281 Codex wording and adds the Claude parts. No version bump.