Quick Start: Build with Spectral

Start from an idea and ship working code with Spectral's AI-powered chat, semantic validation, and multi-language code generation.

Install the Spectral CLI

Pick the install method that fits your environment:

NPM (recommended)

npm install -g @aexol/spectral

Deno

deno install --allow-read --allow-write --allow-net -n spectral https://deno.land/x/spectral/main.ts

Verify

spectral --version

1. Design interactively with spectral chat

Bring up an interactive AI partner that can read and write files, run Spectral commands, and iterate on ideas with you.

spectral chat

What to expect:

  • Choose an AI model (Claude, GPT-5, or local CLI tools)
  • Ask questions like “Draft a todo workflow” or “Refine this spec”
  • Let the agent call tools such as read_file, write_file, and spectral_generate while you supervise the changes

Use --model to pin a specific provider:

spectral chat --model claude-sonnet-4-5-20250929
spectral chat --model codex-cli

2. Validate your specification with spectral validate

Check your Spectral files for syntax and semantic errors before generating code.

spectral validate todo.spectral
spectral validate todo.spectral --verbose

Spectral validates:

  • Type consistency and role definitions
  • Workflow state transitions and guards
  • Agent capabilities and permissions
  • Visitor hierarchies and access patterns

3. Analyze complexity with spectral analyze

Get detailed insights into your specification's structure and complexity.

spectral analyze todo.spectral
spectral analyze ecommerce.spectral --verbose

Highlights:

  • Complexity metrics for visitors, workflows, and agents
  • Recommendations for refactoring
  • Dependency analysis and structural insights

4. Generate production code with spectral generate

Transform your validated specification into production-ready code in multiple languages.

spectral generate todo.spectral -l typescript -o ./src
spectral generate api.spectral -l python -o ./app
spectral generate service.spectral -l rust -o ./services
  • Supports TypeScript, Python, Rust, Go, and JavaScript out of the box
  • Generates type-safe code with proper error handling
  • Creates documentation alongside implementation

5. AI-assisted implementation with spectral implement

Let AI agents implement your specification with guided assistance.

spectral implement todo.spectral --agent copilot
spectral implement api.spectral --agent codex-cli --language python

How it works:

  • Generates project structure with TODO markers
  • Launches your chosen AI agent (Copilot CLI, Codex CLI)
  • Implements each method interactively with AI guidance

Next steps for deeper dives

Documentation for Spectral developers

Stay connected


You now have the full workflow: chat to explore ideas, validate specifications, analyze complexity, generate code, and implement with AI assistance.