LLM coding agents have no training data on green-tea, so they write Express. Every starter now ships an AGENTS.md, with a CLAUDE.md that imports it. It states the rules that differ: a graph, not a chain; needs declared in the signature; the graph validated at boot; reuse existing tokens. It also points the agent at matcha routes|tokens|explain --json and at the llms.txt inside the installed core. matcha agents writes the same files into an older project, with the core version that project actually depends on. It leaves existing files alone unless --force is given. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2.9 KiB
2.9 KiB
AGENTS.md — {{project_name}}
A green-tea app (@green-tea/core {{core_version}}), scaffolded by
matcha. Read this before editing.
green-tea is not Express
green-tea is new, so code that looks right from Express, Fastify or NestJS habits is usually wrong here.
- The request pipeline is a dependency graph, not a middleware chain. There is no
app.use, nonext(), and nothing mutatesreqorres. - A
@Providerbuilds a value once at boot. A@Stepcomputes a value per request. Each declaresprovidesandneeds, and green-tea derives the order from those declarations. - A handler declares what it needs in its signature:
@needs('user'),@param('id'),@body(),@query(),@cookie('name'). Return a value to answer: an object becomes JSON 200,undefinedbecomes 204. ThrowUnauthorized,NotFoundor anotherHttpErrorto fail the request. createAppvalidates the graph at boot. A token nothing provides, a token with two producers, or a node that needs what it provides all fail before the app serves anything.- Reuse what the graph already has. Before writing a new step, check whether a token you need, such as
user, already exists. Before writing@needs('x'), check that something providesx.
Look before you edit
Ask the app what it contains instead of guessing. These commands read src/app.ts without starting a
server or opening connections:
matcha routes --json # every route, its transport, and the chain it runs
matcha tokens --json # every token: who provides it, who needs it
matcha explain /some/:pattern --json # one route's chain, in execution order
matcha graph --format json # the whole graph
explain takes the route pattern as declared (/users/:id), not a URL.
Where things are
src/app.tsbuilds and exportsapp(createApp({ modules: [...] })). Introspection and tests import it.src/main.tsservesapp. It is the only file that differs per runtime.src/app.module.tslists the providers, steps and controllers with@Module.matcha create controller|step|provider|module <Name>generates a piece and wires it into the module.matcha add sse|ws|upload|stream|bufferadds a capability to a controller.
Check your work
- Type-check:
npx tsc --noEmit(Node, edge),deno check src/main.ts(Deno),bunx tsc --noEmit(Bun). - Test without a port:
await app.fetch(new Request('http://x/api/thing'))returns aResponse. matcha doctorfinds the misconfigurations that fail confusingly.
The full guide
The rules, decorators, built-in tokens and common mistakes for the installed version are in the package itself:
- npm / Bun:
node_modules/@green-tea/core/llms.txt - Deno (JSR):
https://jsr.io/@green-tea/core/{{core_version}}/llms.txt
The complete docs as one file: https://green-tea.expressive-tea.io/docs/llms-full.txt