jev-ai-sdk-form-router
AGENTS.md9 starsChanged 2 months agoMITView on GitHub
This is a Next.js 16 / React 19 template for routing three forms with Jev and AI SDK, with an independent fallback model and optional Resend delivery. Use ARCHITECTURE.md for the module map, data flow, and runtime boundaries. Use README.md for local setup and service configuration. Use Node.js 22+ and pnpm from the repository root. Preserve pnpm-lock.yaml and use the installed tool versions through package scripts. Forms and samples can be inspected without credentials. Live routing requires Gateway access, and…
- Reads credentials
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 35,337 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
20 rules. About 0 are common, 9 are distinctive, and 11 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈9
Distinctive · estimate
This author's own choices. Worth a look.
11
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 7
Use Node.js 22+ and pnpm from the repository root.
- Very specific: line 26
Keep fields, sample inputs, destination labels, and ownership criteria in lib/examples.ts.
- Very specific: line 27
Keep routing policy in lib/router.ts and workflow orchestration in lib/submission.ts.
- Very specific: line 28
Use app/[example]/page.tsx, components/router-form.tsx, and components/routing-result.tsx for all three examples.
- Very specific: line 30
Use emails/routed-submission.tsx for both previews and delivery.
- Distinctive: line 31
When adding an example, update the example-ID type, registry, server ID validation, and navigation.
- Distinctive: line 39
Keep Jev statistics attached to its original answer when displaying a fallback decision.
- Very specific: line 47
Write strict TypeScript. Prefer unknown over any, type narrowing over assertions, and as const or satisfies for registries and …
- Distinctive: line 48
Keep functions focused, use descriptive names and early returns, and await promises.
- Distinctive: line 49
Keep shared logic DRY without creating unnecessary files or abstractions.
- Very specific: line 50
Add TSDoc to exported contracts and non-obvious helpers, with applicable @param, @returns, @remarks, and @throws tags.
- Very specific: line 51
Use Server Components by default and client components for interactive state.
- Very specific: line 52
Use function components, stable keys, complete hook dependencies, and React 19 ref props.
- Distinctive: line 53
Prefer existing shadcn/Base UI components and theme tokens.
- Distinctive: line 57
Use semantic controls, associated labels, visible keyboard focus, appropriate button types, and pointer cursors for enabled buttons.
- Distinctive: line 60
Check all three routes at mobile and desktop widths after layout changes.
- Distinctive: line 65
Treat form fields and model output as untrusted.
- Very specific: line 66
Keep API keys in server environment variables.
- Very specific: line 67
Use rel="noopener noreferrer" for links opening new tabs.
- Distinctive: line 76
Keep README setup instructions and the architecture overview aligned with code changes.
≈ “Common” is an estimate: at least 1 in 5 of the 45,344 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Agent instructions
This is a Next.js 16 / React 19 template for routing three forms with Jev and AI SDK, with an independent fallback model and optional Resend delivery. Use ARCHITECTURE.md for the module map, data flow, and runtime boundaries. Use README.md for local setup and service configuration.
Setup and commands
Use Node.js 22+ and pnpm from the repository root. Preserve pnpm-lock.yaml and use the installed tool versions through package scripts.
| Command | Purpose |
pnpm install | Install dependencies |
pnpm dev | Start the Next.js development server |
pnpm fix | Apply Ultracite formatting and lint fixes |
pnpm check | Check formatting and lint rules |
pnpm typecheck | Check TypeScript |
pnpm knip | Find unused code and dependencies |
pnpm test | Run all Vitest tests without external calls |
pnpm exec vitest run lib/router.test.ts | Run focused routing tests |
pnpm validate | Run check, typecheck, Knip, and tests |
pnpm build | Build the production application |
Forms and samples can be inspected without credentials. Live routing requires Gateway access, and email delivery needs separate configuration. Unit tests supply their own mocks and environment values. Do not use real credentials or send real emails in automated tests.
Where to make changes
- Keep fields, sample inputs, destination labels, and ownership criteria in
lib/examples.ts. Derive validation and model choices from these definitions. - Keep routing policy in
lib/router.tsand workflow orchestration inlib/submission.ts. Keepapp/actions.tsthin. - Use
app/[example]/page.tsx,components/router-form.tsx, andcomponents/routing-result.tsxfor all three examples. Avoid separate copies per form. - Configure recipient addresses only in
lib/recipients.ts. Its keys derive from registered destination IDs. Usenullfor unconfigured destinations. - Use
emails/routed-submission.tsxfor both previews and delivery. Its inline styles are intentional for email compatibility. - When adding an example, update the example-ID type, registry, server ID validation, and navigation. When adding a destination, update the recipient map and relevant tests.
Routing and delivery invariants
- Infer ownership from the complete submission. Do not replace this with a user-selected team or a deterministic company-size rule.
- Accept Jev only when its registered answer has valid, unrounded confidence at least
0.95fromproviderMetadata.typesafe.confidence.destination. Never substitute selected-option probability for confidence. - Low, missing, or invalid confidence, or a Jev failure, invokes
openai/gpt-6-luna-fast. Pass the same state and criteria without Jev's answer. The fallback destination is final, including disagreements. Do not invent a comparable fallback confidence or add another review loop. - Validate model destinations against the current example. Keep provider timeouts and retries bounded. If routing fails, send no email.
- Keep Jev statistics attached to its original answer when displaying a fallback decision. Samples populate inputs and must not supply prerecorded results.
- Email delivery requires explicit opt-in and valid configuration for every destination on that form. Resolve the recipient from the server map and use only the validated submitter email as
replyTo. - Preserve successful routing when email delivery fails. Report Resend acceptance separately from inbox delivery. Retry a send with the same payload and idempotency key. A new manual submission is a new operation.
Code standards
Ultracite configures Oxlint and Oxfmt in oxlint.config.ts and oxfmt.config.ts. Follow those rules instead of introducing another formatter or lint system. Keep the experimental ai version pinned and verify behavior when changing it.
- Write strict TypeScript. Prefer
unknownoverany, type narrowing over assertions, andas constorsatisfiesfor registries and configuration. Use discriminated unions for outcomes. - Keep functions focused, use descriptive names and early returns, and await promises. Catch errors where they can become a meaningful application result.
- Keep shared logic DRY without creating unnecessary files or abstractions. Use explicit imports and avoid re-export barrels.
- Add TSDoc to exported contracts and non-obvious helpers, with applicable
@param,@returns,@remarks, and@throwstags. - Use Server Components by default and client components for interactive state. Keep
server-onlyprotection on provider, delivery, and recipient modules. Client components may use type-only imports from server modules. - Use function components, stable keys, complete hook dependencies, and React 19 ref props. Avoid defining components inside other components. Use App Router metadata and Next.js image components where applicable.
- Prefer existing shadcn/Base UI components and theme tokens. Read the project's shadcn skill when changing those components. Keep the neutral palette and Geist typography consistent.
Accessibility and interaction
- Use semantic controls, associated labels, visible keyboard focus, appropriate button types, and pointer cursors for enabled buttons. Hide decorative icons from assistive technology.
- Connect validation messages with
aria-describedbyand mark invalid inputs. Keep navigation state, pending state, and result announcements accessible. - Preserve inputs on failure. Clear stale results after edits, sample changes, reset, or email-option changes. Prevent duplicate submissions while pending.
- Check all three routes at mobile and desktop widths after layout changes. Keep forms at their natural height and leave padding between scrollable content and scrollbars. Check keyboard access to disclosures, popovers, and scroll regions.
- Preserve the sandboxed email iframe. Render submitted text through React Email rather than interpolating it into raw HTML.
Security and scope
- Treat form fields and model output as untrusted. Validate on the server before provider calls, and never accept client-supplied recipients or routing destinations.
- Keep API keys in server environment variables. Never print credentials, commit
.env.local, or expose private provider errors to the browser. Maintain placeholder names in.env.examplewhen configuration changes. - Use
rel="noopener noreferrer"for links opening new tabs. Avoideval, direct cookie assignments, and unsafe HTML insertion. - The template has no database, user authentication, submission history, or application rate limiter. Do not introduce these systems or deployment changes without task scope that calls for them.
Verification and handoff
- For routing or workflow changes, add focused tests to
lib/router.test.tsorlib/submission.test.ts. Use AI SDK mocks or injected dependencies for routing and mock Resend for delivery. Exercise real application logic rather than mocking the module under test. - Cover changed confidence boundaries, invalid metadata or output, independent fallback decisions, validation, recipient selection, and retry behavior. Keep tests deterministic, with assertions inside tests and no committed
.onlyor.skip. - For code changes, run
pnpm fix, inspect the diff, thenpnpm validateandpnpm build. Report any check that could not run or failed. Browser checks are manual, and live model checks require available credentials. - For documentation-only changes, check the touched Markdown with
pnpm exec oxfmt <files> --checkand rungit diff --check. Verify commands and links without running account provisioning or email sends. - Keep README setup instructions and the architecture overview aligned with code changes. Prefer official Vercel, AI SDK, TypeSafe, and Resend documentation for integration details.
- Preserve unrelated user edits. Summarize what changed, the checks performed, and material limitations. Keep commit and pull request descriptions focused on the resulting behavior.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

