# Set up AgentPair

These instructions are for a coding agent (Claude Code, Codex, Cursor, ...) setting up AgentPair
for its user. AgentPair serves LeetCode-style practice problems and interviews. The user solves
them with their own agent and tools, and a remote judge grades the code.

Setup installs one **plugin** that bundles:
- the AgentPair **MCP server** (`https://api.agentpair.dev/mcp`, sign-in through OAuth in the browser; no
  API keys to copy),
- the **agentpair skill**, which teaches you the solving workflow,
- a **hook** that uploads a session's transcript to AgentPair when that session worked on an
  AgentPair attempt. Sessions that never touched AgentPair are never uploaded. Secrets are
  redacted on the server before storage.

Commands are safe to re-run: re-running updates an existing install. For Claude Code and Codex,
the user runs the install command themselves after you explain what the plugin uploads (step 3).
When you're done, tell the user what's left for them (step 4).

## 1. Set up only the agent you're running in

Install AgentPair **only for yourself**, the agent reading these instructions, even if other agents
(Claude Code, Codex, Cursor, ...) are installed on this machine. Don't touch their configuration
unless the user explicitly asks you to set those up too. At the end, you may mention
that the same setup prompt works in the other agents.

You normally know which agent you are. If you're unsure:
- In Claude Code, the shell has `CLAUDECODE=1` (check with `echo $CLAUDECODE`).
- Otherwise, ask the user rather than guessing.

Then follow only your agent's part of steps 2 to 4.

**If a command is blocked.** Your permission system may refuse a step. Don't look for another way
around it, and don't fall back to setting up a different agent. Show the user the exact blocked commands and ask them to run
them. In Claude Code they can type `! <command>` at the prompt, which runs it in this session.
Then continue.

### Upgrading from AgentCode

AgentPair used to be called AgentCode. If your agent has an old `agentcode` install, remove it first,
so you don't end up with two copies of every tool. Only run the lines for your own agent:

```sh
# Claude Code
claude plugin uninstall agentcode@agentcode 2>/dev/null; claude plugin marketplace remove agentcode 2>/dev/null
# Codex
codex plugin remove agentcode@agentcode 2>/dev/null; codex plugin marketplace remove agentcode 2>/dev/null
```

`~/.agentcode` can go once no agent uses it (`rm -rf ~/.agentcode`).

Other agents:
- **Cursor:** delete the `agentcode` entry from `~/.cursor/mcp.json` and the
  `~/.cursor/skills/agentcode` directory, if they exist.
- **Claude Code:** in `~/.claude/settings.json`, replace `mcp__plugin_agentcode_agentcode__*` with
  the AgentPair entry from step 3.

## 2. Download the plugin (Claude Code and Codex)

```sh
mkdir -p ~/.agentpair && rm -rf ~/.agentpair/plugin \
  && curl -fsSL https://api.agentpair.dev/plugin.tar.gz | tar -xz -C ~/.agentpair \
  && ls ~/.agentpair/plugin/agentpair
```

This creates `~/.agentpair/plugin`, a local plugin marketplace that both Claude Code and Codex can
install from (plugin version `0.1.0-e19ea7f2`).

## 3. Install it for your agent

Run only the section for the agent you are.

### Claude Code and Codex: the user installs it

The plugin includes a hook that uploads session transcripts to AgentPair. The user installs it
**themselves**, after you've told them what it sends. Don't run the install commands yourself:
installing something that sends session data to a server is the user's call. Claude Code's auto
mode also blocks an agent from doing it on its own.

1. Check what you downloaded: `cat ~/.agentpair/plugin/agentpair/scripts/upload-transcript.sh`.
2. Tell the user, in your own words but covering every point:
   - The plugin adds the AgentPair MCP server, a skill, and a hook.
   - At the end of each turn, the hook uploads this agent's session log to https://api.agentpair.dev. It
     only does this for sessions that worked on an AgentPair attempt (it looks for the attempt key
     AgentPair prints), and other sessions are never sent.
   - An uploaded log has everything in that session: their prompts, your replies, and tool calls
     with their output, including any files you read. The server redacts common secrets before
     storing it.
   - It's used for process coaching on practice attempts. In an interview, the interviewer sees it.
   - Without it, practice and judging still work, but there's no coaching, and some interviews
     won't let them submit.
3. Give them the command for your agent, and ask them to run it:

   **Claude Code.** They type this at the Claude Code prompt (the `!` runs it in this session):

   ```
   ! claude plugin marketplace add ~/.agentpair/plugin 2>/dev/null || claude plugin marketplace update agentpair; claude plugin install agentpair@agentpair || claude plugin update agentpair@agentpair
   ```

   **Codex.** They run this in a terminal:

   ```
   codex plugin marketplace add ~/.agentpair/plugin 2>/dev/null || true; codex plugin add agentpair@agentpair
   ```

4. When they say it's done, check it: `claude plugin list | grep -A3 agentpair`, or
   `codex mcp list | grep agentpair`. Then go on to step 4.

Re-running setup later (to update) works the same way: download again, then the user re-runs the
command.

Optional, Claude Code only: ask the user first. To skip the per-tool approval prompts, add
`"mcp__plugin_agentpair_agentpair__*"` to `permissions.allow` in `~/.claude/settings.json`. Merge
it into the existing file and keep every other setting.

### Cursor (MCP and skill only; transcript upload isn't supported for Cursor yet)

Merge this into `~/.cursor/mcp.json`, keeping other servers. Create the file if it's missing:

```json
{ "mcpServers": { "agentpair": { "url": "https://api.agentpair.dev/mcp" } } }
```

Then install the skill:

```sh
mkdir -p ~/.cursor/skills/agentpair && curl -fsSL https://api.agentpair.dev/skill.md -o ~/.cursor/skills/agentpair/SKILL.md
```

### Any other MCP client

Add a streamable-HTTP MCP server named `agentpair` at `https://api.agentpair.dev/mcp`. It uses OAuth 2.1
with dynamic client registration. If the client has no OAuth support, the user can create a token
at https://agentpair.dev/settings/tokens and send `Authorization: Bearer <token>`. If the agent
supports Agent Skills, save https://api.agentpair.dev/skill.md as `agentpair/SKILL.md` in its skills
directory.

## 4. Tell the user to sign in

You can't do this step yourself: it opens a browser. Give the user the line for your agent. If they don't have an AgentPair account yet, they can create one at https://agentpair.dev/signup.

- **Claude Code**: run `/reload-plugins` (or restart Claude Code), then `/mcp`, select
  `plugin:agentpair:agentpair` and choose **Authenticate**. Approve in the browser.
- **Codex**: run `codex mcp login agentpair` in a terminal, then restart Codex.
- **Cursor**: open Settings → MCP, then click **Login** next to `agentpair`.

## 5. Try it

After sign-in, the user can ask for something like:

> Let's pair on the AgentPair problem pair-sum in Python. Walk me through it first; I'll lead on the approach.

For an interview, the candidate gives you their interview link, for example: "Let's pair on my
AgentPair interview: <link>". Pass it to `start_attempt`. That starts the interview, so confirm
they're ready first.

Problems are listed at https://agentpair.dev/problems. Each attempt's page (timeline, code history,
verdicts, transcript) is at https://agentpair.dev/attempts/<attempt_id>.
