SpecCraft is an intelligent specification-driven development platform that integrates with Claude Code to streamline feature implementation. The platform has evolved from a template-based code generator to an intelligent guidance system that provides real-time documentation and implementation assistance.
Version: 2.0
Architecture: MCP (Model Context Protocol) Server + Claude Code Integration
Primary Focus: Guidance-driven development with live documentation fetching
SpecCraft v2 represents a fundamental shift from static code generation to dynamic, intelligent guidance:
- Before: Generate template files based on specifications
- Now: Guide Claude Code with real-time documentation and best practices
- Benefit: More flexible, maintainable, and up-to-date implementations
Instead of hardcoded examples, SpecCraft dynamically fetches the latest documentation and examples from official Keystone.js repositories, ensuring implementations always use current best practices.
SpecCraft MCP Server
├── Specification Engine
│ ├── Interactive Questionnaire System
│ ├── AI-Powered Follow-up Questions
│ └── Markdown Specification Generation
├── Documentation Provider
│ ├── Live GitHub Documentation Fetching
│ ├── Intelligent Topic Mapping
│ └── Smart Caching System
├── Project Generator
│ ├── Keystone.js Project Creation
│ ├── o8u-starter Template Integration
│ └── Current Directory Support
└── Guidance Provider
├── Implementation Instructions
├── Best Practice Recommendations
└── Framework-Specific Patterns
SpecCraft integrates seamlessly with Claude Code through 4 essential slash commands:
/speccraft:new- Interactive specification creation/speccraft:build- Intelligent project creation and implementation guidance/speccraft:validate- AI-powered specification validation/speccraft:help- Live documentation lookup
- Guided Questionnaire: AI-driven question flow based on feature type
- Intelligent Follow-ups: Context-aware additional questions
- Markdown Generation: Structured specification output
- Session Management: Persistent conversation state
- GitHub Integration: Real-time fetching from Keystone.js official docs
- Topic Mapping: Intelligent handling of plurals, synonyms, and variations
- Smart Caching: Performance optimization with intelligent cache management
- Error Handling: Graceful fallback when documentation is unavailable
- Framework Detection: Automatic project type identification
- Template Integration: o8u-starter Keystone.js template
- Current Directory Support: Project creation without subfolders
- File Conflict Handling: Safe cloning to existing directories
- Implementation Instructions: Step-by-step guidance for Claude Code
- Best Practice Integration: Real-time access to official patterns
- Framework-Specific Guidance: Tailored instructions based on project type
- Progressive Enhancement: Build on existing projects intelligently
class KeystoneDocumentationProvider {
private async fetchFromGitHub(docPath: string, topic: string): Promise<DocumentationLookup | null> {
const url = `${this.KEYSTONE_DOCS_BASE}/${docPath}.md`;
const response = await fetch(url);
return this.parseMarkdownToDocumentation(content, topic, url);
}
// Intelligent topic mapping with plurals and synonyms
private topicMappings = {
'relationships': 'fields/relationship', // Handle plural
'auth': 'guides/access-control', // Handle synonym
// ... 30+ mappings
};
}class KeystoneProjectGenerator {
async generateProject(config: KeystoneProjectConfig): Promise<string> {
// Handle current directory creation
if (projectPath === '.' || path.resolve(projectPath) === process.cwd()) {
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), 'speccraft-'));
await this.cloneToDirectory(tempProjectPath);
await this.copyDirectoryContents(tempProjectPath, '.');
}
}
}class QuestionnaireEngine {
async processAnswer(sessionId: string, answer: any): Promise<QuestionnaireResponse> {
const session = this.getSession(sessionId);
const nextQuestion = await this.generateFollowUpQuestion(session, answer);
if (this.isComplete(session)) {
return this.generateCompletionInstructions(sessionId);
}
return { question: nextQuestion, progress: this.calculateProgress(session) };
}
}- User: Runs
/speccraft:new "Blog Management System" "A system for managing blog posts and authors" - SpecCraft: Initiates interactive questionnaire
- Claude Code: Asks follow-up questions based on AI analysis
- User: Provides answers through conversation
- SpecCraft: Generates comprehensive specification
- User: Validates with
/speccraft:validate spec.md - User: Implements with
/speccraft:build spec.md - Claude Code: Receives implementation guidance and executes
- SpecCraft: Detects existing project type (Keystone, Next.js, React)
- Analysis: Examines current architecture and dependencies
- Integration Guidance: Provides framework-specific implementation instructions
- Live Documentation: Fetches relevant patterns for the existing stack
- Claude Code: Implements feature following established project patterns
- Documentation Unavailable: Fallback to cached content or helpful alternatives
- Network Issues: Intelligent retry with exponential backoff
- Malformed Responses: Safe error responses instead of tool failures
- Git Clone Failures: Detailed error messages with resolution steps
- Tool Response Validation: Ensure all MCP tools return valid responses
- Error Boundaries: Catch and handle errors at appropriate levels
- Fallback Content: Provide useful alternatives when primary sources fail
class DocumentationCache {
private documentationCache = new Map<string, DocumentationLookup>();
async lookup(topic: string): Promise<DocumentationLookup | null> {
if (this.documentationCache.has(topic)) {
return this.documentationCache.get(topic)!;
}
// Fetch and cache...
}
}- Temporary Directory Cloning: Avoid conflicts in existing directories
- Selective File Copying: Skip unnecessary files (.git, etc.)
- Stream Processing: Handle large files efficiently
- Multi-Framework Support: Expand beyond Keystone.js to Next.js, React, etc.
- Custom Templates: User-defined project templates
- Version Management: Handle different framework versions intelligently
- Team Collaboration: Shared specifications and templates
- Integration Ecosystem: Connect with more development tools
- Distributed Caching: Redis integration for team environments
- API Rate Limiting: Intelligent GitHub API usage optimization
- Load Balancing: Multiple MCP server instances
- Monitoring: Comprehensive observability and metrics
- No Sensitive Data Storage: Specifications contain only architectural information
- Temporary File Cleanup: Automatic cleanup of temporary directories
- Network Security: HTTPS-only communication with external APIs
- Input Validation: Comprehensive sanitization of user inputs
- Local Execution: MCP server runs locally for security
- No External Dependencies: Core functionality works offline
- Audit Trail: Comprehensive logging of all operations
SPECCRAFT_CACHE_TTL=3600 # Documentation cache TTL
SPECCRAFT_GITHUB_TOKEN=optional # For higher API limits
SPECCRAFT_LOG_LEVEL=info # Logging verbosity{
"mcpServers": {
"speccraft": {
"command": "/usr/local/bin/speccraft-mcp-server",
"args": [],
"env": {
"NODE_ENV": "production"
}
}
}
}- Unit Tests: Core functionality and edge cases
- Integration Tests: MCP server communication
- End-to-End Tests: Complete workflow validation
- Performance Tests: Documentation fetching and caching
- Security Tests: Input validation and sanitization
- TypeScript: Full type safety throughout codebase
- ESLint: Consistent code style and best practices
- Prettier: Automated code formatting
- Vitest: Modern testing framework with excellent performance
- NPM Package:
pnpm install -g @opensaas/speccraft - Claude Code Integration: Automatic MCP server setup
- Docker Support: Containerized deployment for teams
- Development Mode: Local development with hot reloading
- Node.js: 18+ (ESM support required)
- Memory: 512MB minimum for documentation caching
- Storage: 100MB for templates and cache
- Network: Internet access for live documentation fetching
- Time to First Implementation: < 5 minutes from specification to running code
- Documentation Accuracy: Always current (real-time GitHub fetching)
- Error Rate: < 1% tool failures with graceful degradation
- User Satisfaction: Simplified workflow from 11 to 4 commands
- Cache Hit Rate: > 80% for documentation lookups
- API Response Time: < 2 seconds for specification generation
- Build Success Rate: > 95% for new project creation
- Memory Usage: < 100MB baseline, < 500MB peak
SpecCraft v2 represents a fundamental evolution in specification-driven development, moving from rigid templates to intelligent, adaptive guidance. By integrating live documentation fetching, intelligent project detection, and seamless Claude Code integration, SpecCraft enables developers to implement features faster and more accurately than ever before.
The platform's focus on guidance over generation ensures that implementations remain flexible, maintainable, and aligned with current best practices, while the simplified command structure reduces cognitive load and improves developer experience.
Last Updated: September 2024
Specification Version: 2.0
Implementation Status: Production Ready