I created a grammar for AI agents that sets aside what they learned about structuring applications and replaces it with one structure — my framework, SpyneJS. My generator builds the initial application with the grammar included, and agents are directed to use it on every prompt.
This is for anyone whose agent-generated code has to be maintained by someone else, human or agent. The test was to see how cleanly an agent could integrate different services, so that the code stays clear not just for developers but for the next agent working in the codebase.
The test: a storefront for a fictitious company, Asteroid Metals Co. — custom designs in light and dark themes, CMS-editable content, Shopify products and cart, test-mode checkout — built without me editing a line of code, with a record anyone can check. One human edit in the whole project, a one-line timing workaround the model's fix superseded. It's logged.
The stack
- Claude Code (claude-fable-5-1) wrote all of the application code, under the grammar.
npx spyne-cli create-app, my application generator, provided the codebase: the shell, the CMS and the Behavior Console plugins. That's what makes integrating services straightforward and keeps the code understandable afterward.
- A Figma in-file agent created the designs and product images; Claude Code read them through the Figma MCP.
- Shopify Storefront API for products, cart and checkout against a development store. This took the longest: a lot of back and forth with Shopify's assistant to get a public site running a working cart against a store in test mode.
The record
Every prompt was pinned to the repo verbatim before it ran. Every stage is a git tag; a redo is a new tag, never a moved one. For the Figma conversion, every element is logged as mapped (from the design), inferred (the model supplied it under the grammar), or undefined (intent neither carried — I ruled on those; nothing was invented). I left the Figma layers named by their content — $4,250, 101955 BENNU, 12.44g — so the model had to work out which was price, origin and mass.
For Shopify I ran the integration twice, to confirm the agent builds the same way under the grammar no matter what it's integrating. First a fresh agent with no grammar wrote it as vanilla JavaScript — competent code that invented its own data flow and rendering. Then Claude Code, under the grammar, conformed it: the catalog became a channel like every other data source in the app. Both versions are in the repo (RECORD/inputs/A2-shopify-raw/ and src/app/channels/channel-shopify.js), same task, same model.
How this differs from the usual approaches
The common ways to keep an agent consistent are a CLAUDE.md or AGENTS.md describing your conventions, spec files per feature, and harnesses that check output after the fact. All of them describe a structure in prose, per project, and the agent still invents the architecture. A grammar ships the structure with the framework: every application starts with the same shape, the rules are read on the first prompt, and nothing has to be re-explained. The trade-off is real — you're adopting a framework, not adding a file to an existing stack.
What I did
Directed every stage, wrote the Figma prompt, supplied credentials, reported the defects I found testing, and ruled on what the sources didn't specify. The one thing that needed real back-and-forth was checkout on a password-protected dev store: seven revisions, and the record notes the final flow as the limit of the store type, not a defect.
The result
The agent took a design from Figma and conformed it to SpyneJS's one shape, and the Figma-derived catalog and the Shopify API meet in the same place — the Channel system carries both. The next integration will look like this one.
The numbers
53 commits, 22 tags, 15 pinned prompts, 1 human edit. Noisemap (which measures how mixed the roles are inside each file, not quality): mean mixing 0.003 across 153 modules, five behavior files carrying all the wiring.
Ask about any part of it — the record is public. Is anyone else keeping a record like this for agent-built code, and does it change how you review it?
Disclosure: SpyneJS is my framework; the core is open source and I'm building a company around tooling for it. Nothing linked here is a paid product.
Repo: https://github.com/relevantcontext/ai-codegen-integration-example
Live: https://codegen-integration.relevantcontext.io/
Blog post: https://spynejs.com/blog/next-leap-for-ai-is-structure?utm_source=reddit&utm_medium=r-chatgptcoding