error
AGENTS.md19 starsChanged 3 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 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.
In this repositoryOne other file it gives its agents.
- vercel-errorSkill
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
- Very specific: line 11
Read CONTEXT.md before naming or changing error-contract concepts.
- Very specific: line 24
Keep feature implementations in src/<feature>/index.ts with colocated index.spec.ts tests.
- Very specific: line 28
Keep the package framework-neutral, dependency-free at runtime, side-effect free on import, and compatible with package.json#sideEffects: …
- Distinctive: line 29
Keep every module isomorphic: the same code runs in browsers, workers, edge runtimes, and Node.
- Distinctive: line 30
Keep public entry modules independent.
- Very specific: line 36
Treat dist/ as generated output.
- Very specific: line 38
When a public entry point changes, update its source module, tsdown.config.ts, and the package.json export map together.
- Very specific: line 42
Keep scope and code separate from messages.
- Very specific: line 43
Put nested debugging context in metadata and flat telemetry values in attributes.
- Very specific: line 44
Treat constructor message, reason, hint, fix, and link as developer-facing.
- Very specific: line 45
Put client-approved prose under public, with a required nonblank public.message.
- Very specific: line 51
If no exact range exists, a case-sensitive curl/ in User-Agent selects ANSI.
- Distinctive: line 53
Treat scope, code, and status as disclosures.
- Very specific: line 54
Use statusCode for authored mappings and status only for a concrete response.
- Very specific: line 55
Keep request ID, metadata, attributes, cause, stack, developer name, and status out of ErrorResponseData and both serialized body formats.
- Very specific: line 57
Treat toJSON() as diagnostic serialization.
- Very specific: line 60
Keep cross-realm recognition as instanceof plus the namespaced symbol and data-shape validation.
- Very specific: line 63
Treat VercelErrorLike metadata and attributes as unknown until validated.
- Very specific: line 64
Keep create, raise, and report.
- Very specific: line 65
Keep onReport and onSerialize synchronous with undefined return types.
- Very specific: line 69
Keep auto, plain, tree, and ansi behind formatError.
- Very specific: line 70
Keep hint, fix, and link as structured FrameSection values.
- Distinctive: line 79
When public behavior, exports, field semantics, or examples change, update the README and every skill reference that states the changed …
- Distinctive: line 83
Document every public symbol beside its export using the language's native JSDoc.
- Distinctive: line 93
Keep implementation rationale in repository documentation or commit history rather than public JSDoc.
- Very specific: line 97
Use the Node and pnpm versions declared in package.json.
- Distinctive: line 99
Run the closest spec after a behavior change.
- Very specific: line 100
Run pnpm typecheck regularly.
- Distinctive: line 101
Test observable behavior through public interfaces.
- Very specific: line 102
Run pnpm validate, pnpm build, and pnpm verify:packed before completion.
- Very specific: line 107
Every push to main validates and attempts npm publication.
≈ “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.
Files
@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, andformat.tsare the designated public entry modules.src/vercel-error/owns authored error fields, mutability, the stable tag, Error subclass behavior, and diagnostictoJSON().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, andonSerializeordering.src/wants-ansi/implements the content negotiation it consumes.src/from-http-response/owns WebResponsestatus 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, andonReportordering.src/types.tsholds 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-errornever imports response data, either HTTP response module, the client entry, or the server entry.formatnever imports the class, response data, or either HTTP response module at runtime.error-response-datanever 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
Responseinterface 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
scopeandcodeseparate from messages. Either may be absent; defined values must be nonblank strings. Usetrim()only to check blankness; keep the original value. Keep the original failure incause. - Put nested debugging context in
metadataand flat telemetry values inattributes. Keep secrets out of both. - Treat constructor
message,reason,hint,fix, andlinkas developer-facing. - Put client-approved prose under
public, with a required nonblankpublic.message. - Validate
publicat construction. Require a nonblankmessageand strings for optional fields. Omit blanks, drop unknown fields, and freeze a copy. Keep nonblank text unchanged. errorResponse()builds client-safe output frompublictext or the fixed generic message. It rejects blankscopeorcodevalues when building a response.- Parsing rejects blank defined response identity and omits blank optional public details. Keep
isVercelError(),isVercelErrorLikeData(), andhasCode()as structural guards with their current contracts. X-Error-Formatwins when present. Only exactansiselects ANSI; other values select JSON.- Next, check exact
text/plain+ansiranges inAccept. They need supported parameters and validq > 0(default1). Duplicates use the highest validq. Exact ranges with no qualifying value select JSON and block the User-Agent fallback. - If no exact range exists, a case-sensitive
curl/inUser-Agentselects ANSI. Wildcards do not. - JSON uses
application/json; ANSI usestext/plain+ansi; charset=utf-8. AddVary: X-Error-Format, Accept, User-Agentfor either format whenevererrorResponse()receivesrequest; omit it when no request is supplied. - Treat scope, code, and status as disclosures. Protected-resource handlers own neutral identity and status mappings.
- Use
statusCodefor authored mappings andstatusonly 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
ErrorResponseDataand both serialized body formats. fromHttpResponse()readsx-vercel-idinto localrequestIdby 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
parseErrorResponseDataandfromErrorResponseData; reservefromHttpResponsefor native Web response consumption. - Keep cross-realm recognition as
instanceofplus the namespaced symbol and data-shape validation. The tag is forgeable. Useinstanceof VercelErrorwhen 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
ErrorResponseInputto put approved prose underpublic. Reject a top-level untaggedmessage. - Treat
VercelErrorLikemetadata and attributes as unknown until validated. Symbol-based recognition applies only while the tag remains observable; serialization channels useErrorResponseData. - Keep
create,raise, andreport. OnlyreportinvokesonReport;createandraisestay free of reporting side effects. WithoutonReport,reportwrites a sanitized terminal frame toconsole.error. - Keep
onReportandonSerializesynchronous withundefinedreturn types. Synchronous callback exceptions propagate.
Rendering Contract
- Keep
auto,plain,tree, andansibehindformatError. Onlyautoreads ambient terminal state. - Keep
hint,fix, andlinkas structuredFrameSectionvalues. 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 typecheckregularly. 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, andpnpm verify:packedbefore completion. - For skill changes, run
pnpm verify:skill; it must listvercel-errorand 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.
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.

