Answer: Add a PostToolUse hook with an Edit|Write matcher to .claude/settings.json that extracts the edited file path with jq and passes it to Prettier. Status: Confirmed Entry: tool/claude-code/agents-and-automation/auto-format-after-edits Revision: 3 Digest: sha256:2d2d32a44c0cab67 (changes whenever the content changes) Timeline: Created: 2026-11-13T03:04:22Z Last changed: 2026-11-16T12:09:27Z (Check succeeded again) Last verified: 2026-11-20T12:21:19Z Next check: 2026-11-21T12:21:19Z Check interval: Daily Expected change: No fixed schedule Data: Field | Value | Source | As of hook event | PostToolUse | [1] | 2026-11-20 matcher | Edit|Write | [1] | 2026-11-20 config file | .claude/settings.json | [1] | 2026-11-20 Sources: [1] Anthropic. "Automate actions with hooks". https://code.claude.com/docs/en/hooks-guide.md Role: primary. Accessed: 2026-11-20T12:21:19Z Quote: "This hook uses the `PostToolUse` event with an `Edit|Write` matcher" (Supports: hook event, matcher) Quote: "Add this to `.claude/settings.json` in your project root:" (Supports: config file) Published: 2026-11-20T10:36:06Z Snapshot SHA-256: 2076ece854a4d4be8c0a9c7568db4e9abc0e35153c22975adf750c6f8f3166e9 (captured 2026-11-17T12:26:31Z) Verification: Method: Automated extraction from [1] with deepseek-flash (JSON output, thinking disabled). Every value was checked by code to appear verbatim in a quoted passage of [1]. On this check the text of [1] was unchanged since 2026-11-17T12:26:31Z, so the values verified then were kept. Cross-check: not-available at 2026-11-20T12:21:19Z. No independent second source is configured for this entry Last successful check: 2026-11-20T12:21:19Z Last attempt: 2026-11-20T12:21:19Z Notes and limitations: Extracted automatically from a single official source (section "Auto-format code after edits"). Related: https://latestn.com/tool/claude-code/agents-and-automation/available-hook-events What hook events are available in Claude Code? https://latestn.com/tool/claude-code/agents-and-automation/build-bug-fixing-agent How do I build and run an agent with the Claude Code Agent SDK that finds and fixes bugs? https://latestn.com/tool/claude-code/agents-and-automation/call-model-from-mod How do I call a model from a Claude Code mod with the mods API? https://latestn.com/tool/claude-code/agents-and-automation/allow-specific-skills How do I allow only specific skills in a Claude Agent SDK session? https://latestn.com/tool/claude-code/agents-and-automation/append-to-claude-code-preset How do I append extra instructions to the claude_code preset system prompt in Claude Code? https://latestn.com/tool/claude-code/agents-and-automation/ask-claude-to-write-mod How do I ask Claude to write a Claude Code mod for me? https://latestn.com/tool/ All entries in AI tools Change log: Time | Event | Change | Source 2026-11-16T12:09:27Z | recovered | Check succeeded again | — 2026-11-16T12:09:27Z | changed | config file: — → .claude/settings.json | [1] 2026-11-16T12:09:27Z | changed | formatter: Prettier → — | [1] 2026-11-16T12:09:27Z | changed | config file location: .claude/settings.json → — | [1] 2026-11-15T12:21:19Z | check-failed | Extraction did not pass verification: answer contains `f=$(jq -r '.tool_input.file_path') && npx prettier --write --ignore-unknown "$f"`, which does not appear in the source | — 2026-11-14T12:17:06Z | changed | formatter: — → Prettier | [1] 2026-11-14T12:17:06Z | changed | config file location: — → .claude/settings.json | [1] 2026-11-14T12:17:06Z | changed | alternative hook: FileChanged → — | [1] 2026-11-14T12:17:06Z | changed | config file: .claude/settings.json → — | [1] 2026-11-13T03:04:22Z | added | Entry created | — Changes for this entry as a feed: https://latestn.com/tool/claude-code/agents-and-automation/auto-format-after-edits/latest Challenge this entry: Open challenges: None How: If a value here is wrong or out of date, send what is wrong and a link to evidence. Challenges are queued and checked against the evidence; they do not change the entry by themselves. If the entry changes as a result, the change log says so. Form: https://latestn.com/dispute/tool/claude-code/agents-and-automation/auto-format-after-edits POST: https://latestn.com/dispute/tool/claude-code/agents-and-automation/auto-format-after-edits with claim, evidence_url, and optionally field and contact (form-encoded or JSON) GET: https://latestn.com/dispute/tool/claude-code/agents-and-automation/auto-format-after-edits?claim={what is wrong}&evidence_url={link} How to cite: LatestN. (2026). How do I make Claude Code auto-format code after it edits files using hooks? Revision 3, last verified 2026-11-20T12:21:19Z. https://latestn.com/tool/claude-code/agents-and-automation/auto-format-after-edits (accessed 2026-11-21T10:03:09Z). @misc{LatestN_tool_claude_code_agents_and_automation_auto_format_after_edits_r3, title = {How do I make Claude Code auto-format code after it edits files using hooks?}, author = {{LatestN}}, year = {2026}, howpublished = {\url{https://latestn.com/tool/claude-code/agents-and-automation/auto-format-after-edits}}, note = {Revision 3; digest sha256:2d2d32a44c0cab67; last verified 2026-11-20T12:21:19Z; accessed 2026-11-21T10:03:09Z} } Reuse: License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/) Attribution: Copying and adapting are allowed, including commercially, if you credit LatestN and link to the entry you used. Each entry ends with a ready-made citation. URL: https://latestn.com/tool/claude-code/agents-and-automation/auto-format-after-edits