Patchly — Skills

Patchly is an AI-powered error tracking service. It captures production errors, groups them by fingerprint, reads your source code from GitHub, and generates fix suggestions using an LLM.

How it works

  1. Install patchly in your app
  2. Initialise with a DSN from patchly.cc → Settings → your project
  3. Errors are captured automatically and visible in the Patchly dashboard
  4. When a group reaches 3 events, an AI fix is generated using your source code from GitHub

Install

npm install patchly

SDK

import { init } from "patchly";

const patchly = init({
  dsn: process.env.PATCHLY_DSN!,  // from patchly.cc → Settings → your project
  release?: string,                 // optional — app version, enables source map lookup
  userId?: string,                  // optional — track affected users
  autoCapture?: boolean,            // default: true — captures uncaught exceptions automatically
});

patchly.capture(error: Error);  // manual capture
await patchly.close();          // flush on graceful shutdown (Node.js)

Next.js (App Router)

instrumentation.ts — server-side auto-capture

Create at the project root:

export async function register() {
  if (process.env.NEXT_RUNTIME === "nodejs") {
    const { init } = await import("patchly");
    init({ dsn: process.env.PATCHLY_DSN! });
  }
}

Enable in next.config.ts:

const nextConfig = {
  experimental: { instrumentationHook: true },
};
export default nextConfig;

app/error.tsx — client-side error boundary

"use client";
import { useEffect } from "react";
import { init } from "patchly";

const patchly = init({ dsn: process.env.NEXT_PUBLIC_PATCHLY_DSN! });

export default function Error({ error, reset }: { error: Error; reset: () => void }) {
  useEffect(() => { patchly.capture(error); }, [error]);
  return (
    <div>
      <h2>Something went wrong</h2>
      <button type="button" onClick={reset}>Try again</button>
    </div>
  );
}

.env.local

PATCHLY_DSN=https://<key>@api.patchly.cc/<projectId>
NEXT_PUBLIC_PATCHLY_DSN=https://<key>@api.patchly.cc/<projectId>

Node.js / Express

import { init } from "patchly";

const patchly = init({ dsn: process.env.PATCHLY_DSN! });
// Uncaught exceptions are captured automatically via process.on("uncaughtException").

// Graceful shutdown — flush remaining events
process.on("SIGTERM", async () => {
  await patchly.close();
  process.exit(0);
});

Verify

  1. Set PATCHLY_DSN in your .env and run the app
  2. Trigger a test error: throw new Error("patchly test")
  3. Check patchly.cc — the event should appear within seconds
  4. After 3 events on the same error, an AI fix suggestion is generated automatically

Where to get your DSN

Log in at patchly.cc → Settings → create or select a project → copy the DSN.