The 8-Step AI Development Loop
Write the docs before you write the code: decide the design system, the features, the screens, the architecture and the rules — then let an AI assistant build the app one feature at a time.
The 8-step AI development loop
Write the docs before you write the code. First decide on your design system, features, screens, architecture, and rules. Then let your AI assistant build the app based on those decisions, one feature at a time. Each step below is collapsible — open one to see its full prompt.
01. Design Tokens + PRD — Turn your product requirements into a color, font, and spacing system — before designing any screens.
Give your product requirements doc (PRD) to an AI design tool and ask it to create a design system: colors, fonts, spacing, and corner radius — saved as CSS variables or JSON. Save these files under docs/design_systems/tokens/. Later, these same values feed into Flutter’s ThemeExtension, so you never type a color or spacing value directly into a screen.
Improvement: also ask for simple usage rules at the same time — for example, when to use which color, or how much space to leave between elements. Adding this later takes more work than asking for it now.
Prompt 1 — Design Tokens + PRD
We are building a production-grade Flutter application. Here is our PRD:
[Paste PRD here]
Based on this PRD, create a tokenized design system. Include:
1. Color palette (primary, secondary, semantic accents, neutrals, surfaces).
2. Typographic scale (sizes, line heights, weights).
3. Spacing grid, radius scale, shadow scale, and motion/easing tokens.
4. A short usage-rules note per category.
Output as CSS custom properties (or a token JSON) plus a one-page rationale.
Do not write Dart code yet.
02. Feature Breakdown — Split the PRD into a numbered list of features, one file per feature, plus an index.
Ask the AI to read the PRD and split it into a numbered list of features. Create one file per feature in docs/features/, plus an index.md that lists them all. Each file should describe what the feature does, what data it needs, and which other features it depends on.
Improvement: do this before designing any screens, not at the same time. This gives you clear feature names to use later — so in Step 7 you can just say “build the onboarding flow” and it’s obvious what that means.
Prompt 2 — Feature Spec Breakdown
Here is our PRD: [reference or paste it].
Break it into a numbered list of feature areas. For each feature, produce a
spec file containing:
1. User stories / jobs-to-be-done.
2. Data entities and screens touched.
3. Dependencies on other features (call out cross-feature imports).
4. Safety, security, or regulatory constraints specific to this feature.
Also produce an index.md listing every feature file.
03. Screen Generation — List every screen and its different states (loading, empty, error, offline), tracked in docs/screen_flow.md.
Design each screen one feature at a time. For every screen, think through what it looks like when it’s loading, empty, showing an error, or the device is offline. Keep a running list of every screen in docs/screen_flow.md.
Improvement: from the start, also keep one master list of every screen (its ID, what it’s made of, and which feature it belongs to), plus a separate file for things shared across all screens — like the offline banner, loading skeletons, and the generic error message. Building these early saves you from redoing the same work screen by screen later.
Prompt 3 — Feature-by-Feature Screens
Using our design tokens and the feature spec for [Feature Name], generate
the screen layout guidelines. Include:
1. Every state per screen: loaded, loading/skeleton, empty, error, offline.
2. A screen ID for each screen (e.g., ONB-01, SET-02).
Add each new screen ID to docs/screen_flow.md. Do not write Flutter widgets yet.
04. Architecture Docs — Write down your database structure, how data flows over the network, and what’s the final source of truth, in docs/architecture.md.
Describe your database tables, how the app talks to the server, and how caching works. For anything the app calculates rather than just stores, write down which side — the app or the server — has the final say, in docs/architecture.md.
Improvement: if you notice the design and the PRD don’t agree on something, write it down instead of quietly picking one in the code. That way, anyone looking at this later — including future you — knows a decision was made, and why.
Prompt 4 — Technical Architecture
Based on the PRD and the feature specs, write the technical architecture docs
for this Flutter app:
1. architecture.md — tech stack, folder structure (Clean Architecture per
feature), state management, local database schema, networking strategy,
error handling, testing strategy, Definition of Done.
2. A data-flow doc — local schema, remote schema, sync direction, and source
of truth rules.
3. Explicitly note anywhere this doc supersedes or conflicts with the PRD.
05. CLAUDE.md Rules — Write the non-negotiable rules — how features stay separate, how state is managed, how caching/theming work.
Update CLAUDE.md with clear rules: what a feature is and isn’t allowed to touch, which state-management approach to use, how caching should work, and how much test coverage is expected.
Improvement: link to the docs from Step 4 instead of copying them — CLAUDE.md should point to the rules, not repeat them. Keep updating it: every time you add a skill in Step 6, or find a problem in Step 8, write the fix here too.
Prompt 5 — Rules Index (CLAUDE.md)
Based on architecture.md and the data-flow doc, generate CLAUDE.md for this
repository:
1. Feature-boundary rules (what a feature may/may not import).
2. State management constraints (Riverpod code-gen rules, no inline widget
logic).
3. Data caching rules (local-first vs remote-first).
4. Theme rules (no hardcoded color/spacing/typography).
5. Lint/test gates.
Link out to the docs rather than duplicating their content.
06. Equip AI Skills — Turn repeatable checks (architecture rules, design tokens, layout tests) into skills your AI assistant can reuse.
Give your AI assistant reusable checklists, saved as skills in .claude/skills/. For example: a checklist for scaffolding a new feature correctly, a check for hardcoded design values, or a check for layout/overflow bugs.
Improvement: add skills for feature scaffolding, data syncing, and state management at the same time as your first audit/testing skills — not one by one, only after you notice you’re repeating the same instructions every session.
Prompt 6 — Equip Skills
Create a Claude Code skill at .claude/skills/[skill-name]/SKILL.md for:
[Choose: clean architecture auditing | design-token compliance | responsive
layout audits | test generation | feature scaffolding | data-sync wiring].
The skill should act as a checklist for the AI to verify before finishing
feature work, with concrete trigger phrases for when it should auto-fire.
Then add one line to CLAUDE.md's skills section pointing to it.
07. Flow-by-Flow Build — Build one full feature at a time, in this order: data model → repository → business logic → state → screen.
Build one full feature flow at a time (like onboarding or settings), instead of one screen at a time. Write the code in this order: data model → repository → business logic (use case) → state management (Riverpod) → the screen itself.
Improvement: run the audit and layout-check skills from Step 6 right after finishing each feature, not later in a separate pass. Catching a mistake immediately is much cheaper than finding it several features later.
Prompt 7 — Flow-by-Flow Implementation
We are ready to implement the [Feature Name] flow (screens: [screen IDs],
flow doc: docs/screen_flow.md).
Generate the code in this exact order:
1. Domain entity + Repository interface contract.
2. Domain use case (encodes business rules).
3. Riverpod controller/notifier.
4. Presentation widgets using ThemeExtension design tokens.
When finished, run the responsiveness and boundary audit skills against
this flow before moving to the next one.
08. Knowledge Graph Audit — Use a tool like graphify to scan the whole codebase for problems, then update CLAUDE.md with what you find.
Run a code-scanning tool (like graphify) to find circular imports, features that break the rules, or code that’s missing a proper structure. Fix what you find, and update CLAUDE.md so the same mistake doesn’t happen again.
Improvement: don’t just run this once at the end — run it again every few features from Step 7, and feed anything you find back into Step 5. Also keep a simple written log of decisions alongside this. The scan tells you how the code is connected; the decision log tells you why things were built that way. A long project needs both.
Prompt 8 — Knowledge Graph Audit
/graphify
Build/refresh the knowledge graph for this workspace. Then report:
1. Any import that crosses a feature boundary CLAUDE.md prohibits.
2. Circular dependencies or orphaned modules.
3. Community hubs large enough to suggest a missing abstraction.
Feed anything found back as a fix task, and flag any rule it exposes that
CLAUDE.md doesn't document yet.
This isn't a one-way list — it's a loop. Whatever Step 8's scan finds should turn into a new rule in CLAUDE.md, not just a quick, one-time fix.
One more doc worth knowing about: docs/local_storage.md explains where the local database is set up, which files are responsible for which part of it, and what to change if you ever want to use a different local storage tool instead of Drift.