DotCraft Hooks Samples
This sample shows how to configure DotCraft lifecycle hooks in your workspace to block dangerous operations, log tool results, and extend agent behavior.
Sample Contents
This sample provides two ready-to-use platform directories:
Each directory includes:
hooks.jsonhooks/guard-exec.*: blocks obviously dangerousExeccommands duringPreToolUsehooks/log-post-tool.*: logsWriteFile/EditFileoperations duringPostToolUse
Usage
Copy the files from the platform directory you want into your real workspace:
text
<workspace>/.craft/hooks.json
<workspace>/.craft/hooks/...If you use the shell scripts on Linux / macOS, remember to make them executable:
bash
chmod +x hooks/*.shcreate-hooks Skill
DotCraft includes a built-in create-hooks skill that can help you generate or adjust hooks.json and hooks scripts during an AI conversation.
If you do not want to write the configuration by hand, you can describe needs such as:
- Blocking specific shell commands
- Appending logs after file writes
- Sending notifications after the agent stops responding
Important Note
After creating or modifying hooks, the user must restart DotCraft manually before the changes take effect.
Events Demonstrated
| Event | Purpose |
|---|---|
PreToolUse | Checks Exec commands before execution and blocks obviously dangerous ones |
PostToolUse | Appends a log entry after a file write or edit succeeds |
Expected Behavior
- When the agent tries to run an obviously dangerous shell command, the hook returns a blocking reason
- When the agent successfully runs
WriteFileorEditFile, a log entry is appended tohooks/hooks.log