freshcrate
Home > Developer Tools > coherent-design-method

coherent-design-method

AI-powered design system generator โ€” once designed, consistent UI everywhere.

Description

AI-powered design system generator โ€” once designed, consistent UI everywhere.

README

Coherent Design Method

AI-powered design system generator.
Describe what you need โ€” get interconnected pages with shared components, design tokens, and auto-generated documentation.

npm version MIT License Node 20+ Next.js 15


What is Coherent?

Most AI tools generate pages. Coherent generates systems.

When you ask for five pages, every page shares the same header, footer, color palette, spacing, and component library. Change the primary color once โ€” all pages update. Add a component once โ€” reuse it everywhere by ID. The design system documentation writes itself.

Coherent is a CLI that creates production-ready Next.js projects with a built-in design system. You describe what you want in plain English, and Coherent generates real code โ€” not wireframes, not mockups, but working pages with real components, real data patterns, and a live Design System viewer at /design-system.

Quick Start

Prerequisites: Node.js 20 or later.

1. Install

npm install -g @getcoherent/cli
Or install from source
git clone https://github.com/skovtun/coherent-design-method.git
cd coherent-design-method
pnpm install && pnpm build
cd packages/cli && pnpm link --global

2. Create a project

coherent init my-app
cd my-app

This creates a Next.js 15 project with Tailwind CSS, a component library, design tokens, and a Design System viewer โ€” all pre-configured. During init, you'll be asked for an Anthropic API key (needed for AI generation).

3. Generate pages

coherent chat "create a SaaS landing page with pricing, about us, and contact pages"

Coherent plans all pages, generates the home page first (establishing the visual style), then generates remaining pages with the same components, spacing, and color palette.

4. Preview

coherent preview

Opens your app at http://localhost:3000. The Design System viewer is at http://localhost:3000/design-system.

5. Iterate

coherent chat "change primary color to indigo and make buttons more rounded"
coherent chat "add a dashboard page with stats and recent activity"
coherent chat "update the pricing page: add a fourth enterprise tier"

Every change respects the existing design system. New pages inherit shared components. Token changes cascade everywhere.

How It Works

When you request multiple pages, Coherent uses a 4-phase architecture to ensure visual consistency:

Phase 1: Plan           โ†’  AI plans all pages (names, routes, descriptions)
Phase 2: Generate Home  โ†’  AI generates the home page with header, footer, full styling
Phase 3: Extract        โ†’  Local processing: extracts header/footer as shared components,
                           captures style patterns (cards, spacing, colors, typography)
Phase 4: Generate Rest  โ†’  AI generates remaining pages with extracted style context
                           injected into each prompt โ€” ensuring visual consistency

Phase 3 extracts style patterns from the home page and injects them as concrete CSS classes into subsequent page prompts โ€” ensuring every page uses the same card styles, spacing, typography, and color patterns.

CLI Commands

Command Description
coherent init Create a new Coherent project with Next.js, Tailwind, and design system
coherent chat "<message>" Generate or modify pages using natural language
coherent preview Start the dev server with auto-fix and file watching
coherent check Show all problems: page quality, component integrity, broken links
coherent fix Auto-fix everything: cache, dependencies, components, syntax, quality
coherent sync Sync Design System with code after manual edits in your editor
coherent export Export a clean, deployable Next.js project (strips DS overlay)
coherent undo Restore project to state before the last coherent chat
coherent rules Regenerate .cursorrules and CLAUDE.md (AI editor context)
coherent update Apply platform updates to an existing project
coherent status Show current project status
coherent components list List all shared and UI components
coherent chat -i Interactive chat mode (REPL)

Examples

# Generate a complete multi-page app
coherent chat "create an e-commerce site with product catalog, cart, checkout, and account pages"

# Modify design tokens
coherent chat "change primary color to #6366f1 and use Inter font"

# Target a specific component
coherent chat --component "Header" "add a search button"

# Target a specific page
coherent chat --page "pricing" "add a fourth enterprise tier"

# Target a design token
coherent chat --token "primary" "change to indigo"

# Interactive mode
coherent chat -i

# After editing code manually in Cursor/VS Code
coherent sync

# Export for deployment
coherent export

Two Workflows

Coherent supports two ways of working. Use whichever fits your task โ€” or combine them.

CLI (fast scaffolding)

Run commands in your terminal. Each command goes through the full pipeline: AI generation, component reuse, validation, and auto-fix.

coherent chat "add a dashboard with revenue stats and user growth chart"
coherent chat "add a settings page with profile form and notification preferences"
coherent preview

Best for: creating pages, changing tokens, batch operations, quick prototyping.

Editor (fine-grained control)

Edit code directly in Cursor, VS Code, or any editor. Coherent provides AI context via .cursorrules and CLAUDE.md โ€” your editor's AI knows about your shared components, design tokens, and quality rules.

After manual edits, run coherent sync to update the Design System:

# Edit files in your editor...
coherent sync      # updates Design System to match your code
coherent check     # verify everything is consistent

Best for: custom components, complex logic, pixel-perfect styling, detailed work.

Recommended workflow

# 1. Scaffold with CLI
coherent chat "add e-commerce: products, cart, checkout"

# 2. Fix any generation issues
coherent fix

# 3. Preview
coherent preview

# 4. Polish in your editor
#    - Customize ProductCard component
#    - Add business logic
#    - Fine-tune responsive styles

# 5. Sync and commit
coherent sync
git commit -m "Product catalog complete"

# 6. Continue building
coherent chat "add admin panel with order management"

What Coherent Creates

When you run coherent init followed by coherent chat, your project gets this structure:

my-app/
โ”œโ”€โ”€ app/
โ”‚   โ”œโ”€โ”€ layout.tsx                  # Root layout with shared header/footer
โ”‚   โ”œโ”€โ”€ page.tsx                    # Home page
โ”‚   โ”œโ”€โ”€ about/page.tsx              # Generated pages...
โ”‚   โ”œโ”€โ”€ pricing/page.tsx
โ”‚   โ”œโ”€โ”€ AppNav.tsx                  # Platform navigation + Design System button
โ”‚   โ”œโ”€โ”€ ShowWhenNotAuthRoute.tsx     # Route-based component visibility
โ”‚   โ””โ”€โ”€ design-system/             # Design System viewer (auto-generated)
โ”‚       โ”œโ”€โ”€ page.tsx                #   Overview
โ”‚       โ”œโ”€โ”€ components/page.tsx     #   Component library
โ”‚       โ”œโ”€โ”€ shared/page.tsx         #   Shared components (CID-xxx)
โ”‚       โ”œโ”€โ”€ tokens/page.tsx         #   Design tokens
โ”‚       โ”œโ”€โ”€ sitemap/page.tsx        #   Page architecture
โ”‚       โ””โ”€โ”€ docs/                   #   Documentation & recommendations
โ”œโ”€โ”€ components/
โ”‚   โ”œโ”€โ”€ ui/                        # shadcn/ui components (Button, Card, Input...)
โ”‚   โ””โ”€โ”€ *.tsx                      # Custom components (auto-detected by sync)
โ”œโ”€โ”€ design-system.config.ts         # Single source of truth for the design system
โ”œโ”€โ”€ coherent.components.json        # Shared component manifest (CID registry)
โ”œโ”€โ”€ .cursorrules                    # AI context for Cursor
โ”œโ”€โ”€ CLAUDE.md                      # AI context for Claude Code
โ””โ”€โ”€ globals.css                    # Tailwind CSS with design tokens

Key files

design-system.config.ts โ€” The single source of truth. Contains all pages, components, design tokens (colors, typography, spacing), and page metadata. Every Coherent command reads from and writes to this file.

coherent.components.json โ€” The shared component registry. Each component gets a unique ID (CID-001, CID-002...) and tracks where it's used. This enables component reuse across pages and powers the Design System viewer.

.cursorrules / CLAUDE.md โ€” AI context files that tell your editor's AI about your design system. Automatically regenerated when you run coherent sync or coherent rules.

AI Provider Setup

Coherent uses Claude (by Anthropic) for AI-powered code generation. You need an API key for the coherent chat command.

Step 1: Get an API key

  1. Go to console.anthropic.com
  2. Sign up or log in
  3. Navigate to API Keys in your account settings
  4. Click Create Key and copy it

Step 2: Configure the key

During coherent init, you'll be prompted to enter your key. It's saved to .env in your project directory (already in .gitignore).

To set it manually:

# In your project directory
echo "ANTHROPIC_API_KEY=sk-ant-..." > .env

Or export it in your shell:

export ANTHROPIC_API_KEY=sk-ant-...

Model configuration

Coherent uses the latest Claude Sonnet model by default. To override:

export CLAUDE_MODEL=claude-sonnet-4-20250514   # or any Claude model

Security

  • Your API key is stored locally in .env (never committed to git)
  • Coherent sends your design instructions to the Claude API and receives generated code
  • No data is stored on Coherent's servers โ€” there are no Coherent servers
  • Each user needs their own API key

If you accidentally expose a key, revoke it immediately at console.anthropic.com/settings/keys and create a new one.

Design System Viewer

Every Coherent project includes a live Design System viewer at /design-system. It shows:

  • Overview โ€” Project summary, page count, component count
  • Components โ€” All UI components with variants, sizes, and code examples
  • Shared Components โ€” Reusable layout/section components with CID tracking
  • Tokens โ€” Color palette, typography scale, spacing, border radius
  • Sitemap โ€” Visual map of all pages and their connections
  • Documentation โ€” Auto-generated docs and UX recommendations

The viewer updates automatically when you add pages or run coherent sync.

Quality System

Coherent validates generated code against 97 design rules covering typography, spacing, accessibility, and color usage.

coherent check (read-only diagnostics)

coherent check

Reports:

  • Raw Tailwind colors (should use semantic tokens like bg-primary)
  • Missing accessibility labels
  • Heading hierarchy issues
  • Native HTML elements (should use design system components)
  • Broken internal links
  • Orphaned or unused shared components

coherent fix (auto-repair)

coherent fix

A unified self-healing command that fixes most issues in one run:

  • TypeScript errors โ€” two-pass auto-fix: deterministic fixers handle field name mismatches, union type casing, and missing event handlers; AI fallback fixes remaining errors when an API key is configured
  • Missing components โ€” auto-installs shadcn/ui components referenced in code
  • Raw colors โ†’ semantic tokens (bg-blue-500 โ†’ bg-primary)
  • CSS variables โ€” syncs globals.css with design tokens
  • Route group layouts โ€” verifies public/app/auth layout structure
  • Build cache โ€” clears stale .next artifacts
  • Component manifest โ€” removes stale entries, adds missing ones

Run coherent fix after coherent chat to catch and repair any generation issues. Most TypeScript and quality problems are fixed automatically โ€” no manual intervention needed.

coherent sync (reverse sync)

After editing code manually in your editor, run coherent sync to update the Design System:

coherent sync              # full sync
coherent sync --tokens     # only CSS variables
coherent sync --components # only component detection
coherent sync --patterns   # only style patterns
coherent sync --dry-run    # preview changes without writing

This extracts CSS variables, detects new custom components, captures style patterns, updates page metadata, and regenerates the Design System viewer.

Development from Source

Prerequisites

  • Node.js 20+
  • pnpm 8+

Setup

git clone https://github.com/skovtun/coherent-design-method.git
cd coherent-design-method

# Install all dependencies
pnpm install

# Build packages (core first, then CLI)
pnpm build

# Link CLI globally so you can use `coherent` command
cd packages/cli
pnpm link --global

# Verify installation
coherent --version

Project structure

coherent-design-method/
โ”œโ”€โ”€ packages/
โ”‚   โ”œโ”€โ”€ core/       # @getcoherent/core โ€” design system engine, generators, managers
โ”‚   โ”œโ”€โ”€ cli/        # @getcoherent/cli  โ€” CLI commands, AI providers, quality tools
โ”‚   โ””โ”€โ”€ templates/  # Project templates
โ”œโ”€โ”€ docs/           # Documentation
โ””โ”€โ”€ package.json    # Monorepo root (pnpm workspaces)

Development workflow

# Watch mode for core package
cd packages/core && pnpm dev

# Watch mode for CLI package (in another terminal)
cd packages/cli && pnpm dev

# After changes, rebuild
pnpm build   # from monorepo root

Troubleshooting

"Not a Coherent project"

You're running a command outside a Coherent project directory. Make sure you're in a directory with design-system.config.ts:

cd my-app          # your project directory
coherent preview   # now it works

"No API key found"

You need an Anthropic API key for coherent chat. See AI Provider Setup.

Build errors after generation

Run the auto-fixer:

coherent fix

This resolves most issues โ€” TypeScript type errors, missing imports, component conflicts, and CSS problems. coherent fix uses deterministic fixers for common patterns and AI fallback for the rest. If issues persist, check the full troubleshooting guide.

Pages look inconsistent

If pages were generated one-by-one (not in a batch), they may not share styles. Fix this:

coherent sync    # extracts style patterns from existing pages

Then generate new pages โ€” they'll match the extracted patterns.

"Module not found" for components

Coherent auto-installs missing shadcn components. If one is missing:

coherent fix     # auto-installs missing components

For the full list of known issues and solutions, see TROUBLESHOOTING.md.

Contributing

We welcome contributions! See CONTRIBUTING.md for:

  • Development setup instructions
  • How to make changes to core vs CLI
  • Testing your changes locally
  • Commit message conventions
  • Pull request process

License

MIT โ€” Sergei Kovtun


LinkedIn ยท GitHub ยท Website

Release History

VersionChangesUrgencyDate
v0.7.15## Highlights - **Compact `coherent fix` report** โ€” groups by issue type, hides info-level behind `--verbose`. Typical output: 80+ โ†’ ~20 lines. - **DSButton** (0.7.12) + nav cleanup (0.7.9/0.7.10/0.7.11) + help cleanup (0.7.13) โ€” session-wide polish. - **New autofixers:** DIALOG_FULL_WIDTH, SMALL_TOUCH_TARGET, MISSING_ARIA_LABEL, DOUBLE_SIGN, RAW_NUMBER_FORMAT, RAW_IMG_TAG, BROKEN_INTERNAL_LINK. ## Demo See attached \`Coherent Design Method DEMO.mp4\`. ## Install \`\`\`bash npm install -g @High4/20/2026
main@2026-04-19Latest activity on main branchHigh4/19/2026
0.0.0No release found โ€” using repo HEADHigh4/8/2026

Dependencies & License Audit

Loading dependencies...

Similar Packages

terminal-mcp๐Ÿ–ฅ๏ธ Enhance your terminal interactions by allowing AI to see and control your session for real-time debugging and automation.main@2026-04-21
ossatureAn open-source harness for spec-driven code generation.master@2026-04-18
System-Constitution๐Ÿš€ Define your architecture with System Constitution to keep your AI coding agents in check, ensuring stability and compliance as your project evolves.main@2026-04-16
aiagentflowA local-first, CLI-driven multi-agent AI software engineering workflow orchestrator with feed specs, PRDs, and guidelines to auto-generate implementation plans and code.v1.0.2
AGENTS.md_generator๐Ÿค– Generate secure, automated repo documentation and pull request checks with a safe-by-default toolchain for coding agents.main@2026-04-21