DEV Community

Rlabs
Rlabs

Posted on

Stop prompting "write me an API" — teach the LLM the shape first

TL;DR

One-shot LLM code generation fails because it has no structural context.
Archetypes are a YAML contract that fixes that. I'll walk through one
end-to-end.

The "90% right, 10% wrong in load-bearing places" problem

[2-3 párrafos con ejemplos reales: layer leakage, mocked tests,
error paths que pierden contexto en el stack trace]

What a structural archetype is

An archetype is a declarative contract describing:

  • Top-level directory layout
  • Component boundaries (and what crosses them)
  • Contracts between components
  • Validation gates that must pass post-generation
  • A self-challenge spec the agent runs against its own output

[Snippet real de un archetype: hexagonal-api.yaml, ~20 líneas]

Walkthrough: hexagonal-api

1. The agent reads the archetype

[Código: claude-code con MCP server configurado, invocando el archetype]

2. Generation pass

[Output esperado: árbol de archivos generado]

3. Self-challenge

The agent re-reads the archetype and scores its own output against
the contract. When it drifts (e.g., puts persistence concerns in the
domain layer) it fails the gate and iterates.

[Ejemplo: el self-challenge detecta una violación y la corrige]

4. Running the tests

[pytest output, green]

When this doesn't fit

Be honest about limits:

  • Greenfield > existing codebases (for now)
  • The archetype has to match your stack shape, not just language
  • Contracts that change frequently drift from the archetype — treat the archetype as the "starting chassis", not the spec of record

Other archetypes in the catalog

Short list of 5-6 with one-line use cases. Link to marketplace.

Building your own archetype

Quick pointer: the schema is documented at /docs/archetype-schema.
Anyone can publish one — sellers set their own price and can offer
seller-funded cashback.

Why I charge for this

[Párrafo honesto: pago infra, estoy invertido, precio bajo deliberado]


Author note: I'm running launch-week cashback on the 61 archetypes
I authored — code SURPRISE_DEVTO returns ~50% of the price as wallet
credit. It's funded from my royalty (not the platform's), 250 uses,
expires June 18. Feedback about which archetypes are missing is the
real currency I'm after.

Top comments (0)