xiaohongshu
xiaohongshu
cfn-compilation-error-fixer
Two-phase compilation error fixer for Rust and TypeScript using Cerebras LLM bulk processing + dedicated agent cleanup. Use when you have 20+ compilation errors that need fast bulk reduction, or when errors are mostly mechanical (type mismatches, missing imports, syntax issues).
Full skill instructions
Two-phase workflow for fixing large-scale compilation errors in Rust and TypeScript projects using Cerebras LLM bulk processing + dedicated agent cleanup.
.claude/skills/cfn-compilation-error-fixer/
├── SKILL.md # This file
├── HANDOFF.md # Detailed handoff documentation
├── package.json # Dependencies and npm scripts
├── index.js # Main entry point
├── bin/
│ └── fix-errors.sh # Executable script
├── lib/
│ └── fixer/
│ ├── package.json # Runtime dependencies
│ ├── cerebras-wrapper.ts # Cerebras SDK wrapper
│ ├── cerebras-gated-fixer-v2.ts # Rust fixer (self-contained)
│ ├── typescript-gated-fixer-v2.ts # TypeScript fixer (self-contained)
│ └── tsconfig.json # TypeScript configuration
└── lib/
└── gates/
└── typescript-gates.ts # TypeScript validation gates
This skill orchestrates:
# Setup (one-time)
cd /mnt/c/Users/masha/Documents/claude-flow-novice/.claude/skills/cfn-compilation-error-fixer
npm install
# Option 1: Run from skill directory
export CEREBRAS_API_KEY="your-key"
npm run fix:rust
# Option 2: Run from your Rust project directory
cd /path/to/your/rust-project
export CEREBRAS_API_KEY="your-key"
npx tsx /mnt/c/Users/masha/Documents/claude-flow-novice/.claude/skills/cfn-compilation-error-fixer/lib/fixer/cerebras-gated-fixer-v2.ts
# Option 3: Use the executable script
./bin/fix-errors.sh rust
# Option 4: Use Node.js entry point
node index.js rust
# Additional flags
npm run fix:rust -- --dry-run # Preview patches without writing
npm run fix:rust -- --verbose # Debug output
npm run fix:rust -- --no-layer3 # Skip LLM review layer
npm run fix:rust -- --no-clippy # Skip clippy checks
# With explicit project path
npx tsx cerebras-gated-fixer-v2.ts --project=/path/to/rust-project
# With environment variable
export RUST_PROJECT_PATH=/path/to/rust-project
npx tsx cerebras-gated-fixer-v2.ts
# Setup (one-time)
cd /mnt/c/Users/masha/Documents/claude-flow-novice/.claude/skills/cfn-compilation-error-fixer
npm install
# Option 1: Run from skill directory
export CEREBRAS_API_KEY="your-key"
npm run fix:ts
# Option 2: Run from your TypeScript project directory
cd /path/to/your/typescript-project
export CEREBRAS_API_KEY="your-key"
npx tsx /mnt/c/Users/masha/Documents/claude-flow-novice/.claude/skills/cfn-compilation-error-fixer/lib/fixer/typescript-gated-fixer-v2.ts
# Option 3: Use the executable script
./bin/fix-errors.sh typescript
./bin/fix-errors.sh ts # Short form
# Option 4: Use Node.js entry point
node index.js typescript
node index.js ts
# Additional flags
npm run fix:ts -- --dry-run # Preview patches without writing
npm run fix:ts -- --verbose # Debug output
# With explicit project path
npx tsx typescript-gated-fixer-v2.ts --project=/path/to/typescript-project
┌─────────────────┐
│ cargo check │ → Parse Rust errors
└────────┬────────┘
▼
┌─────────────────┐
│ Cerebras LLM │ → Generate fix (zai-glm-4.6)
└────────┬────────┘
▼
┌─────────────────────────────────────────┐
│ LAYER 1: 12 Structural Gates │
├─────────────────────────────────────────┤
│ A: LineCount B: FnSignature │
│ C: ImportDup D: BraceBalance │
│ E: SemanticDiff F: OrphanedCode │
│ G: ImportPath H: PatternDup │
│ I: ImplLocation J: TypeCast │
│ K: MatchArm L: Regression │
└────────┬────────────────────────────────┘
▼ (up to 3 retries with feedback)
┌─────────────────────────────────────────┐
│ LAYER 2: cargo check validation │
└────────┬────────────────────────────────┘
▼
┌─────────────────────────────────────────┐
│ LAYER 3: LLM Review Gate │
└────────┬────────────────────────────────┘
▼
┌─────────────────┐
│ Write to file │
└─────────────────┘
/tmp/rust-fix-patches/ - Rust fix patches directory/tmp/typescript-fix-patches/ - TypeScript fix patches directory/tmp/v2-retry-run.log - Full run output/tmp/gate-rejections.json - Gate rejection detailsSpawn a rust-developer or cfn-system-expert agent with this prompt:
You are a Rust compilation error fixer. Fix the remaining errors in the Rust codebase.
CONTEXT:
- Cerebras LLM already fixed ~95% of errors
- Quality validation found some semantic issues in applied fixes
- Remaining errors need high-quality fixes
WORKING DIRECTORY:
cd <YOUR_RUST_PROJECT_PATH> # e.g., /path/to/rust-project
STEP 1: Get current error count and locations
SQLX_OFFLINE=true cargo check 2>&1 | grep -E "^error\[E" | sort | uniq -c | sort -rn
STEP 2: For each error file, fix in order of dependency:
1. Read the FULL file to understand context
2. Identify the root cause (not just the symptom)
3. Apply minimal fix that preserves semantics
4. Run SQLX_OFFLINE=true cargo check to verify
5. If new errors appear, fix those too
RULES:
- Read FULL file before editing (not just error snippets)
- Preserve ALL existing imports, don't duplicate
- Use proper Rust idioms (? operator, as casts, trait bounds)
- Fix root causes first (cascading errors will resolve)
- Verify with cargo check after EACH file
- Maintain CFN compliance standards
COMMON ERROR TYPES:
- E0308 (type mismatch): Add explicit casts or fix generics
- E0412/E0433/E0425 (missing type/import): Add use statements
- E0599 (wrong method): Fix method chain (e.g., .ok_or_else() on Result)
- E0277 (trait not implemented): Add trait implementations
- E0382 (borrow checker): Fix ownership issues
Report final error count when done.
Spawn a typescript-developer or cfn-system-expert agent with this prompt:
You are a TypeScript compilation error fixer. Fix the remaining errors in the TypeScript codebase.
CONTEXT:
- Cerebras LLM already fixed ~95% of errors
- Quality validation found some semantic issues in applied fixes
- Remaining errors need high-quality fixes
WORKING DIRECTORY:
cd <YOUR_TYPESCRIPT_PROJECT_PATH> # e.g., /path/to/typescript-project
STEP 1: Get current error count and locations
npm run type-check 2>&1 | grep -E "error TS" | sort | uniq -c | sort -rn
STEP 2: For each error file, fix in order of dependency:
1. Read the FULL file to understand context
2. Identify the root cause (not just the symptom)
3. Apply minimal fix that preserves semantics
4. Run npm run type-check to verify
5. If new errors appear, fix those too
RULES:
- Read FULL file before editing (not just error snippets)
- Preserve ALL existing imports, don't duplicate
- Use proper TypeScript idioms (type guards, interfaces, generics)
- Fix root causes first (cascading errors will resolve)
- Verify with tsc after EACH file
- Maintain CFN compliance standards
COMMON ERROR TYPES:
- TS2307 (module not found): Fix import paths or install missing packages
- TS2322 (type mismatch): Add type annotations or fix type inference
- TS2339 (property not exists): Add interface definitions or type assertions
- TS7006 (implicit any): Add explicit type annotations
- TS2688 (cannot find type definition): Install @types packages
Report final error count when done.
# 1. Check initial error count
cd <YOUR_RUST_PROJECT_PATH>
SQLX_OFFLINE=true cargo check 2>&1 | grep -c "^error\["
# Output: 342
# 2. Run Phase 1 (Cerebras bulk fixer)
cd /mnt/c/Users/masha/Documents/claude-flow-novice/.claude/skills/cfn-compilation-error-fixer
export CEREBRAS_API_KEY="your-key"
npm run fix:rust 2>&1 | tee /tmp/rust-fix.log
# Output: 342 → 15 (95.6% reduction)
# 3. Validate Phase 1 results
cd <YOUR_RUST_PROJECT_PATH>
SQLX_OFFLINE=true cargo check 2>&1 | grep -E "^error\[" | wc -l
# Output: 15
# 4. Run Phase 2 (dedicated agent cleanup)
# Spawn rust-developer agent with prompt above
# Output: 15 → 0
# 5. Final verification
SQLX_OFFLINE=true cargo check
# Output: Finished dev profile [unoptimized + debuginfo] target(s) in X.XXs
# 1. Check initial error count
cd <YOUR_TYPESCRIPT_PROJECT_PATH>
npm run type-check 2>&1 | grep -c "error TS"
# Output: 156
# 2. Run Phase 1 (Cerebras bulk fixer)
cd /mnt/c/Users/masha/Documents/claude-flow-novice/.claude/skills/cfn-compilation-error-fixer
export CEREBRAS_API_KEY="your-key"
npm run fix:ts 2>&1 | tee /tmp/typescript-fix.log
# Output: 156 → 7 (95.5% reduction)
# 3. Validate Phase 1 results
cd <YOUR_TYPESCRIPT_PROJECT_PATH>
npm run type-check 2>&1 | grep "error TS" | wc -l
# Output: 7
# 4. Run Phase 2 (dedicated agent cleanup)
# Spawn typescript-developer agent with prompt above
# Output: 7 → 0
# 5. Final verification
npm run type-check
# Output: No type errors found
| File | Purpose |
|---|---|
./HANDOFF.md | Detailed handoff documentation |
./lib/fixer/cerebras-gated-fixer-v2.ts | Rust fixer (self-contained) |
./lib/fixer/typescript-gated-fixer-v2.ts | TypeScript fixer (self-contained) |
./lib/gates/typescript-gates.ts | TypeScript validation gates |
./bin/fix-errors.sh | Executable wrapper script |
./index.js | Node.js entry point |
/tmp/gate-rejections.json | Gate rejection log (runtime) |
/tmp/v2-retry-run.log | Full run output (runtime) |
/tmp/rust-fix-patches/ | Rust fix patches (runtime) |
/tmp/typescript-fix-patches/ | TypeScript fix patches (runtime) |
CEREBRAS_API_KEY: Your Cerebras API key (required for LLM fixes)CFN_ALLOW_FALLBACK=true: Allow running without Cerebras SDK (read-only mode)SQLX_OFFLINE=true: For cargo check without database (Rust projects)RUST_PROJECT_PATH: Override default Rust project pathTYPESCRIPT_PROJECT_PATH: Override default TypeScript project path/mnt/c/Users/masha/Documents/ourstories-v2/services/rust-services"tsx is not installed"
npm install -g tsx
# Or use local version
npx tsx [file]
"Cerebras SDK not found"
npm install @cerebras/cerebras_cloud_sdkCFN_ALLOW_FALLBACK=true npm run fix:rustPermission denied on fix-errors.sh
chmod +x bin/fix-errors.sh
"Module not found" errors
cd /mnt/c/Users/masha/Documents/claude-flow-novice/.claude/skills/cfn-compilation-error-fixer
npm install
High memory usage
--max-tokens 2000 to limit LLM response sizeEnable verbose logging to see detailed processing:
npm run fix:rust -- --verbose
npm run fix:ts -- --verbose
--parallel-calls 5 to reduce API calls--no-layer3 to skip LLM review--dry-run to preview fixesIf fixes break the build:
# Rust
cd <RUST_PROJECT>
git checkout -- src/
SQLX_OFFLINE=true cargo check
# TypeScript
cd <TYPESCRIPT_PROJECT>
git checkout -- src/
npm run type-check
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience