---
argument-hint: [clean|production]
description: Builds code-executor-mcp with strict TypeScript/ESLint enforcement, validates MCP server compilation
allowed-tools: Bash, BashOutput, KillShell, Read, TodoWrite, Glob
---
Build "$ARGUMENTS" (default: development)
## π¨ CRITICAL BUILD LAWS
**Non-Negotiable Rules:**
- π¦ **ZERO TOLERANCE:** TypeScript/ESLint errors WILL fail build
- π― **Fix FIRST error**, not loudest (root cause analysis)
- βοΈ **Type Safety:** Full TypeScript strict mode enforcement
- π§ **Clean Build:** dist/ directory must compile successfully
---
## π§Ή CLEAN (Nuclear Option)
**When to clean:** Corrupted cache, mysterious build failures, or explicit `clean` argument
```bash
# Remove all build artifacts
rm -rf dist node_modules/.cache
# Clear schema cache
rm -rf ~/.code-executor/schema-cache.json
# Reinstall if package.json changed
npm install
```
---
## ποΈ BUILD VALIDATION (MANDATORY SEQUENCE)
**MCP Server compilation chain:**
```
TypeScript Compilation β Type Checking β Linting β dist/ Output
```
**Why:** Type safety ensures MCP tool schemas are correctly typed and validated
---
## π COMMON FAILURES & FIXES
| Error | Root Cause | Solution |
| -------------------------- | ------------------------------ | ---------------------------------- |
| `Cannot find module` | Invalid import path | Check tsconfig.json paths |
| `Type error in executor` | Schema validation types wrong | Check AJV types and validators |
| `dist/ incomplete` | Build interrupted | `rm -rf dist && npm run build` |
| `Schema cache error` | Corrupted cache file | `rm ~/.code-executor/schema-cache.json` |
| `@ts-ignore present` | Type safety bypassed | FORBIDDEN - Fix type issues |
---
## β‘ QUALITY CIRCUIT TRIGGER
### Pre-Build Validation
**ALWAYS run before build:**
```bash
npm run lint && npm run typecheck && npm run build
```
### Build Failure Escalation
**TypeScript/ESLint errors β STOP and fix immediately:**
- **Schema changes** β Verify schema-validator.ts types
- **Type errors in executors** β Check TypeScript/Python executor types
- **MCP SDK version mismatch** β Verify @modelcontextprotocol/sdk version
### Success Path
1. If build **PASSES** β Run test suite (`npm test`)
2. **EXCEPTION:** Skip if issue documented in development notes
**Safety Limit:** Max 5 circuit iterations to prevent infinite loops
---
**Type safety is LAW. Nuclear clean when corrupted.**