What makes a good spec
A spec is only useful if the AI follows it. Vague guidelines get ignored. Specific rules get followed. Bad spec:Spec structure
Put specs in.trellis/spec/. Organize by domain:
index.md in each folder is the entry point. Keep it focused - link to other files for details.
Writing rules that stick
Include file paths
Don’t say “the error utility”. Saysrc/lib/errors.ts. The AI can then read that file and understand the pattern.
Show real code
Copy actual code from your project. The AI learns patterns better from real examples than from descriptions.Be prescriptive
State what to do, not what’s possible. The AI needs direction, not options.Include anti-patterns
Show what NOT to do. This prevents common mistakes.Testing your specs
After writing a spec, test it:- Start a new Claude Code session
- Ask it to write code that the spec covers
- Check if it follows the spec
Common mistakes
Too abstract: “Follow clean code principles” - means nothing to the AI. Too long: A 2000-line spec won’t get read carefully. Keep specs focused. No examples: Rules without examples are hard to follow. Outdated references: If you referencesrc/utils/old.ts but that file was deleted, the spec becomes confusing.
Updating specs
Discovered a new pattern or learned something during development? Use/trellis:update-spec to have AI help you capture it in your specs.
Or when wrapping up with /trellis:finish-work, AI will ask if you have new knowledge to add to specs.
Don’t try to “tell” the AI about changes mid-session. Update the spec file. That’s the source of truth.
Next steps
Spec Templates
Download ready-to-use spec templates for common tech stacks.