Skip to main content

Spec-as-Source Framework: AI-driven development where specifications are the source of truth.

Project description

Specular

Specular is a "Spec-as-Source" AI coding framework. It treats rigorous, SRS-style specifications as the source of truth and uses LLMs to compile them into executable code.

Key Features

  • Spec-as-Source: Code is a build artifact. You edit the Spec, not the Python/JS file.
  • Contracts over Code: Define what you want (Functional Requirements) and constraints (Non-Functional Requirements).
  • Self-Healing: An autonomous loop (attempt_fix) analyzes test failures and patches code to resolve discrepancies.
  • Multi-Provider: Supports Google Gemini and Anthropic Claude via a pluggable provider system.
  • Agent-Native: Also available as an MCP server for AI agents.

Installation

pip install specular-ai

Or for development:

git clone https://github.com/symbolfarm/specular.git
cd specular
uv sync

Quick Start

# Set your API key
export GEMINI_API_KEY="your-key-here"

# Create a new spec
specular create calculator "A simple calculator with add and multiply"

# Edit src/calculator.spec.md to define your requirements...

# Compile to code
specular compile calculator

# Run the generated tests
specular test calculator

# If tests fail, auto-fix
specular fix calculator

The Workflow

Specular isn't just a code generator; it's an architecture tool.

  1. Architecture First: Define your data types (types.spec.md) before your logic.
  2. Leaves-Up Strategy: Build dependencies (utils, helpers) before the core business logic.
  3. The Loop:
    • Edit Spec -> specular compile -> specular test.
    • Failure? -> specular fix (Let the AI patch the code).
    • Ambiguity? -> Refine the Spec (don't touch the code).

CLI Reference

specular list                     List all specs in src/
specular create <name> <desc>     Create a new spec from template
specular validate <name>          Check spec structure
specular compile <name>           Compile spec to code + tests
specular test <name>              Run tests for a spec
specular fix <name>               Auto-fix failing tests
specular build                    Compile all specs in dependency order
  --incremental                   Only recompile changed specs
  --parallel                      Compile independent specs concurrently

LLM Providers

Google Gemini (default)

export GEMINI_API_KEY="your-key-here"
export SPECULAR_LLM_MODEL="gemini-2.0-flash"  # optional

Anthropic Claude

export SPECULAR_LLM_PROVIDER="anthropic"
export ANTHROPIC_API_KEY="your-key-here"
export SPECULAR_LLM_MODEL="claude-sonnet-4-20250514"  # optional

MCP Server (for AI Agents)

Specular can run as an MCP server for Claude Desktop or other AI agents:

"specular": {
  "command": "uv",
  "args": ["run", "specular-mcp"],
  "env": {
    "GEMINI_API_KEY": "your-key-here"
  }
}

Or use the CLI: specular mcp

Development

uv run pytest    # Run tests
uv run ruff check src/  # Lint

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

specular_ai-0.2.0.tar.gz (131.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

specular_ai-0.2.0-py3-none-any.whl (32.8 kB view details)

Uploaded Python 3

File details

Details for the file specular_ai-0.2.0.tar.gz.

File metadata

  • Download URL: specular_ai-0.2.0.tar.gz
  • Upload date:
  • Size: 131.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for specular_ai-0.2.0.tar.gz
Algorithm Hash digest
SHA256 3a813b8593442ef1e3e07a8df4d09a8e1552aa87eabbb9fda9e2684281eaa1c5
MD5 b4c300728e013cb633d653f063909e47
BLAKE2b-256 902fb0ccc9dbeffe1de13b9f8e0546bbd49db061bc5c4d8231430c18ffb996d6

See more details on using hashes here.

File details

Details for the file specular_ai-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: specular_ai-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 32.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for specular_ai-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f76e4d9068da75d6b059c52dda4e21fd173e58b3a7a92444c38ca2bfbcf55538
MD5 cdba28271f92dfbf1321b16844f10cff
BLAKE2b-256 c6be1e1dc68600189e9e264df7e1e41e6b4f1d73c8d992bcad303ee20566a992

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page