Docs
Complete guide to understanding and using Derived - a next-generation scaffolding system for AI coding agents
Derived Documentation
What is Derived?
Derived is a next-generation scaffolding and block library designed for AI coding agents. Instead of regenerating boilerplate code from scratch every time, agents can search a shared ecosystem of reusable blocks and insert them directly into your codebase.
Derived focuses on:
- Reuse over regeneration - Stop rewriting the same code
- Deterministic scaffolding - Consistent, predictable results
- Reduced token usage - Save costs and time
- Agent-first design - Built for AI-powered development workflows
Core Components
1. Derived CLI
The Derived CLI is the execution layer that adds scaffolding blocks into your codebase.
Installation:
Basic Usage:
Key Features:
- Works without login (currently all blocks are public)
- Creates NEW FILES ONLY (never modifies existing files)
- Accepts natural-language input
- Uses AI to interpret intent
- Supports both interactive and flag-based modes
Important: Blocks added via the CLI may include AI instructions that tell agents what to do NEXT after insertion (e.g., "wire this into routing", "update exports", etc.).
2. Derived Blocks
Blocks are reusable scaffolding units that contain:
- Code templates - The actual code files to generate
- Metadata - Description, category, dependencies
- AI instructions - Optional post-insertion guidance for agents
Blocks are designed to:
- Replace repetitive boilerplate generation
- Be reused across projects
- Guide agents after insertion
Block Structure:
- Multiple templates with specific file paths
- Optional JSON input for customization
- Currently all blocks are public (no private blocks yet)
Common Block Categories:
- Backend - API controllers, services, database models
- Frontend - Components, pages, utilities
- DevOps - Docker files, CI/CD configurations
- Authentication - Login systems, user management
- Database - Migrations, seeders, queries
3. derived-mcp
derived-mcp is an MCP (Model Context Protocol) server distributed as an npm package. It acts as the discovery and retrieval layer for integrating Derived with ANY coding agent.
Installation:
Capabilities:
- Semantically searches the Derived ecosystem
- Ranks relevant blocks based on user requests
- Delegates insertion to the Derived CLI
Important Constraints:
- Does NOT validate blocks
- Does NOT modify existing code
- Focuses on retrieval and ranking only
Use with AI Agents: The MCP server enables agents like Cursor, Copilot, or custom agents to:
- Search for relevant blocks based on natural language
- Retrieve block metadata and templates
- Execute CLI commands to insert blocks
Template Syntax
Derived uses a powerful templating syntax that allows you to create dynamic, reusable code templates.
Accessing Data
Access JSON data using the {{ .key }} syntax:
Nested Data
Access nested properties using dot notation:
Loops
Loop through arrays using {{ range .key }}:
Accessing Parent Context in Loops
Use $. to access parent context inside loops:
Conditional Statements
Use if statements for conditional logic:
Built-in Functions
Transform your data using built-in functions:
Using Derived
Getting Started with the CLI
1. Install the CLI:
2. Add Your First Block:
3. View Block History:
Template Types
Blocks can create new files in your project:
Important: Derived currently creates NEW FILES ONLY and does not modify existing files.
File Paths with Variables
Templates support dynamic file paths using template variables:
CLI Commands Reference
add - Add a Block
Add a scaffolding block to your project.
Options:
--input <json>- Provide block input as JSON string-f, --force- Force re-add a block even if already added
Examples:
Block History
Derived tracks which blocks have been added to your project in .derived/blocks.json. This prevents duplicate additions and maintains a clear record of your scaffolding history.
Integration with MCP
For AI coding agents, derived-mcp provides seamless integration.
Setup
1. Install derived-mcp:
2. Configure your agent: Add derived-mcp to your agent's MCP configuration (specific steps depend on your agent).
3. Use natural language: Your agent can now search and add blocks using natural language:
The MCP server will:
- Search the Derived ecosystem for relevant blocks
- Rank them based on your request
- Guide the agent to use the CLI for insertion
When to Use Derived
Derived is ideal when you or your AI agent are:
- Scaffolding a new feature - Add boilerplate quickly
- Adding repeated patterns - Reuse instead of regenerating
- Setting up project structures - Standard configurations and layouts
- Using AI agents to build software - Reduce token usage and increase consistency
What Derived Does NOT Do:
- Does not modify existing files
- Does not validate correctness of blocks
- Does not replace business logic generation
- Does not enforce architecture automatically
Derived is a scaffolding and reuse layer, not a full code generator.
Quick Start Guide
1. Install Derived CLI
2. Add a Block to Your Project
3. Provide Input (when prompted)
2. Example: Simple React Component
Block Input:
Template (src/components/{{.componentName}}.tsx):
Example: Backend CRUD Operations
CLI Command:
Generated File (src/controllers/userController.ts):
Best Practices
1. For AI Agents
- Prefer Derived blocks over generating fresh boilerplate - Search first, generate only if necessary
- Use derived-mcp for semantic search - Let it find and rank relevant blocks
- Delegate to CLI for insertion - Use flag-based mode for automation
- Follow post-insertion AI instructions - Blocks may include next steps
2. Working with Blocks
- Check block history - Review
.derived/blocks.jsonto see what's already added - Use force flag carefully - Only re-add blocks when you need different configurations
- Understand block constraints - Blocks create new files only, they don't modify existing ones
3. Input Data
- Keep JSON inputs simple - Flat structures are easier to work with
- Use arrays for repeating elements - Lists of fields, props, etc.
- Validate JSON syntax - Use a JSON validator before passing to CLI
- Document expected structure - Especially for custom or team-specific blocks
Common Use Cases
- API Development: Generate controllers, services, and routes
- Frontend Components: Create React/Vue/Angular components
- Database Models: Generate entity classes and migrations
- Configuration Files: Create environment-specific configs
- Documentation: Generate API docs and README files
- Admin Panels: Create CRUD interfaces for data management
Tips for Success
- Start Small: Begin with simple blocks and understand the workflow
- Use with AI Agents: Derived shines when integrated with coding agents via MCP
- Leverage the Ecosystem: Browse public blocks before creating your own
- Track Your Blocks: Keep
.derived/blocks.jsonin version control - Combine Blocks: Use multiple blocks together to scaffold complete features
- Understand Limitations: Remember that Derived creates new files only, it doesn't modify existing code
Derived helps AI agents stop rewriting the same code, focusing on reuse, determinism, and efficiency.