Updated Hooks for auto sync
This commit is contained in:
@@ -19,9 +19,20 @@ They cannot be committed to a repo (global user settings only).
|
||||
|
||||
---
|
||||
|
||||
### 3. Auto-Sync Preferences (UserPromptSubmit)
|
||||
|
||||
**Trigger:** Before each user message
|
||||
**Behavior:** Runs `git pull` in the local clone of this preferences repo. Because `CLAUDE.md` and `preferences/` are symlinked into `~/.claude/`, the pull immediately updates what Claude sees without any manual steps. Silently skips if already up to date or unreachable.
|
||||
|
||||
Requires the one-time symlink + clone setup described in this repo's `README.md`.
|
||||
|
||||
---
|
||||
|
||||
## Settings JSON
|
||||
|
||||
Add this to `~/.claude/settings.json` (merge with any existing content):
|
||||
Add this to `~/.claude/settings.json` (merge with any existing content). Commands differ by platform — use the block that matches your machine.
|
||||
|
||||
#### Linux
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -50,6 +61,51 @@ Add this to `~/.claude/settings.json` (merge with any existing content):
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"UserPromptSubmit": [
|
||||
{
|
||||
"hooks": [
|
||||
{
|
||||
"type": "command",
|
||||
"command": "git -C \"$HOME/repos/AI\" pull --quiet --ff-only 2>/dev/null; true",
|
||||
"async": true,
|
||||
"statusMessage": "Syncing preferences..."
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Windows
|
||||
|
||||
```json
|
||||
{
|
||||
"hooks": {
|
||||
"Stop": [
|
||||
{
|
||||
"hooks": [
|
||||
{
|
||||
"type": "agent",
|
||||
"prompt": "Check if a README.md file exists in the current project directory. If it does, review what changes were made during this session and update README.md to reflect any new or changed functionality, configuration, API endpoints, environment variables, or setup steps. Only make updates if there is genuinely new or changed information that belongs in a README. Preserve the existing format and style. If nothing meaningful changed, leave the README as-is.",
|
||||
"statusMessage": "Checking README for updates...",
|
||||
"timeout": 120
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"UserPromptSubmit": [
|
||||
{
|
||||
"hooks": [
|
||||
{
|
||||
"type": "command",
|
||||
"command": "powershell -NonInteractive -Command \"git -C C:\\repos\\AI pull --quiet --ff-only 2>$null\"",
|
||||
"async": true,
|
||||
"statusMessage": "Syncing preferences..."
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user