agentleFS
VercelKnown publishervercel-labs/jev-ai-sdk-form-router/AGENTS.md

jev-ai-sdk-form-router

AGENTS.md10 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 checking a change actually works.

    Of the AGENTS.md files we read, the 11,773 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
  1. Very specific:

    Use Node.js 22+ and pnpm from the repository root.

    line 7
  2. Very specific:

    Keep fields, sample inputs, destination labels, and ownership criteria in lib/examples.ts.

    line 26
  3. Very specific:

    Keep routing policy in lib/router.ts and workflow orchestration in lib/submission.ts.

    line 27
  4. Very specific:

    Use app/[example]/page.tsx, components/router-form.tsx, and components/routing-result.tsx for all three examples.

    line 28
  5. Very specific:

    Use emails/routed-submission.tsx for both previews and delivery.

    line 30
  6. Distinctive:

    When adding an example, update the example-ID type, registry, server ID validation, and navigation.

    line 31
  7. Distinctive:

    Keep Jev statistics attached to its original answer when displaying a fallback decision.

    line 39
  8. Very specific:

    Write strict TypeScript. Prefer unknown over any, type narrowing over assertions, and as const or satisfies for registries and …

    line 47
  9. Distinctive:

    Keep functions focused, use descriptive names and early returns, and await promises.

    line 48
  10. Distinctive:

    Keep shared logic DRY without creating unnecessary files or abstractions.

    line 49
  11. Very specific:

    Add TSDoc to exported contracts and non-obvious helpers, with applicable @param, @returns, @remarks, and @throws tags.

    line 50
  12. Very specific:

    Use Server Components by default and client components for interactive state.

    line 51
  13. Very specific:

    Use function components, stable keys, complete hook dependencies, and React 19 ref props.

    line 52
  14. Distinctive:

    Prefer existing shadcn/Base UI components and theme tokens.

    line 53
  15. Distinctive:

    Use semantic controls, associated labels, visible keyboard focus, appropriate button types, and pointer cursors for enabled buttons.

    line 57
  16. Distinctive:

    Check all three routes at mobile and desktop widths after layout changes.

    line 60
  17. Distinctive:

    Treat form fields and model output as untrusted.

    line 65
  18. Very specific:

    Keep API keys in server environment variables.

    line 66
  19. Very specific:

    Use rel="noopener noreferrer" for links opening new tabs.

    line 67
  20. Distinctive:

    Keep README setup instructions and the architecture overview aligned with code changes.

    line 76

≈ “Common” is an estimate: at least 1 in 5 of the 16,595 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

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.

CommandPurpose
pnpm installInstall dependencies
pnpm devStart the Next.js development server
pnpm fixApply Ultracite formatting and lint fixes
pnpm checkCheck formatting and lint rules
pnpm typecheckCheck TypeScript
pnpm knipFind unused code and dependencies
pnpm testRun all Vitest tests without external calls
pnpm exec vitest run lib/router.test.tsRun focused routing tests
pnpm validateRun check, typecheck, Knip, and tests
pnpm buildBuild 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.ts and workflow orchestration in lib/submission.ts. Keep app/actions.ts thin.
  • Use app/[example]/page.tsx, components/router-form.tsx, and components/routing-result.tsx for all three examples. Avoid separate copies per form.
  • Configure recipient addresses only in lib/recipients.ts. Its keys derive from registered destination IDs. Use null for unconfigured destinations.
  • Use emails/routed-submission.tsx for 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.95 from providerMetadata.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 unknown over any, type narrowing over assertions, and as const or satisfies for 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 @throws tags.
  • Use Server Components by default and client components for interactive state. Keep server-only protection 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-describedby and 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.example when configuration changes.
  • Use rel="noopener noreferrer" for links opening new tabs. Avoid eval, 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.ts or lib/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 .only or .skip.
  • For code changes, run pnpm fix, inspect the diff, then pnpm validate and pnpm 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> --check and run git 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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.