Setup with an AI agent
Paste one prompt into a coding agent working in your backend repo. The agent installs the latest SDK, wires the environment, initializes errorcore, adds a test route, and verifies the result in a single pass. It works in Claude Code, Cursor, Codex, Windsurf, or any agent that can read and edit the repo.
Install and configure the errorcore SDK in this repository, end to end, in one pass.
Step 1. Inspect before editing.
Identify the package manager from the lockfile, the web framework, the server entrypoint, how environment variables are loaded, and any existing error middleware. If errorcore is already initialized somewhere, update that setup instead of duplicating it.
Step 2. Install the latest SDK.
Use the command that matches the lockfile:
npm install errorcore@latest
pnpm add errorcore@latest
yarn add errorcore@latest
bun add errorcore@latest
Step 3. Add server-side environment variables.
Write these into the server env file this repo already uses (.env or .env.local), and confirm that file is gitignored first. Keep the placeholders; never invent real values:
ERRORCORE_API_KEY="<ingestion API key from the errorcore console, starts with ec_live_>"
ERRORCORE_DEK="<64-hex payload encryption key from the errorcore console>"
ERRORCORE_ENVIRONMENT="production"
ERRORCORE_RELEASE="<full-git-commit-sha>"
ERRORCORE_INGEST_URL="https://api-production-7ecf.up.railway.app/v1/ingest"
Both keys are server-side only. Never expose them to browser code and never use a public env prefix such as NEXT_PUBLIC_ on any errorcore variable.
Set ERRORCORE_RELEASE from the deployment platform's full commit SHA. The SDK's .git/HEAD lookup is only a local convenience and is commonly unavailable in production containers.
Step 4. Initialize errorcore early.
In the server entrypoint, before database clients, HTTP clients, queues, or workers are created:
import { init } from "errorcore";
init({
service: "<short service name, for example core-api>",
deploymentEnv: process.env.ERRORCORE_ENVIRONMENT,
transport: {
type: "http",
url: process.env.ERRORCORE_INGEST_URL,
apiKey: process.env.ERRORCORE_API_KEY,
},
encryptionKey: process.env.ERRORCORE_DEK,
});
Framework notes: Express registers expressMiddleware() from "errorcore". Fastify registers fastifyPlugin from "errorcore". Hono registers honoMiddleware() from "errorcore/hono". Next.js initializes from instrumentation via "errorcore/nextjs" and wraps route handlers with withErrorcore(). NestJS has no dedicated adapter: initialize before the Nest app is created and, on the default Express platform, register expressMiddleware() through app.use(). Do not add SDK calls beyond the documented init(), captureError(), flush(), shutdown(), and getHealth() surface.
Step 5. Add one controlled test route.
Add a temporary GET /errorcore-test route that calls captureError(new Error("errorcore test error")), awaits flush(), and returns HTTP 202. Keep the route private when possible and remove it after the first event arrives. Do not make the errorcore console call this route.
Step 6. Verify.
Run the repo's typecheck and build scripts if they exist and fix anything your changes broke. Then start the app and call the route from a shell that can reach it. For a local app:
curl --request GET --url "http://localhost:3000/errorcore-test"
Adjust the port to this repo's dev server. For a deployed private app, run the same command inside its service network with the real internal origin. For a public app, use its real HTTPS origin.
Step 7. Report.
List every changed file, where initialization runs, which placeholders in the env file still need real values, and anything you could not verify. Finish by telling me to fill in the env values and watch the event arrive on the errorcore console Setup page.
Keep the diff minimal and do not commit secrets.What the agent will do
- Inspect the repo and detect the package manager, framework, and server entrypoint before editing.
- Install
errorcore@latestwith the package manager the lockfile says you use. - Append the five server-side environment variables (
ERRORCORE_API_KEY,ERRORCORE_DEK,ERRORCORE_ENVIRONMENT,ERRORCORE_RELEASE,ERRORCORE_INGEST_URL) to your gitignored env file, keeping placeholders for the values only you have. - Initialize errorcore in the server entrypoint through the framework's native error path.
- Add a temporary
GET /errorcore-testroute that callscaptureError(), awaitsflush(), and returns HTTP 202. - Run the repo's typecheck and build if they exist, then send the test error with curl.
- Report every changed file and the placeholders you still need to fill in.
After the agent finishes
Fill in ERRORCORE_API_KEY (issued in Settings → API keys) and ERRORCORE_DEK (issued in Settings → Encryption) with the values from the errorcore console. Copy ERRORCORE_INGEST_URL exactly from Setup. Set ERRORCORE_ENVIRONMENT=production and map the deployment platform's full commit SHA into ERRORCORE_RELEASE; .git/HEAD is only a convenience fallback and is commonly absent from production containers. Restart the server, then open Setup in the console. The listener follows your first event live from admitted to indexed, and links straight into the first case.
Review before you commit
The agent edits your env file and server entrypoint, so read the diff. Check that no real key values were written or committed, that initialization runs before database and HTTP clients are created, and that the diff stays minimal. The prompt forbids inventing values and adding SDK calls beyond the documented errorcore.init() shape; hold the agent to both.