Agent Integrations
Triggering hooks inside Claude Code, Cursor, and generic workflows
Every agent integration follows the same pattern: a pre hook that snapshots the working tree before edits, and a post hook that records the session after edits. Use ghost install-hooks to configure all detected agents automatically, or wire them manually below.
Claude Code
Add these hooks to ~/.claude/settings.json:
{
"hooks": {
"PreToolUse": [{
"matcher": "Write|Edit|MultiEdit",
"hooks": [{ "type": "command", "command": "ghost-checkpoint pre --agent claude-code 2>/dev/null || true" }]
}],
"PostToolUse": [{
"matcher": "Write|Edit|MultiEdit",
"hooks": [{ "type": "command", "command": "ghost-checkpoint post --agent claude-code --model \"$(echo $CLAUDE_MODEL)\" --hook-input \"$(cat)\" 2>/dev/null || true" }]
}]
}
}Cursor
Cursor supports pre/post tool hooks via workspace MCP configuration. The pattern is identical to Claude Code — add the same two hooks to your .cursor/mcp.json or project settings.
GitHub Copilot (VS Code)
ghost install-hooks writes a VS Code task trigger in .vscode/tasks.json that runs on Copilot edit events. The pre-hook fires before Copilot applies changes, the post-hook fires after.
Codex CLI
Add these hooks to ~/.codex/config.json:
{
"hooks": {
"before_apply": "ghost-checkpoint pre --agent codex",
"after_apply": "ghost-checkpoint post --agent codex --model \"$CODEX_MODEL\""
}
}OpenCode (via AGENTS.md)
OpenCode reads project-level AGENTS.md for hook configuration. ghost install-hooks writes the plugin at .opencode/plugins/ghost.ts automatically.
Generic / Custom Agents
For any agent not listed above, define hooks in ~/.ghost/agents.yml:
agents:
- name: my-custom-agent
pre_hook: "ghost-checkpoint pre --agent my-custom-agent"
post_hook: "ghost-checkpoint post --agent my-custom-agent --model unknown"
config_path: ~/.my-agent/config.json
hook_key: hooks