agentleFS
VercelKnown publishervercel-labs/error/AGENTS.md

error

AGENTS.md19 starsChanged 2 months agoMITView on GitHub

@vercel/error keeps stable codes, developer details, and client-approved text separate. It builds HTTP response fields and formats terminal output without framework or runtime dependencies. Software branches on stable scope and code values, including those in ErrorResponseData. Frames and prose are for reading, not parsing. Read CONTEXT.md before naming or changing error-contract concepts. Read the accepted decisions and format rules in docs/adr/ before changing disclosure, response seams, module ownership, or cross-realm recognition. Keep feature implementations in src/<feature>/index.ts with colocated index.spec.ts tests.…

  • 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.

  • In this repositoryOne other file it gives its agents.

The file

Show its rules and text

We split this AGENTS.md into the rules it gives an agent

31 rules. About 0 are common, 8 are distinctive, and 23 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈8

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 23

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Read CONTEXT.md before naming or changing error-contract concepts.

    line 11
  2. Very specific:

    Keep feature implementations in src/<feature>/index.ts with colocated index.spec.ts tests.

    line 24
  3. Very specific:

    Keep the package framework-neutral, dependency-free at runtime, side-effect free on import, and compatible with package.json#sideEffects: …

    line 28
  4. Distinctive:

    Keep every module isomorphic: the same code runs in browsers, workers, edge runtimes, and Node.

    line 29
  5. Distinctive:

    Keep public entry modules independent.

    line 30
  6. Very specific:

    Treat dist/ as generated output.

    line 36
  7. Very specific:

    When a public entry point changes, update its source module, tsdown.config.ts, and the package.json export map together.

    line 38
  8. Very specific:

    Keep scope and code separate from messages.

    line 42
  9. Very specific:

    Put nested debugging context in metadata and flat telemetry values in attributes.

    line 43
  10. Very specific:

    Treat constructor message, reason, hint, fix, and link as developer-facing.

    line 44
  11. Very specific:

    Put client-approved prose under public, with a required nonblank public.message.

    line 45
  12. Very specific:

    If no exact range exists, a case-sensitive curl/ in User-Agent selects ANSI.

    line 51
  13. Distinctive:

    Treat scope, code, and status as disclosures.

    line 53
  14. Very specific:

    Use statusCode for authored mappings and status only for a concrete response.

    line 54
  15. Very specific:

    Keep request ID, metadata, attributes, cause, stack, developer name, and status out of ErrorResponseData and both serialized body formats.

    line 55
  16. Very specific:

    Treat toJSON() as diagnostic serialization.

    line 57
  17. Very specific:

    Keep cross-realm recognition as instanceof plus the namespaced symbol and data-shape validation.

    line 60
  18. Very specific:

    Treat VercelErrorLike metadata and attributes as unknown until validated.

    line 63
  19. Very specific:

    Keep create, raise, and report.

    line 64
  20. Very specific:

    Keep onReport and onSerialize synchronous with undefined return types.

    line 65
  21. Very specific:

    Keep auto, plain, tree, and ansi behind formatError.

    line 69
  22. Very specific:

    Keep hint, fix, and link as structured FrameSection values.

    line 70
  23. Distinctive:

    When public behavior, exports, field semantics, or examples change, update the README and every skill reference that states the changed …

    line 79
  24. Distinctive:

    Document every public symbol beside its export using the language's native JSDoc.

    line 83
  25. Distinctive:

    Keep implementation rationale in repository documentation or commit history rather than public JSDoc.

    line 93
  26. Very specific:

    Use the Node and pnpm versions declared in package.json.

    line 97
  27. Distinctive:

    Run the closest spec after a behavior change.

    line 99
  28. Very specific:

    Run pnpm typecheck regularly.

    line 100
  29. Distinctive:

    Test observable behavior through public interfaces.

    line 101
  30. Very specific:

    Run pnpm validate, pnpm build, and pnpm verify:packed before completion.

    line 102
  31. Very specific:

    Every push to main validates and attempts npm publication.

    line 107

≈ “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.

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

@vercel/error Agent Instructions

Purpose

@vercel/error keeps stable codes, developer details, and client-approved text separate. It builds HTTP response fields and formats terminal output without framework or runtime dependencies.

Software branches on stable scope and code values, including those in ErrorResponseData. Frames and prose are for reading, not parsing.

Source Map

Read CONTEXT.md before naming or changing error-contract concepts. Read the accepted decisions and format rules in docs/adr/ before changing disclosure, response seams, module ownership, or cross-realm recognition.

  • src/index.ts, client.ts, server.ts, and format.ts are the designated public entry modules.
  • src/vercel-error/ owns authored error fields, mutability, the stable tag, Error subclass behavior, and diagnostic toJSON().
  • src/error-response-data/ alone builds and parses client-facing data, then reconstructs errors from it.
  • src/to-error-response/ owns server response status validation, headers, and onSerialize ordering. src/wants-ansi/ implements the content negotiation it consumes.
  • src/from-http-response/ owns Web Response status and media-type checks, body consumption, and response-header request context.
  • src/format/ owns presets, sanitization, physical-line containment, connectors, labels, and color.
  • src/create-errors/ owns factory defaults, merge precedence, documentation links, custom constructors, and onReport ordering.
  • src/types.ts holds the shared contract types (PublicErrorDetails, VercelErrorOptions, VercelErrorLike); any feature may import it type-only.
  • Guard and extractor implementations remain in their named feature folders with colocated specs.
  • src/_internal/ is never exported.

Keep feature implementations in src/<feature>/index.ts with colocated index.spec.ts tests. Keep barrel files limited to the designated entry modules. Do not introduce generic core/, shared/, value/, transport/, ports/, or adapters/ directories.

Package Boundaries

  • Keep the package framework-neutral, dependency-free at runtime, side-effect free on import, and compatible with package.json#sideEffects: false.
  • Keep every module isomorphic: the same code runs in browsers, workers, edge runtimes, and Node. Feature-detect newer builtins with a documented fallback instead of requiring them.
  • Keep public entry modules independent. A public entry module never imports another public entry module.
  • vercel-error never imports response data, either HTTP response module, the client entry, or the server entry.
  • format never imports the class, response data, or either HTTP response module at runtime.
  • error-response-data never imports a public entry module or either HTTP response module.
  • The server response module reads symbol-recognized values as data and never invokes their methods.
  • The client response reader uses only the Web Response interface and response-data functions. It never reports an error, invents a fallback, or decides whether to trust response guidance.
  • Treat dist/ as generated output. Change source and rebuild.

When a public entry point changes, update its source module, tsdown.config.ts, and the package.json export map together. Prove the published subpath with the packed-consumer check (pnpm verify:packed).

Error Contract

  • Keep scope and code separate from messages. Either may be absent; defined values must be nonblank strings. Use trim() only to check blankness; keep the original value. Keep the original failure in cause.
  • Put nested debugging context in metadata and flat telemetry values in attributes. Keep secrets out of both.
  • Treat constructor message, reason, hint, fix, and link as developer-facing.
  • Put client-approved prose under public, with a required nonblank public.message.
  • Validate public at construction. Require a nonblank message and strings for optional fields. Omit blanks, drop unknown fields, and freeze a copy. Keep nonblank text unchanged.
  • errorResponse() builds client-safe output from public text or the fixed generic message. It rejects blank scope or code values when building a response.
  • Parsing rejects blank defined response identity and omits blank optional public details. Keep isVercelError(), isVercelErrorLikeData(), and hasCode() as structural guards with their current contracts.
  • X-Error-Format wins when present. Only exact ansi selects ANSI; other values select JSON.
  • Next, check exact text/plain+ansi ranges in Accept. They need supported parameters and valid q > 0 (default 1). Duplicates use the highest valid q. Exact ranges with no qualifying value select JSON and block the User-Agent fallback.
  • If no exact range exists, a case-sensitive curl/ in User-Agent selects ANSI. Wildcards do not.
  • JSON uses application/json; ANSI uses text/plain+ansi; charset=utf-8. Add Vary: X-Error-Format, Accept, User-Agent for either format whenever errorResponse() receives request; omit it when no request is supplied.
  • Treat scope, code, and status as disclosures. Protected-resource handlers own neutral identity and status mappings.
  • Use statusCode for authored mappings and status only for a concrete response. Server response production accepts integer error statuses from 400 through 599 and defaults omission to 500. Client response reading accepts only observed statuses in that range.
  • Keep request ID, metadata, attributes, cause, stack, developer name, and status out of ErrorResponseData and both serialized body formats.
  • fromHttpResponse() reads x-vercel-id into local requestId by default. An explicit request ID wins; callers can select another header or disable lookup. Treat the default as Vercel routing context, not an application trace ID.
  • Treat toJSON() as diagnostic serialization. It may contain developer prose, stack, metadata, attributes, and public data.
  • Parse known response data fields strictly and ignore unknown fields. Parsing validates shape, not producer trust or action authority.
  • Name data-level client functions parseErrorResponseData and fromErrorResponseData; reserve fromHttpResponse for native Web response consumption.
  • Keep cross-realm recognition as instanceof plus the namespaced symbol and data-shape validation. The tag is forgeable. Use instanceof VercelError when local methods are required.
  • Classify the package-namespaced tag before untagged public input; any other symbol carries no meaning. Tagged-invalid values throw instead of falling through.
  • Require untagged ErrorResponseInput to put approved prose under public. Reject a top-level untagged message.
  • Treat VercelErrorLike metadata and attributes as unknown until validated. Symbol-based recognition applies only while the tag remains observable; serialization channels use ErrorResponseData.
  • Keep create, raise, and report. Only report invokes onReport; create and raise stay free of reporting side effects. Without onReport, report writes a sanitized terminal frame to console.error.
  • Keep onReport and onSerialize synchronous with undefined return types. Synchronous callback exceptions propagate.

Rendering Contract

  • Keep auto, plain, tree, and ansi behind formatError. Only auto reads ambient terminal state.
  • Keep hint, fix, and link as structured FrameSection values. Renderer behavior comes from the token kind, not a parsed string prefix.
  • Sanitize every caller-controlled field, normalize CRLF, remove bare carriage returns, and frame every physical continuation line.
  • Preserve tabs, blank lines, and useful multiline text while keeping every continuation line under a library-owned prefix.
  • Render HTTP text from client-safe response data with explicit ansi; never call a method on a value recognized only by its symbol tag.

Public Documentation

The README documents the public interface and disclosure model. The installable skill lives at skills/vercel-error/SKILL.md.

When public behavior, exports, field semantics, or examples change, update the README and every skill reference that states the changed contract. Keep the skill on released interfaces; do not document unmerged behavior.

JSDoc Standard

Document every public symbol beside its export using the language's native JSDoc. State the facts a caller needs:

  • meaning and audience
  • required invariants and constraints
  • non-obvious defaults
  • observable precedence and ordering
  • errors and side effects
  • disclosure or trust implications at transport seams
  • one concise example when options interact

Keep implementation rationale in repository documentation or commit history rather than public JSDoc.

Development Workflow

Use the Node and pnpm versions declared in package.json.

  • Run the closest spec after a behavior change.
  • Run pnpm typecheck regularly. Specs are excluded from TypeScript, so prove public type changes through built declarations or the packed consumer.
  • Test observable behavior through public interfaces. Cover success, omission, malformed input, disclosure, and environment cases affected by the change.
  • Run pnpm validate, pnpm build, and pnpm verify:packed before completion.
  • For skill changes, run pnpm verify:skill; it must list vercel-error and verify that every relative inline Markdown link points to an existing path.

Releases

Every push to main validates and attempts npm publication. Before merge, set package.json to an unpublished version and ensure release validation runs packed-package and skill checks before publish.

Record each version in CHANGELOG.md. Keep each entry to one concise line under the applicable ### Patch Changes, ### Minor Changes, or ### Major Changes heading.

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.