# Set up Replume in this repository (instructions for a coding agent)

Follow these steps in order. Run commands in the repository on the user's machine. Do not create an account, request a key, use `sudo`, or claim a hook fired just because its config file exists. Replume supports macOS and Linux and requires Node.js 20 or newer.

1. **Check Node.js and Git.**

   ```sh
   node --version
   node -p 'Number(process.versions.node.split(".")[0]) >= 20'
   git --version
   ```

   **Check:** the second command prints `true`, and Git prints a version. **If it fails:** use an already installed Node version manager to select Node 20+; install Git if missing. Re-run these checks before continuing. Do not attempt Replume setup with an unsupported Node version.

2. **Install the persistent CLI.**

   ```sh
   npm install -g replume-cli
   ```

   **Check:** npm exits successfully. **If it fails:** if the global npm directory needs permissions, stop and ask the human to choose a user-owned npm prefix or to install the package. Do not use `sudo`, ask for credentials, or switch to one-shot `npx`: agent hooks need a command that remains on `PATH`. For any other npm error, show the error and retry only after correcting its stated cause; do not claim installation succeeded.

3. **Check the command the hooks will find.**

   ```sh
   replume --version
   command -v replume
   npm list -g replume-cli --depth=0
   ```

   **Check:** `replume --version` runs, and its version matches the globally installed `replume-cli` shown by npm. `command -v replume` shows the executable the current shell finds first. **If it fails or an older Replume appears first:** warn the user that the older command may shadow the new one; fix the `PATH` order, start a fresh shell, and repeat all three commands. Do not continue with a mismatched command.

4. **Initialize from the Git repository root.**

   ```sh
   git rev-parse --show-toplevel
   ```

   **Check:** the command prints this repository's root. **If it fails:** stop and ask the human to run setup in the Git repository root, or to initialize this project with `git init` if it is not yet a Git repository. Do not run `replume init` until this check succeeds.

   ```sh
   cd "$(git rev-parse --show-toplevel)"
   replume init
   ```

   If you are setting up **Cursor**, run `replume init --cursor`; for **Codex**, run `replume init --codex`. These explicit flags install their project hooks even if `.cursor/` or `.codex/` did not previously exist. Claude Code hooks are installed by `replume init` when Claude Code is detected.

   **Check:** the default `replume init` exits successfully and prints `Replume is on (mode: auto). Hooks are installed.` This banner does not prove that a hook for your agent was installed; use the grep in step 5 for that. **If init fails:** correct its reported error and rerun with the same flag. Do not say supervision is on yet.

5. **Inspect the hook for the agent you are using.** Run the matching command:

   ```sh
   grep -nF 'replume hook claude' .claude/settings.json  # Claude Code
   grep -nF 'replume hook cursor' .cursor/hooks.json      # Cursor
   grep -nF 'replume hook codex' .codex/hooks.json        # Codex
   ```

   **Check:** the matching file exists and the command appears in it. For Codex, also review and trust the project hook using Codex's `/hooks` interface before relying on it. **If it fails:** rerun `replume init` (with `--cursor` or `--codex` as applicable), inspect its message, and check again. If the hook is still absent or Codex has not trusted it, report setup as incomplete. A config entry proves installation, not live delivery; confirm delivery on the next agent task.

6. **Find and run the project's existing test command once.** Inspect the project's README and test configuration. For a Node project, list scripts with `npm run` and use `npm test` only if a `test` script exists. Examples for other projects are `pytest`, `go test ./...`, and `cargo test`; choose the command the project actually uses.

   **Check:** record the exact command, exit code, and test result. **If there is no identifiable test command:** stop and ask the human which command should be used. **If tests fail:** show the failing output as a baseline failure; do not edit tests merely to make onboarding green. The hook configuration can still be ready, but do not claim tests pass.

7. **Tell the user the result in exactly three lines.** Fill in the observed values; if a required check failed, say setup is incomplete instead of promising supervision.

   ```text
   Replume <version> is installed; <agent> hooks are configured in <hook file>.
   Baseline tests: <exact command> → <passed/failed, with the observed result>.
   The next task in this repo will run with Replume supervision enabled; I will confirm hook delivery when it starts.
   ```

Replume's default setup needs no account or API key. The test command is repository code: inspect it before running it. Do not send repository contents or test output to another service as part of this setup.
