PR
prompt-logging-hook-setup
Use when setting up, repairing, verifying, or troubleshooting a UserPromptSubmit prompt logging hook in a target repository, including trusted mode checks, hooks.json command wiring, git user name prompt-prefix logging, and per-user prompt log file names.
Install
mkdir -p .claude/skills/prompt-logging-hook-setup-yangsijun528 && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/14805" && unzip -o skill.zip -d .claude/skills/prompt-logging-hook-setup-yangsijun528 && rm skill.zipInstalls to .claude/skills/prompt-logging-hook-setup-yangsijun528
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Use when setting up, repairing, verifying, or troubleshooting a UserPromptSubmit prompt logging hook in a target repository, including trusted mode checks, hooks.json command wiring, git user name prompt-prefix logging, and per-user prompt log file names.255 chars✓ has a “when” triggerlonger than Claude Code's old 250-char listing cap (fine on current versions)
About this skill
Prompt Logging Hook Setup
Use this skill when the user wants to install a UserPromptSubmit prompt logging hook from scratch, repair a broken setup, check why the hook is not firing, or verify that prompt logs are being written correctly for a target repository.
Workflow
- Inspect the hook files in the repository being diagnosed before proposing changes:
.codex/config.toml.codex/hooks.json- the referenced script under
.codex/hooks/
- Verify whether the repository being inspected must be opened in trusted mode for
.codexto load. - Check the hook command carefully:
- confirm the event name
- confirm the script path resolves from the repo root
- confirm the script reads JSON from stdin and handles invalid payloads safely
- Verify the log schema:
git_user_nameshould come fromgit config user.nameprompt_prefixshould match that Git user nameprompt_rawshould preserve the unprefixed user inputpromptshould contain the visible prefixed form
- Verify where output is written and whether the parent directory is created.
- prompt logs should be per Git user:
logs/{sanitized-git-user-name}-prompt-log.jsonl
- prompt logs should be per Git user:
- If the user wants a diagnosis, run
scripts/validate_hook_setup.py <repo_path>first. - If the user wants a fix, prefer the smallest repair:
- enable
codex_hooks - fix malformed
hooks.json - fix the command path
- add Git user name prefix logging
- fix log path creation
- repair the standard prompt log hook with
scripts/install_or_repair_hook.py <repo_path> - document trusted mode requirements when the repo still looks structurally correct
- enable
What Good Prompt Logging Hook Setups Usually Include
codex_hooks = truein.codex/config.toml- a valid
.codex/hooks.json - a hook script that accepts stdin JSON and exits safely on malformed payloads
- a hook script that reads Git
user.nameand stores it asgit_user_nameandprompt_prefix - a per-user log path inside the target repository, such as
logs/{sanitized-git-user-name}-prompt-log.jsonl - a short troubleshooting note explaining trusted mode
Troubleshooting Priorities
- If no hook runs at all, first suspect trusted mode or
.codex/config.toml. - If the hook is registered but no log file appears, inspect the command path and write target.
- If the script runs but log lines are missing prefix fields, inspect the Git user lookup and log schema.
- If the structure is correct but runtime behavior still fails, explicitly tell the user to reopen the repository being repaired in trusted mode because that cannot be repaired by editing files inside the repository alone.
- If the user asks for documentation, keep it short and operational rather than explanatory.
Resources
- Use
scripts/validate_hook_setup.pyfor a fast structural check. - Use
scripts/install_or_repair_hook.pyto write the standard prompt hook files into a target repository. - Read
references/troubleshooting.mdwhen you need a more explicit diagnosis checklist.