Skip to content

armgit / Wake

Public Imported from GitHub
0

All your AI agent sessions in one place — browse, search, resume. Rust + GPUI.

Rust

docs(cli): SessionStart hook recipe that hands Claude Code the project's recent sessions

Corey Chiu2a7ef9399a1e
diff --git a/README.md b/README.md
index e90f7b1..10c4688 100644
--- a/README.md
+++ b/README.md
@@ -124,7 +124,7 @@ wake-cli setup # path, PATH setup, and a bloc
It prints what the MCP tools return, asserted byte for byte in the test suite apart from a trailing newline the CLI adds, so an agent driving it through a shell sees what a connected one does. Full reference in [docs/cli.md](docs/cli.md).
-To make an agent reach for it without being told, install the bundled skill with `npx skills add iAmCorey/Wake` (or copy `skills/wake/` into `~/.claude/skills/wake/`).
+To make an agent reach for it without being told, install the bundled skill with `npx skills add iAmCorey/Wake` (or copy `skills/wake/` into `~/.claude/skills/wake/`). Claude Code can go one step further and receive the project's recent sessions the moment a session starts, through a `SessionStart` hook that runs `wake-cli` — the recipe is in [docs/cli.md](docs/cli.md#teaching-an-agent-to-use-it).
## Language
diff --git a/docs/cli.md b/docs/cli.md
index a408bb9..31fd1f8 100644
--- a/docs/cli.md
+++ b/docs/cli.md
@@ -119,7 +119,8 @@ To make this automatic instead of per-project, install the skill (next section).
## Teaching an agent to use it
-Two ways, same content.
+Two ways to teach it, same content — and a third that skips the teaching by handing the
+agent this project's recent sessions before it asks.
**A skill, once, for every project** — the repository ships one at `skills/wake/`:
@@ -136,7 +137,46 @@ an error has been seen before — and how to read keys, references and pages.
into that project's `CLAUDE.md` or `AGENTS.md`. Use this when you would rather not
install anything, or want the guidance to live in the repository.
-Neither writes to another tool's configuration; Wake only ever prints.
+**Automatically, at session start (Claude Code)** — a `SessionStart` hook runs a command
+when a session begins and hands its output to the agent as context. This one lists the
+project's recent sessions, so the agent already knows what happened here before you say
+"continue from yesterday":
+
+```json
+{
+ "hooks": {
+ "SessionStart": [
+ {
+ "matcher": "startup|resume",
+ "hooks": [
+ {
+ "type": "command",
+ "command": "wake-cli sessions --project \"$CLAUDE_PROJECT_DIR\" --limit 5 --since 14d 2>/dev/null || true",
+ "timeout": 30
+ }
+ ]
+ }
+ ]
+ }
+}
+```
+
+Put it in `~/.claude/settings.json` to get it in every project, or in a project's
+`.claude/settings.json`. A few things to know:
+
+- If `wake-cli` is not on your `PATH`, use its full path (see *Where it lives*).
+- Keep the trailing `|| true`. A hook that exits `2` stops the session from starting, and
+ `wake-cli` exits `2` when there is no index yet.
+- What gets injected is titles, keys and dates — a handful of lines, not transcripts. The
+ agent still reads a session with `show` when it needs the details.
+- `startup|resume` skips `/clear` and compaction; drop the matcher to run on those too.
+- A lookup made by the hook is not the agent asking Wake, so it does not show up in
+ Insights under *Agents asking Wake*; the lookups the agent then makes on its own do.
+- Only Claude Code has this hook. Codex and Gemini CLI have no equivalent, so there the
+ skill is the way in.
+
+None of the three writes to another tool's configuration; Wake only ever prints, and the
+hook is yours to add.
### `index`
diff --git a/docs/mcp.md b/docs/mcp.md
index e5d6455..541cec1 100644
--- a/docs/mcp.md
+++ b/docs/mcp.md
@@ -85,6 +85,10 @@ Before asking me for context about this repository, check earlier sessions with
wake_list_sessions with the current directory, then wake_get_session for the relevant one.
```
+Claude Code can also be handed the project's recent sessions automatically when a session
+starts, through a `SessionStart` hook that runs `wake-cli` — see
+[Automatically, at session start](cli.md#teaching-an-agent-to-use-it) in the command-line guide.
+
### A worked example
```