Skip to content

fix: add missing post-tool-use.sh (broken on fresh installs)#12

Merged
anthroos merged 1 commit intomainfrom
fix/public-post-tool-use-hook
May 2, 2026
Merged

fix: add missing post-tool-use.sh (broken on fresh installs)#12
anthroos merged 1 commit intomainfrom
fix/public-post-tool-use-hook

Conversation

@anthroos
Copy link
Copy Markdown
Owner

@anthroos anthroos commented May 2, 2026

Critical: fresh installs were broken

setup.sh registers a PostToolUse hook pointing to openexp/hooks/post-tool-use.sh — but the file was never in the public repo. After ./setup.sh, Claude Code had a hook configured to a non-existent script, and every Write / Edit / Bash tool call would error or fail silently.

The README's "Four hooks run automatically" claim was un-backed by code. This PR closes that gap.

What's in the hook

  • Captures Write, Edit, Bash tool calls.
  • Writes JSONL to ${OPENEXP_OBSERVATIONS_DIR:-~/.openexp/observations}/observations-YYYY-MM-DD.jsonl.
  • Skips read-only Bash (ls, cat, head, tail, find, etc.) — those don't change state, no point capturing.
  • Skips sensitive files: .env, *token.json, *credentials.json, *.pem, *.key, .ssh/*.
  • Redacts secrets in summaries: Bearer X, token=X, password=X, api_key=X, secret=X, credential=X (where X is 8+ chars).
  • export TOKEN=... / export SECRET=... / export KEY=... / export PASSWORD=... → entire summary becomes [env variable setup - REDACTED].
  • All observations are type: "feature" with empty tags: []. No path-based classification — that's intentional, since the right defaults differ per user / per project. Custom classifications should come from a config file when there's demand for it.

Smoke test

Ran the hook with simulated input for six cases — all passed:

Case Expected Result
Write to a normal file observation written
Bash with export SECRET_TOKEN=... observation written, command redacted
Bash with ls -la skipped (no observation)
Write to ~/.env skipped (sensitive file)
Read tool call skipped (not Write/Edit/Bash)
Bearer token in command redacted in summary

Test plan after merge

  • Fresh clone + ./setup.sh on a clean machine — confirm hook gets registered, then run any Edit/Write and confirm a new line lands in ~/.openexp/observations/observations-YYYY-MM-DD.jsonl.
  • Confirm Claude Code does not surface errors after the hook runs.

setup.sh registers a PostToolUse hook pointing to
openexp/hooks/post-tool-use.sh, but the file was missing from the
public repo — fresh ./setup.sh runs would register a hook to a
non-existent script and Claude Code would error on every Write/Edit/
Bash. The README's "Four hooks run automatically" claim was unbacked.

This commits a generic version of the hook:

- Captures Write, Edit, Bash; writes observations to
  ~/.openexp/observations/observations-YYYY-MM-DD.jsonl as JSONL.
- Skips read-only commands (ls, cat, head, tail, find, etc.).
- Skips sensitive files (.env, *.token.json, *.pem, .ssh/*, etc.).
- Redacts Bearer tokens and token/password/secret/credential values
  from summaries; flags TOKEN/SECRET/KEY/PASSWORD env-var setup as
  REDACTED entirely.
- Honors OPENEXP_OBSERVATIONS_DIR for output location.
- All observations get type="feature" with empty tags. Per-project
  classification is not built into the hook by design — when a user
  needs custom classifications, that should come from a config file
  (tracked in private#44).

Smoke-tested: write capture, edit capture, bash with redaction,
read-only skip, sensitive-file skip, non-Write/Edit/Bash skip — all
behave correctly.
@anthroos anthroos merged commit d84fce6 into main May 2, 2026
3 checks passed
@anthroos anthroos deleted the fix/public-post-tool-use-hook branch May 2, 2026 03:41
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.

1 participant