This document defines the implementation standards for the Claude Code Builder v3.0 Enhanced shell script that builds autonomous project builders with full memory integration, research capabilities, and production-first standards.
- ALWAYS check mem0 BEFORE any code/task - No exceptions
- SEARCH FIRST, CODE SECOND - Memory drives all decisions
- Store EVERYTHING learned for future projects
- Cross-project knowledge benefits - Project A learnings help Project B
- NO mock implementations - Everything must be REAL and FUNCTIONAL
- NO unit tests - Integration and end-to-end tests ONLY
- NO dry runs - Execute actual builds that create real projects
- NO placeholders - Complete implementations only
- Real APIs, databases, services - No simulations ever
MANDATORY RESEARCH SEQUENCE:
1. CHECK MEM0 FIRST β Search for existing knowledge
2. USE CONTEXT7 SECOND β Get latest documentation
3. WEB SEARCH THIRD β Only if mem0 and context7 insufficient
4. STORE IN MEM0 ALWAYS β Save all findings for future useThe builder creates a sophisticated shell script with these components:
builder-claude-code-builder.sh
βββ Memory Integration Functions
β βββ check_mem0_memory() # Search existing knowledge
β βββ save_memory_state() # Store phase learnings
β βββ load_build_state() # Resume capability
βββ Research System Functions
β βββ execute_research_phase() # Comprehensive research
β βββ create_research_instructions() # Research guidelines
β βββ Research workflow enforcement
βββ Enhanced Logging Functions
β βββ parse_enhanced_stream_output() # Tool usage tracking
β βββ display_tool_parameters() # Parameter explanation
β βββ Tool rationale logging
βββ Git Integration Functions
β βββ initialize_git_repo() # Version control setup
β βββ Enhanced commit messages # Detailed commits
β βββ Per-phase commit automation
βββ MCP Configuration
β βββ setup_enhanced_mcp() # Server configuration
β βββ mem0 server integration # Persistent memory
β βββ context7 server integration # Documentation
β βββ Enhanced .mcp.json generation
βββ Production Standards Enforcement
βββ Dependency validation # Required tools check
βββ Production requirements # NO mocks enforcement
βββ Cost tracking integration # API usage monitoring
βββ Error handling standards{
"mcpServers": {
"mem0": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-mem0"],
"env": {"MEM0_API_KEY": "${MEM0_API_KEY:-}"},
"description": "Persistent memory across all projects"
},
"context7": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-context7"],
"description": "Latest documentation for libraries"
},
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "."],
"description": "File system operations with full logging"
},
"git": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-git"],
"description": "Version control throughout build"
}
}
}# Before tool execution
log("TOOL", "Using ${TOOL_NAME}")
log("TOOL", "Rationale: ${WHY_USING_THIS_TOOL}")
log("TOOL", "Expected outcome: ${WHAT_WE_EXPECT}")
# During execution
display_tool_parameters "${TOOL_NAME}" "${PARAMETERS}"
# After execution
log("TOOL", "Result: ${WHAT_WAS_ACHIEVED}")
log("TOOL", "Learning: ${WHAT_WAS_LEARNED}")
# Memory storage
log("MEMORY", "Storing: ${PATTERN_FOR_FUTURE_USE}")- Memory Operations (mem0__*): Purple logging with π§ icon
- Documentation Lookup (context7__*): Cyan logging with π icon
- File Operations (filesystem__*): Green logging with π icon
- Version Control (git__*): Orange logging with π icon
- General Tools: Cyan logging with π§ icon
- Load Context: Previous phase memory and learnings
- Check mem0: Search for relevant patterns and solutions
- Research: Use context7 for documentation when needed
- Execute with Logging: Implement with full rationale
- Store Learnings: Save discoveries and patterns to mem0
- Git Commit: Version control with detailed messages
- Track Costs: Record and analyze API usage
PHASE ${PHASE_NUM}: ${PHASE_NAME}
OBJECTIVE: ${PHASE_OBJECTIVE}
MEMORY CONTEXT FROM PREVIOUS PHASES:
${MEMORY_CONTEXT}
REQUIREMENTS (PRODUCTION STANDARDS - NO EXCEPTIONS):
- Check mem0 for any relevant patterns before implementing
- Use context7 for documentation when using new libraries
- Log the rationale for every tool use
- Store important patterns and decisions in mem0
- Implement all functionality completely (NO placeholders, NO TODOs)
- NO mock implementations - everything must be REAL and FUNCTIONAL
- NO unit tests - create integration and E2E tests ONLY
- Use REAL APIs, databases, and services (no simulations)
- Include comprehensive error handling with retry logic
- Add production-grade logging to stdout/stderr
- Use environment variables for ALL configuration
- Implement proper security (input validation, auth, etc.)
- Ensure cloud-ready architecture
- Create integration tests that use real services
ENHANCED TOOLSET AVAILABLE:
- mem0__search-memories/add-memory (MANDATORY - check first, store learnings)
- context7__resolve-library-id/get-library-docs (for latest documentation)
- filesystem__read_file/write_file/create_directory (with full logging)
- sequential_thinking__think_about (for complex analysis)
- git__status/add/commit (for version control)initialize_git_repo() {
log "GIT" "π Initializing git repository for version control"
if [ ! -d ".git" ]; then
git init
log "GIT" "π Created new git repository"
fi
# Create comprehensive .gitignore
# Add build artifacts, logs, state files
# Commit initial setup
}git commit -m "${GIT_COMMIT_MSG}
Phase Details:
- Duration: ${PHASE_DURATION}s
- Memory Points: ${MEMORY_POINTS}
- Tools Used: See phase-${PHASE_NUM}-output.log
π€ Generated with Claude Code Builder v3.0 Enhanced
Co-Authored-By: Claude <noreply@anthropic.com>"track_cost_information() {
local phase_num=$1
local log_file=$2
# Extract cost data from Claude Code logs
local session_cost=$(grep -o '"session_cost":[0-9.]*' "$log_file" | tail -1)
local total_cost=$(grep -o '"total_cost":[0-9.]*' "$log_file" | tail -1)
# Store in .cost-tracking.json
# Log cost breakdown
# Identify optimization opportunities
}# Dependency checking at script start
REQUIRED_TOOLS=("jq" "git" "npx" "claude")
for tool in "${REQUIRED_TOOLS[@]}"; do
if ! command -v "$tool" >/dev/null 2>&1; then
echo -e "\033[0;31mError:\033[0m Required tool '\033[1m$tool\033[0m' not found."
exit 1
fi
done
# Interactive session detection
if [ -t 1 ]; then
clear # Only clear in interactive sessions
fi
# Resume logic with directory handling
if [ "$RESUME_BUILD" = true ] && [ "$OUTPUT_DIR" != "." ]; then
log "WARNING" "Using saved output directory during resume"
fi# NO DRY RUNS - Create actual test specification
cat > test-spec.md << 'EOF'
# Test API with FastAPI - PRODUCTION STANDARDS
Build a REAL, FUNCTIONAL API using FastAPI with:
- Health check endpoint with actual status checks
- JWT authentication with real token validation
- Protected endpoints with proper authorization
- Database integration (PostgreSQL or SQLite)
- Integration tests ONLY (NO unit tests)
- Environment variable configuration
- Production-ready middleware
EOF
# Execute REAL build (NO dry run)
claude-code-builder test-spec.md \
--output-dir ./test-output \
--enable-research \
--verbose \
--no-dry-run \
2>&1 | tee test-execution.log- ZERO hardcoded credentials - Environment variables only
- Input validation for all user inputs
- Output sanitization for all displays
- No bypassing authentication ever
- SSL/TLS enforcement for all connections
- Security event logging for audit trails
# MCP server environment variables
"env": {
"MEM0_API_KEY": "${MEM0_API_KEY:-}",
"GITHUB_TOKEN": "${GITHUB_TOKEN:-}"
}save_build_state() {
local phase_num=$1
local status=$2
local cost_data=${3:-"{}"}
cat > "$STATE_FILE" << EOF
{
"version": "$VERSION",
"timestamp": "$(date -u +"%Y-%m-%dT%H:%M:%SZ")",
"current_phase": $phase_num,
"status": "$status",
"output_dir": "$OUTPUT_DIR",
"memory_file": "$MEMORY_FILE",
"cost_data": $cost_data
}
EOF
}save_memory_state() {
local phase_id=$1
local memory_data=$2
# Update .build-memory-v3.json with phase learnings
# Include decisions made, patterns discovered
# Store for cross-phase context and future projects
}The builder must create projects that are:
- Complete and functional - No placeholder code
- Production-ready - Real error handling, logging, security
- Cloud-compatible - Environment variables, health checks
- Well-tested - Integration and E2E tests only
- Properly documented - README, API docs, deployment guides
- Version controlled - Full git history
- Cost-optimized - Efficient API usage patterns
Before completion, verify:
- β All phases completed successfully
- β Memory integration active throughout
- β Research workflow demonstrated
- β Tool logging comprehensive with rationale
- β Git commits include detailed context
- β Cost tracking functional and accurate
- β NO mock implementations anywhere
- β Production standards enforced
- β Security requirements met
- β Error handling comprehensive
Final directory structure:
output-directory/
βββ claude-code-builder/ # Generated project
β βββ [Complete, functional codebase]
β βββ [Production-ready implementation]
βββ .build-state-v3-enhanced.json # Build state
βββ .build-memory-v3.json # Memory persistence
βββ .cost-tracking.json # Cost analytics
βββ .mcp.json # MCP configuration
βββ build-phases-v3.json # AI-generated phases
βββ build-strategy-v3.md # Strategy document
βββ .git/ # Version control
βββ [Various log files] # Execution logs
The enhanced builder succeeds when it:
- Learns from memory and applies knowledge across projects
- Researches thoroughly using the mandatory workflow
- Builds real projects with no mocks or simulations
- Logs comprehensively with rationale for every action
- Tracks costs accurately and identifies optimizations
- Enforces production standards throughout the process
- Integrates version control with detailed history
- Stores knowledge for future project benefits
This creates the most intelligent autonomous project builder that learns, researches, and improves with every use while maintaining the highest production standards.