> ## Documentation Index
> Fetch the complete documentation index at: https://docs.codeant.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Cursor Integration

> Integrate CodeAnt AI code review and PR comment resolution into your Cursor AI workflow

Integrate CodeAnt AI into [Cursor](https://cursor.com) to resolve PR review comments, review local changes, and generate custom review rules — driven by Cursor's AI agent.

## What You Get

Three Cursor Skills that teach the AI agent how to use the CodeAnt CLI:

| Slash Command                       | Description                                                          |
| ----------------------------------- | -------------------------------------------------------------------- |
| `/codeant-review`                   | Run a CodeAnt code review on local changes and fix all issues        |
| `/codeant-resolve-pr-comments`      | Fetch unresolved CodeAnt review comments on a PR and fix them        |
| `/codeant-implement-repo-learnings` | Learn team review patterns from PR history and generate custom rules |

## Prerequisites

1. **Cursor 2.4 or later** — the new Skills system requires this minimum version ([download](https://cursor.com))

2. **CodeAnt CLI** installed and authenticated — follow the [CLI setup guide](https://docs.codeant.ai/cli/setup)

## Installation

### Option 1: Clone from Skills Repo (Recommended)

Run these commands from your project root:

```bash theme={null}
mkdir -p .cursor/skills
git clone https://github.com/CodeAnt-AI/skills.git /tmp/codeant-skills
cp -r /tmp/codeant-skills/cursor/skills/* .cursor/skills/
rm -rf /tmp/codeant-skills
```

Commit to share with your team:

```bash theme={null}
git add .cursor/skills/
git commit -m "Add CodeAnt AI Cursor skills"
```

### Option 2: Create Manually

Create the skill files under `.cursor/skills/` — see the full skill content in the [skills repository](https://github.com/CodeAnt-AI/skills/tree/main/cursor/skills).

Each skill is a `SKILL.md` file inside its own directory:

```
.cursor/skills/
├── codeant-review/SKILL.md
├── codeant-resolve-pr-comments/SKILL.md
└── codeant-implement-repo-learnings/SKILL.md
```

<Accordion title="Migrating from the legacy .mdc rule?">
  If you previously installed the `.mdc` rule file to `.cursor/rules/codeant.mdc`, you can migrate to the new Skills format:

  1. Install the new skills using the instructions above
  2. Delete the old rule file: `rm .cursor/rules/codeant.mdc`
  3. Restart Cursor

  The new Skills format provides slash command invocation, better discoverability, and feature parity with the Claude Code integration.
</Accordion>

## Usage

### `/codeant-resolve-pr-comments` — Resolve PR Review Comments

Fetch all unresolved CodeAnt AI review comments on a pull request and fix them.

**With a PR number:**

```
> /codeant-resolve-pr-comments 42
```

**Auto-detect from current branch:**

```
> /codeant-resolve-pr-comments
```

Or use natural language:

```
> Fix all unresolved CodeAnt comments on my current PR
```

**The fix flow:**

1. **Find the PR** — detects from current branch or uses the provided PR number
2. **Fetch comments** — runs `codeant pr comments --pr-number <N> --codeant-generated true` and filters to unresolved comments
3. **Categorize** — separates inline code comments (actionable) from general PR-level comments (informational, skipped)
4. **Analyze and assign verdicts** — for each comment:
   * Reads the file with 30 lines of surrounding context
   * Checks the code still matches what the comment describes
   * Extracts code suggestions from the comment body
   * Validates syntax, variable scope, imports, and that existing logic is not broken
   * Assigns a verdict: **ACCEPT**, **LIKELY ACCEPT**, **DO NOT ACCEPT**, or **STALE**
5. **Present summary** — shows all comments grouped by verdict with before/after code diffs
6. **Apply safe fixes** — applies ACCEPT fixes, asks about LIKELY ACCEPT, skips DO NOT ACCEPT and STALE
7. **Resolve threads** — marks applied comments as resolved on the PR via `codeant pr resolve`
8. **Offer to commit** — lists changed files and offers to commit and push

Changes are **not committed automatically** — you review the diffs and decide.

***

### `/codeant-review` — Review and Fix Local Changes

Run a CodeAnt AI code review on your local changes and fix all issues found.

```
> /codeant-review
```

You can specify the review scope:

```
> /codeant-review staged files only
> /codeant-review last commit
> /codeant-review against the develop branch
```

The skill selects the right flag based on your request:

| You say                          | Flag used                 |
| -------------------------------- | ------------------------- |
| "staged"                         | `--staged`                |
| "uncommitted" / nothing specific | `--uncommitted` (default) |
| "last commit"                    | `--last-commit`           |
| "last 3 commits"                 | `--last-n-commits 3`      |
| "unpushed" / "committed"         | `--committed`             |
| a branch name                    | `--base <branch>`         |
| a commit hash                    | `--base-commit <hash>`    |
| "everything" / "all"             | `--all`                   |

**The fix flow:**

1. **Run review** — executes `codeant review <scope-flag>`
2. **Present findings** — shows issues grouped by file with category labels (Security, Code Quality, Performance, Maintainability)
3. **Analyze and assign verdicts** — classifies each issue as ACCEPT, LIKELY ACCEPT, DO NOT ACCEPT, or STALE
4. **Present summary with verdicts** — shows before/after code diffs, highlights Security issues first
5. **Apply safe fixes** — minimal changes only, skips anything that could break existing logic
6. **Verify** — re-runs the review to confirm fixes are clean
7. **Report** — initial findings, fixes applied, fixes skipped (and why), and verification results

Changes are **not committed automatically** — you review the diffs and commit when ready.

***

### `/codeant-implement-repo-learnings` — Generate Custom Review Rules

Analyze your team's PR review history to generate custom CodeAnt review rules.

```
> /codeant-implement-repo-learnings
```

**The workflow:**

1. **Fetch PR history** — retrieves the last 100 merged PRs
2. **Extract human feedback** — fetches review comments, filters out bots and non-actionable replies
3. **Analyze bug-fix commits** — mines git history for recurring fix patterns
4. **Read project guidelines** — extracts conventions from `.cursorrules`, `CLAUDE.md`, `CONTRIBUTING.md`, etc.
5. **Cluster patterns** — groups feedback into rule candidates with confidence levels (HIGH/MEDIUM)
6. **Interactive confirmation** — presents each rule with evidence for your approval
7. **Write rules** — generates `.codeant/review.json` with your approved rules

Rules are merged with any existing `.codeant/review.json` — nothing is overwritten without confirmation.

## Verdict System

All fix workflows use a verdict system to classify each suggestion before applying:

| Verdict           | Meaning                                                                           | Action                              |
| ----------------- | --------------------------------------------------------------------------------- | ----------------------------------- |
| **ACCEPT**        | Safe to apply — fix is correct, localized, and won't break anything               | Applied automatically               |
| **LIKELY ACCEPT** | Probably correct, but may affect callers or tests                                 | Applied only with user confirmation |
| **DO NOT ACCEPT** | Could break logic — changes signatures, removes error handling, or over-refactors | Skipped with explanation            |
| **STALE**         | Code has changed since the review — comment no longer applies                     | Skipped with explanation            |

## Example Workflows

### Resolve PR Comments

```
> /codeant-resolve-pr-comments

Found PR #42: "Add payment processing" (feature/payments → main)

6 unresolved CodeAnt comments:

ACCEPT — Safe to apply (3):
  src/auth.ts:34 — SQL injection in login query
    Fix: parameterize the query → safe, no API change
  src/auth.ts:78 — Missing rate limiting
    Fix: add rate limiting middleware → safe, additive only
  src/api/users.ts:45 — Magic number should be a constant
    Fix: extract to named constant → safe, no behavior change

LIKELY ACCEPT — Verify callers (1):
  src/api/users.ts:12 — Unvalidated input
    Fix: add validation → callers may depend on permissive behavior

DO NOT ACCEPT (0)
STALE (0)

Manual review needed (2):
  PR-level comments about error handling strategy and test coverage

I will apply the 3 ACCEPT fixes now. Want me to also apply
the LIKELY ACCEPT fix, or skip it for now?

> apply all

✓ Applied src/auth.ts:34 — parameterized the SQL query
✓ Applied src/auth.ts:78 — added rate limiting middleware
✓ Applied src/api/users.ts:45 — extracted magic number to constant
✓ Applied src/api/users.ts:12 — added input validation

Resolving applied comments on PR...
✓ 4 comments resolved

Changes ready for review. Would you like me to commit and push?
```

### Review → Fix → Ship

```
> Implement the user authentication endpoint

(Cursor implements the feature)

> /codeant-review

Found 3 issues:
  Security: Missing input sanitization (src/auth.ts:15)   — ACCEPT
  Code Quality: Unused variable (src/auth.ts:8)            — ACCEPT
  Code Quality: Missing error handling (src/auth.ts:42)    — ACCEPT

All 3 fixes applied. Verification passed — no remaining issues.

> git add -A && git commit -m "Add auth endpoint"
```

## How It Works

Each skill is a `SKILL.md` file inside `.cursor/skills/` — part of Cursor's [Agent Skills](https://cursor.com/docs/skills) system. Skills teach the Cursor agent specialized workflows through detailed step-by-step instructions.

Skills are automatically discovered by Cursor and can be invoked via `/skill-name` slash commands or triggered automatically when the agent determines they're relevant. You can also reference them naturally in conversation (e.g., "review my changes with CodeAnt").

## Troubleshooting

**"codeant: command not found"**

Ensure the CLI is installed globally and accessible from Cursor's terminal:

```bash theme={null}
npm install -g codeant-cli
codeant --version
```

If using nvm, ensure the correct Node version is active in Cursor's integrated terminal.

**"Not authenticated" or "Could not detect remote"**

```bash theme={null}
codeant login                           # CodeAnt API auth
codeant set-token github <your-token>   # SCM auth for PR features
```

**Skills not appearing**

* Verify `.cursor/skills/codeant-review/SKILL.md` exists (and similar for other skills)
* Restart Cursor after adding skills
* Check Settings → Rules to see if skills appear under "Agent Decides"
* Be explicit: "Use CodeAnt to review my changes" or use `/codeant-review`
