Inngest Brownfield Audit
Use this skill when asked to inspect an existing codebase, add
Inngest "where it makes sense", migrate fragile background work, or find
durability gaps before making changes.
This is an agent-first workflow. Do the audit from evidence in the repo, name
the specific files and call sites that drove each conclusion, and make small
integration moves that preserve current behavior.
When to Trigger
Use this skill for requests like:
- "Audit this repo for Inngest opportunities"
- "Add Inngest to this codebase"
- "Make our webhooks / cron jobs / background tasks reliable"
- "Find places where work can be lost on deploy or process crash"
- "Replace fragile polling, delayed jobs, or fire-and-forget promises"
- "Make this AI workflow / agent durable"
If the user is starting from scratch instead of a brownfield repo, use
inngest-setup, inngest-durable-functions, inngest-events,
inngest-steps, and, for AI workflows, the agent patterns in this skill.
Audit Loop
Map the project shape.
- Read
package.json, workspace files, app/router structure, server entry
points, deployment config, and test scripts.
- Identify framework: Next.js App Router, Next.js Pages Router, Express,
Hono, Fastify, Remix, SvelteKit, Astro, NestJS, worker-only service, or
other.
- Detect package manager and TypeScript conventions before adding files.
Find existing Inngest usage.
- Search for
inngest, createFunction, serve(, /api/inngest,
INNGEST_, step.run, step.sleep, step.waitForEvent,
step.sendEvent, step.invoke, step.ai, inngest.send, and
@inngest/realtime.
- If Inngest exists, inspect version, client config, serve endpoint,
registered functions, event naming, env vars, and v3/v4 API shape before
changing anything.
Find durability gaps.
- Search for fire-and-forget work:
void someAsync(), un-awaited promises,
.then( chains, setTimeout, setInterval, detached jobs after HTTP
response, and background work in route handlers.
- Search for cron and schedulers:
cron, node-cron, agenda, bull,
bullmq, bee-queue, qstash, sqs, temporal, trigger.dev,
deployment cron config, and scheduled API routes.
- Search for webhooks and at-least-once producers: Stripe, Clerk, GitHub,
Slack, Shopify, HubSpot, Linear, Svix, and generic
webhook.
- Search for long-running work: PDF generation, exports, video/image
processing, embeddings, bulk email, imports, ETL, sync jobs, polling loops,
retries, and external API calls.
- Search for AI agent shapes: tool loops, LLM calls, streaming tokens,
human approval, multi-step reasoning, vector search, eval loops, and
provider calls that need rate limits or retry-safe state.
Classify each candidate.
- P0: user-visible loss, duplicate charge/email/action, timeout, missed
webhook, or crash-prone workflow.
- P1: fragile but recoverable background work, manual retry burden,
noisy 429s, or poor observability.
- P2: cleanup, ergonomics, or future migration opportunity.
- For each candidate, record: file, current trigger, side effects,
idempotency key, failure mode, recommended Inngest primitive, migration
size, and confidence.
Choose the smallest safe integration.
- Prefer one vertical slice over a wide rewrite.
- Keep existing domain functions and data models where possible.
- Add an Inngest client and serve endpoint only once.
- Move side effects into
step.run one boundary at a time.
- Make event IDs and database writes idempotent before adding retries.
- Add tests around existing behavior and the new event/function boundary.
Useful Discovery Commands
Run commands that fit the repo. Prefer rg; keep output focused.
rg -n "inngest|createFunction|step\\.|serve\\(|/api/inngest|INNGEST_" .
rg -n "setTimeout|setInterval|Promise\\.all|void [a-zA-Z0-9_]+\\(|\\.then\\(" .
rg -n "cron|node-cron|schedule|bull|bullmq|bee-queue|agenda|qstash|sqs" .
rg -n "webhook|stripe|svix|clerk|github|shopify|slack|hubspot|linear" .
rg -n "retry|backoff|poll|status|timeout|429|rate limit|rate-limit" .
rg -n "openai|anthropic|ai\\.|generateText|streamText|tool|agent|embedding" .
When the repo is large, narrow searches to app source directories and exclude
generated/vendor folders.
Brownfield Decision Matrix
| Existing shape |
Inngest fit |
Primary primitives |
| HTTP handler does slow side effects before responding |
Emit event, return fast |
inngest.send, event trigger, step.run |
| Webhook must acknowledge quickly but process reliably |
Verify signature, emit idempotent event |
Event ID, step.run, retries |
| Cron job loses progress midway |
Cron-triggered durable function |
Cron trigger, page-level step.run, flow control |
| Polling loop waits for external async work |
Durable wait or durable poll |
step.waitForEvent, step.sleep, step.run |
| Large fan-out exceeds request/serverless limits |
Split orchestration and item work |
step.sendEvent, per-item function, concurrency |
| External API hits 429s |
Move limits to function config |
throttle, rateLimit, concurrency |
| Human review can take days |
Persist the wait in Inngest |
step.waitForEvent, timeout, realtime |
| AI agent/tool loop needs retry-safe progress |
One step per tool/model boundary |
step.ai, step.run, step.sleep, realtime |
| Existing queue only hides fragile work |
Replace queue boundary gradually |
Event trigger, idempotency, function-level retries |
Integration Plan Format
Before editing, summarize findings in this compact shape:
Inngest audit:
- Existing Inngest: none / partial / healthy / risky
- Framework: <framework and evidence>
- Best first slice: <file + workflow>
- Why: <loss/timeout/retry/idempotency failure>
- Proposed primitives: <event, steps, flow control, waits, realtime>
- Idempotency key: <source of truth>
- Files likely touched: <short list>
- Tests/checks: <commands or focused cases>
Then implement unless the user asked for audit-only.
Existing Inngest Checklist
If Inngest is already present, verify:
- A single shared client is exported from a stable module.
- The app
id is a stable slug and is not derived from deploy-specific data.
- v4 local development uses
INNGEST_DEV=1; production uses
INNGEST_SIGNING_KEY.
- Serve endpoint path is discoverable, usually
/api/inngest.
- The serve handler registers all functions that should sync.
- Side effects and non-deterministic work are inside steps.
- Step IDs are stable and descriptive.
- Event names follow
domain/noun.verb.
- Events that may be replayed use deterministic IDs.
- Webhook handlers verify signatures before emitting events.
- Flow control is configured where external APIs have limits.
- Realtime uses v4 native
inngest/realtime, not the v3
@inngest/realtime package.
Durable Agent Patterns
Use Inngest when an AI or agent workflow needs durable progress across model
calls, tool calls, waits, approvals, or streaming UI updates.
Good candidates:
- Multi-step agent that calls tools or external APIs.
- LLM workflow that may exceed one HTTP request lifetime.
- Human-in-the-loop review, approval, correction, or escalation.
- Agent that must pause for an external event or scheduled follow-up.
- Bulk AI work that needs provider-level rate limits and cost protection.
- User-visible agent progress that should stream from durable execution.
Recommended shape:
- HTTP/UI request stores the user intent and emits an event with a stable
id.
- Inngest function loads state inside
step.run.
- Each model call, tool call, vector search, and external side effect lives in
its own
step.ai or step.run boundary.
- Human pauses use
step.waitForEvent or step.waitForSignal with a timeout.
- Progress updates use
step.realtime.publish between steps, or
inngest.realtime.publish inside an existing step.run.
- Provider rate limits use
concurrency, throttle, or rateLimit, not
ad hoc in-process throttlers.
Avoid:
- Keeping agent state only in memory.
- Retrying whole agent loops after a single tool failure.
- Charging for repeated successful model calls because the result was not
memoized.
- Using
setTimeout or a cron poller for follow-ups and approvals.
- Streaming progress from a process-local WebSocket server when the workflow
itself is durable elsewhere.
Implementation Guardrails
- Do not replace working queues, crons, or webhooks blindly. First preserve
behavior with a thin Inngest slice.
- Do not create duplicate clients or serve endpoints if the repo already has
them.
- Do not put database writes, API calls, random IDs, timestamps, or LLM calls
outside steps in the new function.
- Do not hide missing idempotency behind retries. Retries require idempotent
side effects.
- Do not hardcode secrets or dev-mode flags in source.
- Do not leave the app unable to sync: register new functions with the serve
endpoint and run available type/tests.
Verification
Pick checks that prove the integration path:
- Typecheck/build/lint the touched app.
- Run existing tests around the migrated handler or workflow.
- Add focused tests for "handler emits event and returns fast" and "function
calls the same domain operations in step boundaries" where the repo supports
it.
- If local runtime is available, start the app and Inngest dev server, confirm
the function syncs, then send a sample event.
- If only static checks are available, explicitly state that runtime sync was
not verified.
1---2name: inngest-brownfield-audit3description: Use when analyzing an existing TypeScript or JavaScript codebase to decide where and how to introduce Inngest. Covers repository discovery, framework and package detection, finding durability gaps in HTTP handlers, webhooks, cron jobs, queues, long-running jobs, AI agents, polling loops, and side-effect-heavy code, then producing and implementing an incremental integration plan.4---5
6# Inngest Brownfield Audit
7
8Use this skill when asked to inspect an existing codebase, add
9Inngest "where it makes sense", migrate fragile background work, or find
10durability gaps before making changes.
11
12This is an agent-first workflow. Do the audit from evidence in the repo, name
13the specific files and call sites that drove each conclusion, and make small
14integration moves that preserve current behavior.
15
16## When to Trigger
17
18Use this skill for requests like:
19
20- "Audit this repo for Inngest opportunities"
21- "Add Inngest to this codebase"
22- "Make our webhooks / cron jobs / background tasks reliable"
23- "Find places where work can be lost on deploy or process crash"
24- "Replace fragile polling, delayed jobs, or fire-and-forget promises"
25- "Make this AI workflow / agent durable"
26
27If the user is starting from scratch instead of a brownfield repo, use
28`inngest-setup`, `inngest-durable-functions`, `inngest-events`,
29`inngest-steps`, and, for AI workflows, the agent patterns in this skill.
30
31## Audit Loop
32
331. **Map the project shape.**
34 - Read `package.json`, workspace files, app/router structure, server entry
35 points, deployment config, and test scripts.
36 - Identify framework: Next.js App Router, Next.js Pages Router, Express,
37 Hono, Fastify, Remix, SvelteKit, Astro, NestJS, worker-only service, or
38 other.
39 - Detect package manager and TypeScript conventions before adding files.
40
412. **Find existing Inngest usage.**
42 - Search for `inngest`, `createFunction`, `serve(`, `/api/inngest`,
43 `INNGEST_`, `step.run`, `step.sleep`, `step.waitForEvent`,
44 `step.sendEvent`, `step.invoke`, `step.ai`, `inngest.send`, and
45 `@inngest/realtime`.
46 - If Inngest exists, inspect version, client config, serve endpoint,
47 registered functions, event naming, env vars, and v3/v4 API shape before
48 changing anything.
49
503. **Find durability gaps.**
51 - Search for fire-and-forget work: `void someAsync()`, un-awaited promises,
52 `.then(` chains, `setTimeout`, `setInterval`, detached jobs after HTTP
53 response, and background work in route handlers.
54 - Search for cron and schedulers: `cron`, `node-cron`, `agenda`, `bull`,
55 `bullmq`, `bee-queue`, `qstash`, `sqs`, `temporal`, `trigger.dev`,
56 deployment cron config, and scheduled API routes.
57 - Search for webhooks and at-least-once producers: Stripe, Clerk, GitHub,
58 Slack, Shopify, HubSpot, Linear, Svix, and generic `webhook`.
59 - Search for long-running work: PDF generation, exports, video/image
60 processing, embeddings, bulk email, imports, ETL, sync jobs, polling loops,
61 retries, and external API calls.
62 - Search for AI agent shapes: tool loops, LLM calls, streaming tokens,
63 human approval, multi-step reasoning, vector search, eval loops, and
64 provider calls that need rate limits or retry-safe state.
65
664. **Classify each candidate.**
67 - **P0:** user-visible loss, duplicate charge/email/action, timeout, missed
68 webhook, or crash-prone workflow.
69 - **P1:** fragile but recoverable background work, manual retry burden,
70 noisy 429s, or poor observability.
71 - **P2:** cleanup, ergonomics, or future migration opportunity.
72 - For each candidate, record: file, current trigger, side effects,
73 idempotency key, failure mode, recommended Inngest primitive, migration
74 size, and confidence.
75
765. **Choose the smallest safe integration.**
77 - Prefer one vertical slice over a wide rewrite.
78 - Keep existing domain functions and data models where possible.
79 - Add an Inngest client and serve endpoint only once.
80 - Move side effects into `step.run` one boundary at a time.
81 - Make event IDs and database writes idempotent before adding retries.
82 - Add tests around existing behavior and the new event/function boundary.
83
84## Useful Discovery Commands
85
86Run commands that fit the repo. Prefer `rg`; keep output focused.
87
88```bash
89rg -n "inngest|createFunction|step\\.|serve\\(|/api/inngest|INNGEST_" .
90rg -n "setTimeout|setInterval|Promise\\.all|void [a-zA-Z0-9_]+\\(|\\.then\\(" .
91rg -n "cron|node-cron|schedule|bull|bullmq|bee-queue|agenda|qstash|sqs" .
92rg -n "webhook|stripe|svix|clerk|github|shopify|slack|hubspot|linear" .
93rg -n "retry|backoff|poll|status|timeout|429|rate limit|rate-limit" .
94rg -n "openai|anthropic|ai\\.|generateText|streamText|tool|agent|embedding" .
95```
96
97When the repo is large, narrow searches to app source directories and exclude
98generated/vendor folders.
99
100## Brownfield Decision Matrix
101
102| Existing shape | Inngest fit | Primary primitives |
103|---|---|---|
104| HTTP handler does slow side effects before responding | Emit event, return fast | `inngest.send`, event trigger, `step.run` |
105| Webhook must acknowledge quickly but process reliably | Verify signature, emit idempotent event | Event ID, `step.run`, retries |
106| Cron job loses progress midway | Cron-triggered durable function | Cron trigger, page-level `step.run`, flow control |
107| Polling loop waits for external async work | Durable wait or durable poll | `step.waitForEvent`, `step.sleep`, `step.run` |
108| Large fan-out exceeds request/serverless limits | Split orchestration and item work | `step.sendEvent`, per-item function, concurrency |
109| External API hits 429s | Move limits to function config | `throttle`, `rateLimit`, `concurrency` |
110| Human review can take days | Persist the wait in Inngest | `step.waitForEvent`, timeout, realtime |
111| AI agent/tool loop needs retry-safe progress | One step per tool/model boundary | `step.ai`, `step.run`, `step.sleep`, realtime |
112| Existing queue only hides fragile work | Replace queue boundary gradually | Event trigger, idempotency, function-level retries |
113
114## Integration Plan Format
115
116Before editing, summarize findings in this compact shape:
117
118```text
119Inngest audit:
120- Existing Inngest: none / partial / healthy / risky
121- Framework: <framework and evidence>
122- Best first slice: <file + workflow>
123- Why: <loss/timeout/retry/idempotency failure>
124- Proposed primitives: <event, steps, flow control, waits, realtime>
125- Idempotency key: <source of truth>
126- Files likely touched: <short list>
127- Tests/checks: <commands or focused cases>
128```
129
130Then implement unless the user asked for audit-only.
131
132## Existing Inngest Checklist
133
134If Inngest is already present, verify:
135
136- A single shared client is exported from a stable module.
137- The app `id` is a stable slug and is not derived from deploy-specific data.
138- v4 local development uses `INNGEST_DEV=1`; production uses
139 `INNGEST_SIGNING_KEY`.
140- Serve endpoint path is discoverable, usually `/api/inngest`.
141- The serve handler registers all functions that should sync.
142- Side effects and non-deterministic work are inside steps.
143- Step IDs are stable and descriptive.
144- Event names follow `domain/noun.verb`.
145- Events that may be replayed use deterministic IDs.
146- Webhook handlers verify signatures before emitting events.
147- Flow control is configured where external APIs have limits.
148- Realtime uses v4 native `inngest/realtime`, not the v3
149 `@inngest/realtime` package.
150
151## Durable Agent Patterns
152
153Use Inngest when an AI or agent workflow needs durable progress across model
154calls, tool calls, waits, approvals, or streaming UI updates.
155
156Good candidates:
157
158- Multi-step agent that calls tools or external APIs.
159- LLM workflow that may exceed one HTTP request lifetime.
160- Human-in-the-loop review, approval, correction, or escalation.
161- Agent that must pause for an external event or scheduled follow-up.
162- Bulk AI work that needs provider-level rate limits and cost protection.
163- User-visible agent progress that should stream from durable execution.
164
165Recommended shape:
166
1671. HTTP/UI request stores the user intent and emits an event with a stable
168 `id`.
1692. Inngest function loads state inside `step.run`.
1703. Each model call, tool call, vector search, and external side effect lives in
171 its own `step.ai` or `step.run` boundary.
1724. Human pauses use `step.waitForEvent` or `step.waitForSignal` with a timeout.
1735. Progress updates use `step.realtime.publish` between steps, or
174 `inngest.realtime.publish` inside an existing `step.run`.
1756. Provider rate limits use `concurrency`, `throttle`, or `rateLimit`, not
176 ad hoc in-process throttlers.
177
178Avoid:
179
180- Keeping agent state only in memory.
181- Retrying whole agent loops after a single tool failure.
182- Charging for repeated successful model calls because the result was not
183 memoized.
184- Using `setTimeout` or a cron poller for follow-ups and approvals.
185- Streaming progress from a process-local WebSocket server when the workflow
186 itself is durable elsewhere.
187
188## Implementation Guardrails
189
190- Do not replace working queues, crons, or webhooks blindly. First preserve
191 behavior with a thin Inngest slice.
192- Do not create duplicate clients or serve endpoints if the repo already has
193 them.
194- Do not put database writes, API calls, random IDs, timestamps, or LLM calls
195 outside steps in the new function.
196- Do not hide missing idempotency behind retries. Retries require idempotent
197 side effects.
198- Do not hardcode secrets or dev-mode flags in source.
199- Do not leave the app unable to sync: register new functions with the serve
200 endpoint and run available type/tests.
201
202## Verification
203
204Pick checks that prove the integration path:
205
206- Typecheck/build/lint the touched app.
207- Run existing tests around the migrated handler or workflow.
208- Add focused tests for "handler emits event and returns fast" and "function
209 calls the same domain operations in step boundaries" where the repo supports
210 it.
211- If local runtime is available, start the app and Inngest dev server, confirm
212 the function syncs, then send a sample event.
213- If only static checks are available, explicitly state that runtime sync was
214 not verified.