.docwriter/hooks.json in your workspace. You manage them
through the UI; you do not edit the file by hand.
Open the hooks panel
In the menu bar, open Settings and click Hooks. A panel opens listing every hook in the workspace.
Anatomy of a hook
Each hook has four fields:
The command runs in the workspace root with your shell environment. Exit
code, stdout, and stderr are captured and surfaced in the history pane.
Placeholders
{{file}}. The file the triggering tool acted on (e.g.essay.md).{{stem}}. The file’s name without its last extension (essay).{{tool}}. The tool name (Edit,Write,Bash, etc.).
{{file}} and {{stem}} are only set when the event has a file scope
(PreToolUse, PostToolUse). For events like Stop they are empty.
Add a hook from a template
The hooks panel has a row of template chips for common toolchains:- pdflatex. Rebuild
main.pdffrommain.texon every edit, with bibtex and synctex. - pandoc HTML. Render the active markdown file as HTML.
- pandoc PDF. Render the active markdown file as PDF (via a TeX engine).
- Mermaid SVG. Render a
.mmddiagram file. - Git auto-commit & push on Stop. Commit and push every agent turn.
+
to save.
Add a hook manually
The add-form at the bottom of the panel has the same four fields. Fill them in directly:- Event: pick from the dropdown.
- Matcher: leave blank to match every tool, or use a regex like
Edit|Write. - Command: the shell command to run.
- Output: optional path to the rendered artifact, if any.
+ to save.
Run a hook manually
Every saved hook has a Run now button. The command runs with the currently active tab’s path as{{file}}. The result streams to the
history pane just like an auto-fired hook.
Useful for first-time setup (“does the build actually work?”) and for
re-running after editing a hook’s command.
Disable or delete
The toggle on each hook row enables or disables it without removing it. The× button deletes the hook.
Disabled hooks stay in the panel and in .docwriter/hooks.json but do not
fire.
The history pane
Every hook run appears as a card in the history pane:- Running while the command is in flight.
- Done with exit code 0, plus stdout and stderr in expandable sections.
- Failed with non-zero exit code, plus stderr.
When hooks fire during an agent turn
A typical sequence when you accept an agent edit:- The agent calls
edit_doc(a tool). PostToolUsewith matcherEdit|Writefires. Yourpdflatexhook runs.- The
outputfile (e.g.main.pdf) is regenerated. - The preview window listens for this and reloads. See Preview.
Stopfires.- Your
git auto-commithook runs, committing and pushing the change.
Where to go next
- Hook events. The full table of when each event fires.
- Preview. Wire a hook’s
outputto a live preview window. - Editing an Overleaf LaTeX project. A worked example using pdflatex and git-push hooks.