Journey · Step 04

Hooks, scripts, and ingestion

Once the laptop and the VPS were both in play, manual coordination was the weak point. This stage turns repeated actions into explicit system behavior by wiring git events, session endings, helper scripts, and OpenClaw ingestion together.

Capture important context automatically. Commits should feed the memory layer. Session endings should feed the memory layer. Repeated sync and audit behavior should happen through scripts with a clear role instead of vague habit.

1. Add a global git hooks path

Make commit-triggered ingestion work across repos

A repo-local git hook is too narrow for this setup. The system uses a global hooks path so commit events can be captured consistently across projects.

mkdir -p ~/.git-hooks
git config --global core.hooksPath ~/.git-hooks

After that, the relevant hook file lives at:

~/.git-hooks/post-commit

2. Use the post-commit hook to feed OpenClaw

Capture code changes as they happen

The remembered design explicitly includes a global git post-commit hook. Its job is to notify OpenClaw that a commit happened, which project it happened in, and what changed.

# conceptual responsibilities of ~/.git-hooks/post-commit
# - detect repo root
# - collect commit hash and commit message
# - identify project name
# - send event or payload into OpenClaw

The exact transport can vary, but the role stays the same: a commit should create a record in the memory layer without relying on manual logging.

3. Add a Claude Code Stop hook

Capture reasoning and session context, not just code diffs

Commit history is useful, but it misses most of the thinking. That is why the setup also uses a Claude Code Stop hook.

The hook script lives under the local helper scripts, for example:

~/bin/claude_stop_hook.sh

Its job is to trigger when a Claude session ends, summarize the work, and hand that summary to OpenClaw so the memory layer gets more than final code state.

4. Add helper scripts for support tasks

Keep glue logic readable and reusable

The preserved setup notes mention helper scripts in ~/bin/ and specific maintenance scripts such as git_daily_sync.sh and setup audit scripts.

These scripts matter because they turn repeated manual maintenance into named, inspectable behavior. Each script has a narrow job.

~/bin/git_daily_sync.sh
~/bin/claude_setup_audit.sh
~/bin/codex_setup_audit.sh
~/bin/claude_stop_hook.sh

5. Be explicit about what each script does

Give each piece a narrow operational role

The scripts are useful because they are specific.

  • claude_stop_hook.sh captures Claude session-end context
  • git_daily_sync.sh handles git-oriented maintenance or sync behavior
  • claude_setup_audit.sh checks Claude-related config and instruction files
  • codex_setup_audit.sh checks Codex-related config and setup state

Their value comes from being part of a chain. Git captures code state. the Claude Stop hook captures session context. Audit scripts help keep the environment healthy.

6. Fix the ingestion pipeline when it is too thin

Parser fixes and webhook cleanup matter

One of the remembered setup decisions is that the parser and webhook handling were fixed because the early path was too sparse. That is an important lesson: getting events into the system is easy, but getting useful context into the system takes iteration.

# practical ingestion concerns
# - webhook auth/header handling
# - transcript parser shape
# - payload quality
# - deduplication

7. Add a verification marker

Use a canary phrase to prove the pipeline works end to end

The setup used a canary phrase as a verification step. That is a good design choice because it makes the test unambiguous.

lobster remembers everything

If the memory layer can later recall that exact phrase, the hook path is carrying more than vague summaries.

8. Keep the data clean

Store decisions and rationale, skip secrets and junk

The memory rules matter here. Hooks should preserve decisions, rationale, timestamps, projects, touched files, and useful context. They should not copy credentials, tokens, raw secret material, or noisy junk that makes retrieval worse later.

# keep
# - project
# - task
# - decisions
# - rationale
# - files touched

# avoid
# - credentials
# - tokens
# - .env contents
# - redundant raw dumps

Problem solved

Without hooks and scripts, the system depends too much on memory and manual discipline. Important context gets lost.

Result

The environment starts behaving like a real system. Commits, session endings, and maintenance tasks feed the memory layer in a structured way.