[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M72FRQC6J70KXF6JVBY22YX7":3,"skill-same:01M72FRQC6J70KXF6JVBY22YX7":44},{"skillNo":4,"name":5,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":20,"frontMatter":21,"refName":22,"commitSha":23,"skillDirectory":24,"forksCount":25,"repositoryHtmlUrl":26,"repositoryHomepageUrl":6,"ownerHtmlUrl":27,"ownerBlogUrl":6,"ownerDescription":28,"updatedAt":29,"install":30,"resources":43},"01M72FRQC6J70KXF6JVBY22YX7","setup-hooks",null,"Johnny1110\u002FEVVA","Johnny1110","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F32870491?v=4","01M72FR9VJ3EPP3VYAW7ZN312M","Johnny Wang","01M72FR9WQ7NDYKHJ5V2PY8B6E",2,"MIT","https:\u002F\u002Fgithub.com\u002FJohnny1110\u002FEVVA\u002Fblob\u002Fmain\u002Finternal\u002Fskills\u002Fbundled\u002Fcontent\u002Fsetup-hooks\u002FSKILL.md",[],[],"2026-11-10 18:39:20",false,"# setup-hooks Configure lifecycle hooks in evva's settings.json\n\nUse this skill when the user wants something to happen automatically in response to an EVENT (\"after writes, run prettier\", \"before bash, log the command\", \"when I send a prompt, prepend X\"). Automated behaviors require hooks — memory and prompt preferences cannot trigger automated actions; the harness executes hooks, not the agent.\n\n## Where settings live\n\nevva's hook engine reads two files (project hooks fire before user hooks):\n\n| Scope | Path | Git | Use for |\n| --- | --- | --- | --- |\n| Project | `\u003Cworkdir>\u002F.evva\u002Fsettings.json` | commit (team-shared) or gitignore (personal-per-repo) | Team-wide hooks, repo-specific automation |\n| User | `\u003CAPP_HOME>\u002Fsettings.json` (typically `~\u002F.evva\u002Fsettings.json`) | N\u002FA | Cross-project personal hooks |\n\nRead the existing file FIRST before writing. Merge new hook entries with existing ones — never replace the whole file.\n\n## The six events (and only six)\n\nevva supports exactly these events. Do not advertise others.\n\n| Event | When it fires | Receives | Can block? | Can mutate? | Can inject context? |\n| --- | --- | --- | --- | --- | --- |\n| `SessionStart` | Once, when a session opens | `source`, `model` | No | No (no tool yet) | Yes — `initialUserMessage` or `additionalContext` prepended to the first turn |\n| `UserPromptSubmit` | Each time the user submits a prompt | `prompt` | Yes — dropping the prompt with a `reason` | No | Yes — `additionalContext` appended to the prompt |\n| `PreToolUse` | Before the permission gate, for every tool call | `tool_name`, `tool_input`, `tool_use_id` | Yes — short-circuits the tool with `block` | Yes — `updatedInput` replaces the args the tool executes with | Yes — folded into the tool result |\n| `PostToolUse` | After the tool returns | `tool_name`, `tool_input`, `tool_response`, `is_error` | No (post-hoc) | No | Yes — `additionalContext` appended to the tool result content |\n| `Stop` | When the agent reaches a terminal turn (no more tool calls) | `last_assistant_message`, `stop_hook_active` | Yes — re-enters the loop exactly ONCE (the `stop_hook_active` flag guards a second pass) | No | No |\n| `Notification` | Out-of-band side channel — iteration limit, approval needed | `message`, `title`, `notification_type` | No (async fire-and-forget) | No | No (stdout ignored) |\n\n## settings.json schema\n\n```json\n{\n  \"hooks\": {\n    \"\u003CEventName>\": [\n      {\n        \"matcher\": \"\u003Ctool-name-glob>\",\n        \"hooks\": [\n          {\n            \"type\": \"command\",\n            \"command\": \"\u002Fpath\u002Fto\u002Fhook.sh\",\n            \"timeout\": 60\n          }\n        ]\n      }\n    ]\n  }\n}\n```\n\nField rules:\n- `matcher` is a doublestar glob on the tool name. Empty = match-all. Required for `PreToolUse`\u002F`PostToolUse`; meaningless for the other four events.\n- `type` is `\"command\"` (shell subprocess) or `\"http\"` (webhook POST).\n- For `type: \"command\"`: `command` is required (passed to `\u002Fbin\u002Fsh -c`).\n- For `type: \"http\"`: `url` is required. Optional: `method` (default `POST`), `headers`, `async` (default `true` for http, fire-and-forget).\n- `timeout` is seconds in `[1, 600]`. `0` or omit = use the event's default.\n\n## The hook payload (stdin for command, body for http)\n\nEvery hook receives a JSON envelope:\n\n```json\n{\n  \"session_id\": \"...\",\n  \"transcript_path\": \"...\",\n  \"cwd\": \"\u002Fabs\u002Fpath\u002Fto\u002Fworkdir\",\n  \"permission_mode\": \"default\" | \"accept_edits\" | \"plan\" | \"bypass\",\n  \"agent_id\": \"...\",\n  \"agent_type\": \"main\" | \"explore\" | \"plan\" | \"general-purpose\",\n  \"hook_event_name\": \"PreToolUse\"\n}\n```\n\nPer-event fields attach on top — PreToolUse adds `tool_name`, `tool_input` (the JSON the LLM emitted), `tool_use_id`. PostToolUse adds `tool_response`, `is_error` (plus `tool_use_id`). UserPromptSubmit adds `prompt`. Stop adds `last_assistant_message`, `stop_hook_active`.\n\n## The decision JSON (parse stdout, exit 0)\n\nThe hook's stdout (when exit 0) is parsed as a JSON decision object:\n\n```json\n{\n  \"continue\": true,\n  \"decision\": \"approve\" | \"block\" | \"\",\n  \"reason\": \"why\",\n  \"systemMessage\": \"shown to user\",\n  \"hookSpecificOutput\": {\n    \"permissionDecision\": \"allow\" | \"deny\" | \"ask\",\n    \"permissionDecisionReason\": \"why\",\n    \"updatedInput\": {\"command\": \"echo replaced\"},\n    \"additionalContext\": \"appended to result \u002F prompt \u002F session start\",\n    \"initialUserMessage\": \"prepended to the first turn (SessionStart only)\"\n  }\n}\n```\n\nField semantics (cross-reference: `pkg\u002Fhooks\u002Fdecision.go`):\n- `continue: false` OR `decision: \"block\"` → block the operation (PreToolUse \u002F UserPromptSubmit \u002F Stop). On PreToolUse the tool returns an `is_error` result with `reason` as the content.\n- `decision: \"approve\"` → on PreToolUse, allow the tool unconditionally (overrides any pending permission prompt).\n- `hookSpecificOutput.permissionDecision` → on PreToolUse, overrides the permission gate's behavior. `\"allow\"` skips the gate; `\"deny\"` blocks without asking; `\"ask\"` forces a prompt even when a rule would auto-allow.\n- `hookSpecificOutput.updatedInput` → on PreToolUse, the tool executes with this JSON instead of the LLM's original `tool_input`. Last-write-wins across multiple hooks in the chain.\n- `hookSpecificOutput.additionalContext` → text appended to the tool result (PreToolUse \u002F PostToolUse) or the prompt (UserPromptSubmit) or the first turn (SessionStart). Concatenated across hooks.\n- `hookSpecificOutput.initialUserMessage` → SessionStart only. Prepended as a synthetic user message at the start of the first turn.\n\n## Exit codes (matter when stdout is not JSON)\n\n- `0` → parse stdout as the decision JSON above. Empty stdout = no opinion.\n- `1` → log the error and continue (non-blocking, treated as pass-through).\n- `2` → block. Stderr is used as `reason` if no decision JSON is on stdout.\n- Timeout → block. The configured timeout (or 60s default) wins.\n\n## Constructing a hook — the verification flow\n\nDon't just write JSON and hope. Follow this flow — each step catches a different failure class. A hook that silently does nothing is worse than no hook.\n\n### Step 1 — Dedup check\n\nRead the target settings file with `read`. If an entry already exists for the same `event + matcher`, show the user the existing command and ask (via `ask_user_question`) whether to keep it, replace it, or add alongside.\n\n### Step 2 — Construct the command for THIS project\n\nThe hook receives a JSON payload on stdin. Build a command that:\n- Extracts payload fields safely — use `jq -r` into a quoted variable, or `{ read -r f; ... \"$f\"; }`, NOT unquoted `| xargs` (splits on spaces).\n- Invokes the project's actual tool — check `package.json` scripts, `Makefile`, `go.mod`, etc., before assuming `npx` \u002F `bunx` \u002F `npm` \u002F global install.\n- Skips inputs the tool doesn't handle — formatters often have `--ignore-unknown`; if not, guard by extension.\n- Stays RAW for now — no `|| true`, no stderr suppression. You'll wrap it after pipe-testing.\n\n### Step 3 — Pipe-test the raw command\n\nSynthesize the stdin payload the hook will receive and pipe it through with `bash`:\n\nFor `PreToolUse` \u002F `PostToolUse` on `write` \u002F `edit`-like tools:\n```\necho '{\"tool_name\":\"edit\",\"tool_input\":{\"file_path\":\"\u003Ca real file from this repo>\"}}' | \u003Ccmd>\n```\n\nFor `PreToolUse` \u002F `PostToolUse` on `bash`:\n```\necho '{\"tool_name\":\"bash\",\"tool_input\":{\"command\":\"ls\"}}' | \u003Ccmd>\n```\n\nFor `SessionStart` \u002F `UserPromptSubmit` \u002F `Stop`: most commands don't read stdin, so `echo '{}' | \u003Ccmd>` suffices.\n\nCheck the exit code AND the side effect (file actually formatted, log line actually written, etc.). If it fails you get a real error — fix it (wrong package manager? tool not installed? jq path wrong?) and retest. Once it works, wrap with `2>\u002Fdev\u002Fnull || true` UNLESS the user wants the hook to block on failure.\n\n### Step 4 — Write the JSON\n\nMerge the new entry into the target file with `edit`. If you're creating `\u003Cworkdir>\u002F.evva\u002Fsettings.json` for the first time, ALSO add it to `.gitignore` if the project doesn't already commit `.evva\u002F` — the `write` tool doesn't auto-gitignore. (Project-shared hooks belong in a committed file; personal-per-repo hooks belong in a gitignored one. Ask if unclear.)\n\n### Step 5 — Validate syntax + schema\n\nRun with `bash`:\n\n```\njq -e '.hooks.\u003CEventName>[] | select(.matcher == \"\u003Cmatcher>\") | .hooks[] | select(.type == \"command\") | .command' \u003Ctarget-file>\n```\n\nExit 0 with your command printed = correct. Exit 4 = matcher doesn't match the path. Exit 5 = malformed JSON or wrong nesting. **A broken settings.json silently disables ALL hooks from that file** — fix any pre-existing malformation too, with the user's permission.\n\n### Step 6 — Prove the hook fires (PreToolUse \u002F PostToolUse only)\n\nFor `Pre\u002FPostToolUse` on a matcher you can trigger in-turn (`edit` for write-like tools, `bash` for bash):\n- For a formatter on `PostToolUse` for `write|edit`: introduce a detectable violation via `edit` (two consecutive blank lines, bad indentation, missing semicolon — something this formatter corrects; NOT trailing whitespace, `edit` strips that before writing), re-read, confirm the hook **fixed** it.\n- For anything else: temporarily prefix the command in settings.json with `echo \"$(date) hook fired\" >> \u002Ftmp\u002Fevva-hook-check.txt; `, trigger the matching tool (an `edit` for `write|edit`, a harmless `bash` `true` for `bash`), read the sentinel file.\n\n**Always clean up** — revert the violation, strip the sentinel prefix — whether the proof passed or failed.\n\nFor `SessionStart`, `UserPromptSubmit`, `Stop`, `Notification`: those fire outside this turn. Skip the proof; trust the pipe-test from step 3 plus the `jq -e` validation in step 5.\n\n### Step 7 — Handoff\n\nTell the user the hook is live, point them at the target settings file path so they can edit or disable it later, and remind them that:\n- Project hooks (`\u003Cworkdir>\u002F.evva\u002Fsettings.json`) fire BEFORE user hooks (`\u003CAPP_HOME>\u002Fsettings.json`) in the dispatcher's sequential walk.\n- A `continue: false` from an earlier hook short-circuits later hooks in the chain.\n\n## Common patterns\n\n### Auto-format on write\n\n```json\n{\n  \"hooks\": {\n    \"PostToolUse\": [{\n      \"matcher\": \"write|edit\",\n      \"hooks\": [{\n        \"type\": \"command\",\n        \"command\": \"jq -r '.tool_input.file_path' | { read -r f; gofmt -w \\\"$f\\\" 2>\u002Fdev\u002Fnull || prettier --write \\\"$f\\\" 2>\u002Fdev\u002Fnull; } || true\"\n      }]\n    }]\n  }\n}\n```\n\n### Block destructive bash commands\n\n```json\n{\n  \"hooks\": {\n    \"PreToolUse\": [{\n      \"matcher\": \"bash\",\n      \"hooks\": [{\n        \"type\": \"command\",\n        \"command\": \"jq -e '.tool_input.command | startswith(\\\"rm -rf\\\")' >\u002Fdev\u002Fnull && echo '{\\\"continue\\\":false,\\\"reason\\\":\\\"rm -rf blocked by project policy\\\"}' || echo '{}'\"\n      }]\n    }]\n  }\n}\n```\n\n### Log every bash command\n\n```json\n{\n  \"hooks\": {\n    \"PreToolUse\": [{\n      \"matcher\": \"bash\",\n      \"hooks\": [{\n        \"type\": \"command\",\n        \"command\": \"jq -r '\\\"\\\\(now) \\\\(.tool_input.command)\\\"' >> ~\u002F.evva\u002Fbash-log.txt\"\n      }]\n    }]\n  }\n}\n```\n\n### Inject context at session start\n\n```json\n{\n  \"hooks\": {\n    \"SessionStart\": [{\n      \"hooks\": [{\n        \"type\": \"command\",\n        \"command\": \"echo '{\\\"hookSpecificOutput\\\":{\\\"additionalContext\\\":\\\"This repo deploys via GitHub Actions on tag push. Do not push to main directly.\\\"}}'\"\n      }]\n    }]\n  }\n}\n```\n\n## Troubleshooting\n\nIf a hook isn't firing:\n1. Re-read the settings file with `read`. Confirm the JSON is valid.\n2. Run the `jq -e` validation from Step 5.\n3. Check the matcher matches the tool's wire name. Tool names are lowercase: `bash`, `edit`, `write`, `read`, `grep`, etc. (see `pkg\u002Ftools\u002Fname.go`).\n4. Pipe-test the command in isolation (Step 3) — if it doesn't work in the shell, it won't work as a hook.\n5. Settings files are loaded at session start. If you edited settings mid-session, the user needs to restart evva for the new hooks to take effect.\n\n## Reference\n\n- Engine: `pkg\u002Fhooks` (loader, dispatcher, runner, decision).\n- Wiring & guarantees: `docs\u002Fcontributing\u002Fextending.md` → `## Lifecycle hooks`.\n",{},"main","7ae8d7a9c769f9b4db97cbdad71bd8117bfab983","internal\u002Fskills\u002Fbundled\u002Fcontent\u002Fsetup-hooks",3,"https:\u002F\u002Fgithub.com\u002FJohnny1110\u002FEVVA","https:\u002F\u002Fgithub.com\u002FJohnny1110","Stay Hungry & Humble.","2026-08-04 11:46:50",{"source":7,"skillName":5,"commands":31,"prompt":41,"zipAvailable":42},[32,35,38],{"tool":33,"command":34},"npx","npx skills add Johnny1110\u002FEVVA --skill setup-hooks",{"tool":36,"command":37},"bunx","bunx skills add Johnny1110\u002FEVVA --skill setup-hooks",{"tool":39,"command":40},"pnpm","pnpm dlx skills add Johnny1110\u002FEVVA --skill setup-hooks","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FJohnny1110\u002FEVVA\u002Fblob\u002Fmain\u002Finternal\u002Fskills\u002Fbundled\u002Fcontent\u002Fsetup-hooks\u002FSKILL.md",true,[],[45,51,57,63,69,75],{"skillNo":46,"name":47,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":48,"categories":49,"keywords":50,"publishedAt":18},"01M72FS2CSWGA31Q3SC4T5BFK2","standup","https:\u002F\u002Fgithub.com\u002FJohnny1110\u002FEVVA\u002Fblob\u002Fmain\u002Finternal\u002Fswarm\u002Fagentdef\u002Ftestdata\u002Fagents\u002Fmain\u002Fleader\u002Fskills\u002Fstandup\u002FSKILL.md",[],[],{"skillNo":52,"name":53,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":54,"categories":55,"keywords":56,"publishedAt":18},"01M72FRZNEXBHR1BNTKTNW6YZQ","simplify","https:\u002F\u002Fgithub.com\u002FJohnny1110\u002FEVVA\u002Fblob\u002Fmain\u002Finternal\u002Fskills\u002Fbundled\u002Fcontent\u002Fsimplify\u002FSKILL.md",[],[],{"skillNo":58,"name":59,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":60,"categories":61,"keywords":62,"publishedAt":18},"01M72FRX9VW4GFP0H4CFQ01NAH","setup-swarm","https:\u002F\u002Fgithub.com\u002FJohnny1110\u002FEVVA\u002Fblob\u002Fmain\u002Finternal\u002Fskills\u002Fbundled\u002Fcontent\u002Fsetup-swarm\u002FSKILL.md",[],[],{"skillNo":64,"name":65,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":18},"01M72FRSX9TDN3SJJ679PAEWE7","setup-mcp","https:\u002F\u002Fgithub.com\u002FJohnny1110\u002FEVVA\u002Fblob\u002Fmain\u002Finternal\u002Fskills\u002Fbundled\u002Fcontent\u002Fsetup-mcp\u002FSKILL.md",[],[],{"skillNo":70,"name":71,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":18},"01M72FRNC0NWJABHM2V20ZTSRZ","security-review","https:\u002F\u002Fgithub.com\u002FJohnny1110\u002FEVVA\u002Fblob\u002Fmain\u002Finternal\u002Fskills\u002Fbundled\u002Fcontent\u002Fsecurity-review\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":18},"01M72FRMBR8SFQGRHVSVDFPWKQ","review","https:\u002F\u002Fgithub.com\u002FJohnny1110\u002FEVVA\u002Fblob\u002Fmain\u002Finternal\u002Fskills\u002Fbundled\u002Fcontent\u002Freview\u002FSKILL.md",[],[]]