---
name: patchly
description: Resolve production errors from Patchly — list open issues, fetch AI repair notes, draft fixes, and post patch comments.
---

# Patchly Error Resolution

Patchly is an AI-powered error tracker. Each production error becomes a Patchly issue with a stack trace and an AI-generated repair note. This skill lets you resolve those issues without leaving your editor.

## When to activate

Activate this skill when the user:
- Mentions a Patchly issue, error, or "what broke in production"
- Asks you to fix a production error
- References a Patchly issue ID or project ID

## MCP tools available

The Patchly MCP server exposes these tools. Use them in order:

| Tool | What it does |
|---|---|
| `list_issues` | List open issues for a project (needs `project_id`) |
| `get_issue` | Fetch full issue with stack trace + repair note |
| `get_repair_note` | Fetch just the AI fix suggestion |
| `post_comment` | Post a patch comment on the linked GitHub issue |
| `mark_patch_proposed` | Mark the issue as patch proposed |

## Standard workflow

1. **Identify the project** — ask the user for their Patchly project ID if you don't already have it, or call `list_issues` if they give you one.
2. **Fetch the issue** — call `get_issue` to read the full stack trace and repair note.
3. **Draft a local fix** — read the affected files in the editor and draft a fix based on the repair note and stack trace.
4. **Ask for confirmation** — show the user the proposed diff before applying.
5. **Apply the fix** — edit the files after the user approves.
6. **Post a comment** — call `post_comment` with a summary of the fix (Markdown supported). Include the file paths changed.
7. **Mark resolved** — call `mark_patch_proposed` to update the issue state in Patchly.

## Required environment variable

`PATCHLY_API_TOKEN` must be set in the MCP server config. The user can generate a token at **patchly.cc → Dashboard → Settings → Agent API Tokens**.

## Example invocation

User: "Fix the latest Patchly error in project proj_abc123"

```
1. list_issues({ project_id: "proj_abc123" })
2. get_issue({ issue_id: "<first open issue id>" })
3. Read affected files from the editor
4. Draft fix, show diff to user
5. Apply fix after approval
6. post_comment({ issue_id: "...", comment: "## Patch proposed\n\n..." })
7. mark_patch_proposed({ issue_id: "..." })
```
