agentleFS
useinviouseinvio/nfse-sdk/AGENTS.md

nfse-sdk

AGENTS.md4 starsChanged 20 days agoMITView on GitHub

Guidance for AI coding agents working on this repository. To use the SDK from another project, read llms.txt instead. @useinvio/nfse-sdk is the protocol layer for Brazil's NFS-e Nacional: DPS and event XML, official XSD validation (libxml2 in WebAssembly), XMLDSIG, GZip/Base64, mTLS to SEFIN and ADN, typed results and errors. It must not become a tax engine: never add fiscal defaults or choose codes for the user. All tests run offline: the SEFIN transport is mocked (testing.ts and test/httpsMock.ts). - Fiscal…

  • Installs packages
  • 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,196 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

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

7 rules. About 1 is common, 0 are distinctive, and 6 are very specific to this project.

  • ≈1

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    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:

    All tests run offline: the SEFIN transport is mocked (testing.ts and test/httpsMock.ts).

    line 23
  2. Very specific:

    Fiscal neutrality: No silent defaults for tributacaoMunicipal, totTrib, cTribNac or regime.

    line 52
  3. Common:

    Never log, serialize or return key material, PFX bytes or passwords.

    line 55
  4. Very specific:

    Network: Only sefinClient.ts talks to the network.

    line 56
  5. Very specific:

    Public API: Keep names exported by index.ts stable.

    line 63
  6. Very specific:

    Never edit the generated file by hand, and keep the official text verbatim.

    line 79
  7. Very specific:

    After regenerating, run npm run build:rejection-pages to refresh docs/rejeicoes/.

    line 80

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

AGENTS.md

Guidance for AI coding agents working on this repository. To use the SDK from another project, read llms.txt instead.

What this is

@useinvio/nfse-sdk is the protocol layer for Brazil's NFS-e Nacional: DPS and event XML, official XSD validation (libxml2 in WebAssembly), XMLDSIG, GZip/Base64, mTLS to SEFIN and ADN, typed results and errors. It must not become a tax engine: never add fiscal defaults or choose codes for the user.

Commands

npm install
npm run typecheck            # library
npm run typecheck:examples   # examples/*.ts against the source
npm test                     # build + all tests (node:test), including the MCP stdio interop test
npm pack --dry-run           # what gets published

All tests run offline: the SEFIN transport is mocked (testing.ts and test/httpsMock.ts).

Layout

PathRole
index.tsPublic API. Everything exported here is supported.
client.tsNfseClient facade over the functions below.
dpsJson.ts, fiscalValidation.ts, dpsJsonSchema.ts, fiscalDomains.tsJSON input, validation, JSON Schema, DPS XML builder.
emissaoNota.tsEmission flow: prepare (XSD, validity, sign, verify) and transmit.
eventoJson.ts, eventosNfse.tsCancellation events: builders and send flow.
consultas.ts, nfseXml.tsTyped query, recovery by DPS id, NFS-e XML reader.
sefinClient.tsThe only module that does network I/O: endpoints, timeouts, GET retries, path validation, metrics, test transport seam.
certificate.ts, certificateValidation.ts, loadPfx.tsNfseCertificate and certificate checks.
xsdValidation.ts, xmlInspection.ts, signXml.ts, xmlBuild.ts, gzipB64.tsXML, XSD and crypto helpers.
rejeicoes.ts, rejeicoesCatalog.tsOfficial rejection catalog. The catalog is generated; see below.
agent.tsFramework-neutral agent tools and the prepare/confirm toolkit.
mcpServer.ts, mcpCli.tsDependency-free MCP stdio server and its CLI.
testing.tsPublic test helpers: createTestCertificate, installMockSefin.
cli.ts, cliBin.ts, cliExample.tsThe nfse command line and its sample payload.
playground/Browser playground. Edit playground/src/; npm run build:playground writes playground/index.html; pages.yml deploys it to GitHub Pages on push to main.
docs/rejeicoes/One page per rejection code, generated by npm run build:rejection-pages. Never edit by hand.
mcp/The @useinvio/nfse-mcp wrapper package (a bin that calls mcpServer.ts).
plugin/, .claude-plugin/marketplace.jsonClaude Code plugin (skill + MCP server) and its marketplace.
docs/pt-BR docs: tutoriais/, guias/, referencia/, conceitos/.
schemas/Official XSD v1.01. Never edit these files.

Rules

  • Fiscal neutrality. No silent defaults for tributacaoMunicipal, totTrib, cTribNac or regime. Reject unsupported shapes instead of guessing.
  • Certificates. Accept CertificateInput and go through resolveCredentials. Never log, serialize or return key material, PFX bytes or passwords.
  • Network. Only sefinClient.ts talks to the network. POSTs are never retried. Validate every URL path parameter before the request.
  • XML order follows the XSD; tests compare snippets. Every generated XML must pass validateDpsXmlAgainstXsd or validatePedRegEventoXmlAgainstXsd.
  • Agent tools. Certificate and environment come from NfseAgentContext, never from tool input. Anything that sends to SEFIN must be a confirm_* tool behind a prepare_* step and allowWrite.
  • Public API. Keep names exported by index.ts stable. A new export needs a test, an entry in docs/referencia/api.md and, when relevant, llms.txt.
  • Docs. README stays short; details go to docs/. test/documentation.test.ts checks snippet payloads against the XSD, imported names and every relative link.

Rejection catalog

rejeicoesCatalog.ts is generated from the official gov.br annexes. To update it, download the current anexo_i-...xlsx and anexo_ii-...xlsx from https://www.gov.br/nfse/pt-br/biblioteca/documentacao-tecnica/documentacao-atual and run:

node scripts/build-rejection-catalog.mjs "anexo_i.xlsx|Anexo I ... v1.01 (09/02/2026)|<url>" "anexo_ii.xlsx|Anexo II ... v1.01 (22/01/2026)|<url>"

Never edit the generated file by hand, and keep the official text verbatim. After regenerating, run npm run build:rejection-pages to refresh docs/rejeicoes/.

Releases

The SDK publishes from publish.yml on a tag matching package.json. The MCP wrapper in mcp/ depends on the SDK version that contains mcpServer.ts, so publish the SDK first, then mcp/ (npm publish from that folder), then update mcp/server.json in the MCP Registry.

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.