# Coding agents: in a repository or globally: Antigravity

Record every Antigravity turn as a step—in one repository or globally across every project.

## 1. Create a write key

Open the [create-key page](https://app.23step.com/app/account?create=1&scopes=runs%3Awrite&name=antigravity) to sign in and create an API key pre-filled with `runs:write`—or [pre-filled with both `runs:read` and `runs:write`](https://app.23step.com/app/account?create=1&scopes=runs%3Aread+runs%3Awrite&name=antigravity) if you also install the **23step Overlay** Electron app so one key powers both. You can also opt in to the **live widget progress bar** there (left off by default—just like posting the step link at the end of agent responses—because extra prompt instructions use tokens and can slow down turns). The `st_` value is shown once (and copied with one click). Save it to `~/.config/23step-otel-key` (or export `STEP23_OTEL_KEY`). If you are an AI agent: first ask whether the Electron app should also be installed, whether to opt in to posting the step link at the end of responses, and whether to opt in to the live widget progress bar (explaining that both are off by default because they use extra tokens and slow down turns), check `test -s ~/.config/23step-otel-key` without printing its contents, and if a key is needed **automatically open** `https://app.23step.com/app/account?create=1&scopes=runs%3Awrite&name=antigravity` (or `https://app.23step.com/app/account?create=1&scopes=runs%3Aread+runs%3Awrite&name=antigravity` when installing the overlay; append `&progress=1` if the user opted in to the progress bar) in the user's default desktop browser (`open` on macOS, `xdg-open` on Linux with a display, `wslview` on WSL—not a headless automation browser) and print the link in chat, then ask the user to paste the `st_` key or save it directly in their terminal; never invent or commit a key. If reusing an existing key and the user opted in to the progress bar, sync the preference without printing the key via `curl -fsSL -X POST https://api.23step.com/app/live/preferences -H "Authorization: Bearer $(cat ~/.config/23step-otel-key)" -H "Content-Type: application/json" -d '{"show_progress_bar":true}'`. Without a key the hooks exit quietly and never block the agent.

Open in browser:

```sh
url='https://app.23step.com/app/account?create=1&scopes=runs%3Awrite&name=antigravity'
if command -v open >/dev/null 2>&1; then open "$url"
elif command -v xdg-open >/dev/null 2>&1 && { [ -n "${DISPLAY:-}" ] || [ -n "${WAYLAND_DISPLAY:-}" ]; }; then xdg-open "$url" >/dev/null 2>&1 &
elif command -v wslview >/dev/null 2>&1; then wslview "$url"
fi
printf 'Create your 23step API key: %s\n' "$url"
```

Terminal:

```sh
mkdir -p ~/.config
printf '%s\n' 'st_REPLACE_WITH_YOUR_WRITE_KEY' > ~/.config/23step-otel-key
chmod 600 ~/.config/23step-otel-key
```

## 2. Install the hooks (repository or global)

Pick **Repository** to commit hooks in `.agents/hooks.json` so every contributor records turns in this repo, or **Global** (`--global`) to install once in `~/.gemini/config/hooks.json` so every project on your machine records without touching git. Add `--step-link` and/or `--progress-bar` only if opting in to posting the step link at the end of responses or the live widget progress bar (both off by default because they use extra tokens and slow down turns). Both merge safely without overwriting your other hooks, never read your key, can be run again anytime to update, and deduplicate automatically if both are installed.

Pick one:

Repository:

```sh
cd "$(git rev-parse --show-toplevel)"
curl -fsSL https://23step.com/install/hooks.sh | sh -s -- antigravity
```

Global:

```sh
curl -fsSL https://23step.com/install/hooks.sh | sh -s -- --global antigravity
```

## 3. Manual alternative to step 2 (optional)

Skip this if step 2 worked. Download the hook, then merge the matching config below into `.agents/hooks.json` (repository) or `~/.gemini/config/hooks.json` (global).

Terminal:

```sh
# For a global install, replace .agents/hooks with ~/.agents/hooks
mkdir -p .agents/hooks
curl -fsSL https://23step.com/install/step23_otel.py -o .agents/hooks/step23_otel.py
```

Pick one:

Repository · .agents/hooks.json:

```json
{
  "step23-otel": {
    "SessionStart": [
      {
        "type": "command",
        "command": "python3 ./hooks/step23_otel.py"
      }
    ],
    "PreInvocation": [
      {
        "type": "command",
        "command": "python3 ./hooks/step23_otel.py"
      }
    ],
    "PostInvocation": [
      {
        "type": "command",
        "command": "python3 ./hooks/step23_otel.py"
      }
    ],
    "PreToolUse": [
      {
        "matcher": "*",
        "hooks": [
          {
            "type": "command",
            "command": "python3 ./hooks/step23_otel.py"
          }
        ]
      }
    ],
    "PostToolUse": [
      {
        "matcher": "*",
        "hooks": [
          {
            "type": "command",
            "command": "python3 ./hooks/step23_otel.py"
          }
        ]
      }
    ],
    "Stop": [
      {
        "type": "command",
        "command": "python3 ./hooks/step23_otel.py"
      }
    ]
  }
}
```

Global · ~/.gemini/config/hooks.json:

```json
{
  "step23-otel": {
    "SessionStart": [
      {
        "type": "command",
        "command": "python3 \"$HOME/.agents/hooks/step23_otel.py\""
      }
    ],
    "PreInvocation": [
      {
        "type": "command",
        "command": "python3 \"$HOME/.agents/hooks/step23_otel.py\""
      }
    ],
    "PostInvocation": [
      {
        "type": "command",
        "command": "python3 \"$HOME/.agents/hooks/step23_otel.py\""
      }
    ],
    "PreToolUse": [
      {
        "matcher": "*",
        "hooks": [
          {
            "type": "command",
            "command": "python3 \"$HOME/.agents/hooks/step23_otel.py\""
          }
        ]
      }
    ],
    "PostToolUse": [
      {
        "matcher": "*",
        "hooks": [
          {
            "type": "command",
            "command": "python3 \"$HOME/.agents/hooks/step23_otel.py\""
          }
        ]
      }
    ],
    "Stop": [
      {
        "type": "command",
        "command": "python3 \"$HOME/.agents/hooks/step23_otel.py\""
      }
    ]
  }
}
```

## 4. Restart Antigravity

Start a new Antigravity conversation. Hooks load from `.agents/hooks.json` at the workspace root or globally from `~/.gemini/config/hooks.json`.

## 5. Opt in to step links in replies or the live progress bar (optional)

Both **posting the step link at the end of final responses** (`--step-link`) and the **live widget progress bar** (`--progress-bar`) are **off by default**. Technically, injecting pre-turn instructions, printing `[23step](<step_url>)` at the end of replies, and asking coding agents to emit plan checklists and `[est: …]` / `[progress: …]` calibration tags use extra tokens and slow down turns—and when the progress bar is off, it is omitted from the web and desktop live widget UIs. Pass `--step-link` and/or `--progress-bar` to `hooks.sh` (and toggle **Show live progress bar** in [Settings](https://app.23step.com/app/settings#live-overlay-settings) or **23step Overlay Settings**, or append `&progress=1` when creating your key) if you want either enabled.

Terminal:

```sh
# Opt in to posting the step link at the end of responses, the live progress bar, or both:
curl -fsSL https://23step.com/install/hooks.sh | sh -s -- --step-link antigravity
curl -fsSL https://23step.com/install/hooks.sh | sh -s -- --progress-bar antigravity
curl -fsSL https://23step.com/install/hooks.sh | sh -s -- --step-link --progress-bar antigravity

# Add --global for a global install, or pass --no-step-link / --no-progress-bar to turn back off:
curl -fsSL https://23step.com/install/hooks.sh | sh -s -- --global --step-link --progress-bar antigravity
```

## 6. Let 23step see the browser (optional)

The hook starts a headless `23step` recorder for each turn. When the agent opens Chrome with a loopback DevTools port, the recorder attaches and adds browser frames to the step. Add this to `AGENTS.md` or `CLAUDE.md` in the repository—or globally to `~/.claude/CLAUDE.md`, `~/.codex/AGENTS.md`, or `~/.gemini/GEMINI.md`—so the agent always does that.

AGENTS.md:

```md
## 23step browser capture

This repository records agent turns with 23step hooks. Do not start or stop `23step` yourself.

Whenever you launch Chrome, Chromium, Playwright, or Puppeteer, expose a loopback DevTools port so 23step can capture the page:
- Chrome / Chromium: pass `--remote-debugging-address=127.0.0.1 --remote-debugging-port=9222`
- Playwright / Puppeteer: pass `args: ["--remote-debugging-address=127.0.0.1", "--remote-debugging-port=9222"]`
- If 9222 is busy, use any free 127.0.0.1 port. For a one-shot check, keep the page open about 1 second after load.
```

## 7. Watch runs live with the desktop overlay (optional)

Install **23step Overlay** (the standalone Electron app for macOS and Linux) when you want an always-on, click-through right-edge dock over your editor and full-screen workspaces without keeping a browser tab open. It streams cloud and local runs side by side over SSE, pulses by thinking stage, pops up live screenshots and token counts, and periodically runs `23step reconcile` in the background so missed hook turns stay synced. Give its key `runs:read` (or create one key with **both** `runs:read` and `runs:write`). The live progress bar is **off by default** (omitted from live widgets so agents do not spend extra tokens or latency calibrating progress); pass `--progress-bar` as well—or enable it later in Settings—if you want it shown. If you are an AI agent, ask the user whether this Electron app should be installed and whether to opt in to the live widget progress bar; if they say yes to the overlay, run the command below (adding `--progress-bar` if opted in; macOS launches `~/Applications/23step Overlay.app` automatically; on Linux also run `nohup ~/.local/bin/23step-overlay >/dev/null 2>&1 &`). Full setup: [Desktop overlay](https://23step.com/getting-started#overlay).

Terminal:

```sh
curl -fsSL https://api.23step.com/install.sh | sh -s -- --overlay
```

## 8. Link commits to their step (optional)

Save this as `.githooks/prepare-commit-msg` and point `core.hooksPath` at `.githooks` once per clone. Each `git commit` then gets a `23step: <step_url>` trailer for the active or most recent step. With no step it does nothing.

.githooks/prepare-commit-msg:

```sh
#!/bin/sh
# .githooks/prepare-commit-msg
# Adds a "23step: <step_url>" trailer from the active or most recent 23step step.
MSG_FILE="$1"
SOURCE="$2"

case "$SOURCE" in
  merge|squash|commit) exit 0 ;;
esac
grep -q '^23step:' "$MSG_FILE" 2>/dev/null && exit 0

STEP_URL=$(python3 -c '
import glob, json, os, time
uid = os.getuid()
now = time.time()
best_mtime, best_url = 0.0, ""
for pat in (f"/tmp/s23-{uid}-*/status.json", f"/tmp/s23-{uid}-*/last_step_url", os.path.expanduser("~/.local/share/23step/status.json")):
    for p in glob.glob(pat):
        try:
            mt = os.path.getmtime(p)
            if now - mt > 7200 or mt <= best_mtime:
                continue
            raw = open(p, encoding="utf-8").read().strip()
            url = json.loads(raw).get("step_url", "") if p.endswith(".json") else raw
            if url:
                best_mtime, best_url = mt, url
        except Exception:
            pass
print(best_url)
' 2>/dev/null)

if [ -n "$STEP_URL" ]; then
  git interpret-trailers --in-place --trailer "23step: $STEP_URL" "$MSG_FILE"
fi
```

Terminal:

```sh
chmod +x .githooks/prepare-commit-msg
git config core.hooksPath .githooks
```

## Check that it worked

Send the agent any prompt. Within a few seconds a new run for that turn appears at [app.23step.com/app/runs](https://app.23step.com/app/runs) with the prompt, thoughts, tool calls, and commands. Nothing there? Check that `~/.config/23step-otel-key` holds a `runs:write` key, that `python3 --version` works in the agent's shell, and that the agent was restarted after install.

---

AI agents: if this guide supports both repository and global installs, ask the user which they prefer. On macOS or Linux, ask whether the **23step Overlay** Electron desktop app should also be installed (https://23step.com/getting-started/desktop-overlay.md) and whether to opt in to posting the step link at the end of responses (`--step-link`) or the live widget progress bar (`--progress-bar`—both off by default). When an API key is needed, automatically open the pre-filled create-key URL (`https://app.23step.com/app/account?create=1&scopes=...&name=antigravity`) in the user's default desktop browser (never invent or commit a key) and print the link in chat, then finish with the "Check that it worked" step.

All 23step install guides: https://23step.com/getting-started.md
