npm package: @sailfish-ai/autofix
Description: Sailfish Autofix — Universal installer for AI coding agents. Installs the Autofix skill and MCP server across Claude Code, Cursor, Codex, Copilot, OpenCode, Windsurf, Gemini CLI, Goose, and 30+ more.
Author: Sailfish AI
Latest version: 0.1.1

# @sailfish-ai/autofix

Standalone installer for Sailfish Autofix — enables AI-powered bug fixing across AI coding agents without the desktop app.

## Quick Start

```bash
npx @sailfish-ai/autofix setup
```

This single command will:

1. Open your browser to authenticate with Sailfish
2. Detect which AI coding agents are installed on your machine
3. Install the Autofix skill and MCP server for each detected agent

Once setup is complete, open any supported agent and use `/autofix <issue-id>` to investigate and fix issues.

## Prerequisites

- **Node.js** >= 18.0.0
- A **Sailfish account** (sign up at [app.sailfish.ai](https://app.sailfish.ai))
- At least one supported AI coding agent installed

## Installation

### Option A: One-command setup (recommended)

No global install needed — `npx` runs it directly:

```bash
npx @sailfish-ai/autofix setup
```

### Option B: Install globally

```bash
npm install -g @sailfish-ai/autofix
sailfish-autofix setup
```

### Option C: From the Sailfish web app

Click "Fix with CLI" on any issue page to get a one-liner with an embedded auth token:

```bash
npx @sailfish-ai/autofix setup --token <token>
```

### Option D: Via Agent Skills

If your tool supports the [Agent Skills](https://agentskills.io) standard:

```bash
npx skills add @sailfish-ai/autofix
```

Note: This installs only the skill. Run `npx @sailfish-ai/autofix setup` separately to configure authentication and the MCP server.

## Supported Agents

| Agent | Skill Location | MCP Config Location |
|-------|---------------|---------------------|
| Claude Code | `~/.claude/skills/` | `~/.claude.json` |
| Cursor | `~/.cursor/skills/` | `~/.cursor/mcp.json` |
| Codex (OpenAI) | `~/.codex/skills/` | `~/.codex/config.toml` |
| GitHub Copilot | `~/.agents/skills/` | `~/.vscode/mcp.json` |
| OpenCode | `~/.agents/skills/` | `~/.config/opencode/config.json` |
| Windsurf | `~/.windsurf/skills/` | `~/.windsurf/mcp.json` |
| Gemini CLI | `~/.gemini/skills/` | `~/.gemini/settings.json` |
| Goose | `~/.agents/skills/` | `~/.config/goose/config.yaml` |
| Generic (Agent Skills) | `~/.agents/skills/` | Manual MCP setup |

All agents also get a copy at `~/.agents/skills/sailfish-autofix/` (cross-client convention).

## Commands

### `setup` — All-in-one install

```bash
npx @sailfish-ai/autofix setup [options]
```

Authenticates, detects agents, and installs the skill + MCP server configuration.

| Option | Description |
|--------|-------------|
| `--token <token>` | Use a pre-authenticated token from the Sailfish web app |
| `--global` | Install skill globally for all projects (default: true) |
| `--agents <list>` | Comma-separated list of agents to configure (e.g. `claude-code,cursor`) |
| `-y, --yes` | Skip confirmation prompts |

### `uninstall` — Clean removal

```bash
npx @sailfish-ai/autofix uninstall [options]
```

Removes all installed skills, MCP configurations, and optionally credentials.

| Option | Description |
|--------|-------------|
| `--keep-credentials` | Keep authentication credentials (only remove skill + MCP config) |
| `-y, --yes` | Skip confirmation prompts |

### `login` — Authenticate

```bash
npx @sailfish-ai/autofix login [options]
```

Opens your browser to sign in via OAuth. Credentials are stored at `~/.sailfish/credentials.json`.

| Option | Description |
|--------|-------------|
| `--token <token>` | Exchange a short-lived token instead of browser flow |

### `logout` — Remove credentials

```bash
npx @sailfish-ai/autofix logout
```

### `status` — Show current state

```bash
npx @sailfish-ai/autofix status
```

Displays authentication status and which agents have the skill and MCP server installed.

### `doctor` — Diagnose issues

```bash
npx @sailfish-ai/autofix doctor
```

Checks credentials, backend connectivity, and agent installations. Suggests fixes for any issues found. If credentials are expired, doctor will attempt to re-authenticate automatically.

### `serve` — Run MCP server

```bash
npx @sailfish-ai/autofix serve
```

Starts the MCP server in STDIO mode. This command is used internally by agent configurations — you don't need to run it manually.

## How It Works

The package installs two things for each detected agent:

1. **Agent Skill** (`SKILL.md`) — A workflow file following the [Agent Skills](https://agentskills.io) open standard. It tells the AI agent how to investigate and fix issues using Sailfish telemetry data.

2. **MCP Server** — A [Model Context Protocol](https://modelcontextprotocol.io) server that provides 12 tools for accessing telemetry:

   | Tool | Description |
   |------|-------------|
   | `autofix_get_issue_exceptions` | Fetch exception details, stack traces, occurrence counts |
   | `autofix_get_backend_logs` | Server-side logs for a recording session |
   | `autofix_get_frontend_logs` | Browser console logs |
   | `autofix_get_network_request_logs` | HTTP request/response logs |
   | `autofix_get_network_hops` | Service-to-service call chain (distributed tracing) |
   | `autofix_get_print_statements` | stdout/print output |
   | `autofix_get_user_actions` | User interaction events (clicks, navigation) |
   | `autofix_get_frontend_display_data` | Frontend display state snapshots |
   | `autofix_update_issue_status` | Report fix progress back to Sailfish |
   | `autofix_create_pull_request` | Create a PR via GitHub/Bitbucket integration |
   | `autofix_clone_repos` | Clone company repos locally |

## Credentials & Authentication

Credentials are stored at `~/.sailfish/credentials.json` with mode `0600` (owner read/write only).

The MCP server reads credentials via the `SAILFISH_JWT_FILE` environment variable, which is set automatically in agent configurations.

### Coexistence with Desktop App

This package works alongside the Sailfish desktop app (Veritas). They use compatible credential formats but separate configuration paths:

- **Desktop app**: writes MCP config as `sailfishTelemetry` / `sailfishEnterprise`
- **Standalone CLI**: writes MCP config as `sailfishAutofix`
- Both can coexist in the same agent configuration

## Troubleshooting

### "No supported agents detected"

The installer checks for known config directories and binaries. If your agent isn't detected:

```bash
npx @sailfish-ai/autofix setup --agents claude-code
```

### "Credentials expired"

```bash
npx @sailfish-ai/autofix login
```

### "Cannot reach backend"

Run `npx @sailfish-ai/autofix doctor` to diagnose connectivity issues. Ensure you can reach `https://api.sailfish.ai` from your network.

### Verify installation

```bash
npx @sailfish-ai/autofix status
```

Shows which agents have the skill and MCP server installed. All entries should show `skill` and `mcp`.

## License

MIT