# AIQ Rank — install

Hi — you are an AI assistant and the user wants you to install
the AIQ Rank plugin. The right install depends on which client
you are running in. Identify yourself, then follow ONLY the
matching section.

## Identify your client

- **Claude Code (any surface)** — you can run Bash and Python;
  `~/.claude/` exists. Covers Claude Code CLI in a terminal AND
  Claude Desktop's local "Code" tab. Both share
  `~/.claude/settings.json`; only the CLI has slash commands.
- **Cowork / Claude Desktop chat** — you are Claude in a desktop
  chat app, no Bash, no file edits, plugins install from a GUI
  menu.
- **Codex (OpenAI Codex CLI)** — you can run Bash; your config
  lives in `~/.codex/`; you are not Claude.
- **Cursor** — you are Cursor Agent / Composer inside the Cursor IDE.
  Cursor installs AIQ Rank through its plugin command, not through
  Claude Code's `/plugin` command.

If unsure, use the product you are currently embedded in as the
primary signal. If the UI is Cursor, use the Cursor section even
if `~/.claude/` or `~/.codex/` also exists. If you can't run Bash
at all, you are Cowork / a chat-only Claude Desktop surface — use
that section.

## Claude Code (any surface — CLI or Desktop "Code" tab)

### Step 1 — Detect your surface (CLI vs Desktop)

The `/plugin` and `/reload-plugins` slash commands work in the
Claude Code CLI but NOT in Claude Desktop's Code tab (see
anthropics/claude-code#42142). CLI users register the marketplace
with `/plugin marketplace add`; Desktop users edit
`~/.claude/settings.json` directly and restart the app to pick up
the change. You must figure out which surface you are in. The
user should not have to pick.

Read `$CLAUDE_CODE_ENTRYPOINT` — it cleanly tells you which one:

```bash
echo "${CLAUDE_CODE_ENTRYPOINT:-unset}"
```

Decide:

1. If the value is `claude-desktop` → **Desktop**.
2. If the value is `cli` → **CLI**.
3. If the value is anything else or `unset`, fall back to this
   probe and pick the matching surface:

   ```bash
   {
     echo "tty=$([ -t 0 ] && [ -t 1 ] && echo yes || echo no)"
     echo "term=${TERM:-unset}"
     echo "term_program=${TERM_PROGRAM:-unset}"
     echo "parent=$(ps -o comm= -p $PPID 2>/dev/null | tr -d ' ')"
   } 2>/dev/null
   ```

   - `tty=no` OR `term=unset` OR `parent` contains `claude` /
     `Claude.app` / `Electron` / `node` → **Desktop**.
   - `tty=yes` AND `term_program` is set (`iTerm.app`,
     `Apple_Terminal`, `Ghostty`, `WezTerm`, etc.) AND `parent`
     is a shell (`bash`, `zsh`, `fish`, `sh`, `dash`) → **CLI**.
   - Otherwise default to **CLI** — recoverable wrong-guess
     since the user can still restart the app if the slash
     commands do nothing.

### Step 2 — Print the install instructions

#### If CLI

Print exactly this and nothing else. Do not edit
`~/.claude/settings.json` — slash commands write the canonical
runtime state; a manual settings edit alone is invisible to
`/plugin install` until Claude Code restarts.

    Welcome to AIQ Rank. To get set up, just run these three
    slash commands. That's it! Copy-paste one at a time:

      1. /plugin marketplace add aiqrank/plugin
      2. /plugin install aiqrank@aiqrank
      3. /aiqrank

    You'll see your score in under 60 seconds.

    If /aiqrank doesn't load, run /reload-plugins once and try again.

    Stuck on install? Email support@aiqrank.com with the error
    message or screenshot and we'll help.

Do not run `/plugin marketplace add`, `/plugin install`,
`/reload-plugins`, or `/aiqrank` yourself; those are commands
the user invokes in their own session.

#### If Desktop

Desktop has no slash commands, so registering the marketplace
means editing `~/.claude/settings.json` directly, then restarting
the app so the change takes effect. Tell the user what's about
to happen and wait for confirmation:

    I'll register AIQ Rank in ~/.claude/settings.json (one
    marketplace entry; existing settings preserved). You'll need
    to restart Claude Desktop afterward so it picks up the
    change, then open the Code tab and run /aiqrank. OK to
    proceed?

When the user confirms (any affirmative), run this Python script:

```bash
python3 - <<'PY'
import json, os, pathlib, sys
p = pathlib.Path(os.path.expanduser("~/.claude/settings.json"))
p.parent.mkdir(parents=True, exist_ok=True)
raw = p.read_text() if p.exists() else ""
try:
    s = json.loads(raw) if raw.strip() else {}
except json.JSONDecodeError as e:
    sys.stderr.write(
        f"settings.json is not valid JSON ({e}). "
        "Please fix it manually and retry — no changes were made.\n"
    )
    sys.exit(1)
s.setdefault("extraKnownMarketplaces", {})["aiqrank"] = {
    "source": {"source": "github", "repo": "aiqrank/plugin"}
}
try:
    p.write_text(json.dumps(s, indent=2) + "\n")
except OSError as e:
    sys.stderr.write(
        f"Could not write {p} ({e}). Please check permissions, "
        "or use the manual install at https://aiqrank.com/setup.\n"
    )
    sys.exit(1)
print("settings.json updated")
PY
```

Then print exactly this and nothing else:

    AIQ Rank is registered. Restart Claude Desktop, then open the Code tab and type /aiqrank in the prompt to see your score.

    Stuck on install? Email support@aiqrank.com with the error message or screenshot and we'll help.

---

## Cowork / Claude Desktop chat

AIQ Rank can't run from inside Cowork. The chat sandbox — and
scheduled Cowork tasks — can't reach the user's transcript files
on the host (`~/.claude/projects/` for Claude Code activity and
`~/Library/Application Support/Claude/local-agent-mode-sessions/`
for Cowork activity). You cannot do the install for the user from
here. Print exactly this and nothing else:

    AIQ Rank can't run from inside Cowork — the chat sandbox can't
    reach your transcript files. To score your Cowork activity,
    install Claude Code (in your terminal, or the "Code" tab in
    Claude Desktop) and run /aiqrank there. It scans both your
    Claude Code AND Cowork activity in a single pass.

    Install guide: https://aiqrank.com/setup
    Stuck on install? Email support@aiqrank.com with the error
    message or screenshot and we'll help.

---

## Codex (OpenAI Codex CLI)

Codex installs AIQ Rank from a terminal, not from inside Codex.
Print exactly this and nothing else:

    AIQ Rank for Codex installs from a fresh terminal. Paste this:

      curl -sSL https://aiqrank.com/setup/codex | bash

    Then run /aiqrank in any Codex session.

    Stuck on install? Email support@aiqrank.com with the error
    message or screenshot and we'll help. Full instructions:
    https://aiqrank.com/setup

---

## Cursor

Cursor installs AIQ Rank through Cursor's plugin command. Print
exactly this and nothing else:

    Welcome to AIQ Rank. To get set up in Cursor, run this command:

      /add-plugin aiqrank/aiqrank

    Then run the AIQ Rank plugin in Cursor to get your score.

    AIQ Rank scans Cursor's local activity summary on this machine.
    Nothing uploads without your OK.

    Stuck on install? Email support@aiqrank.com with the error
    message or screenshot and we'll help.

Do not run `/add-plugin aiqrank/aiqrank` yourself; it is a Cursor
command the user invokes in their own session.
