Inspiration
Every year, organizations spend billions maintaining decaying legacy codebases—1985 COBOL banking routines, 1999 PHP 4 portals, and 2008 jQuery spaghetti. Simply asking an LLM to "rewrite this" (vibe coding) is dangerous: AI models routinely carry over silent security vulnerabilities like eval() Remote Code Execution (RCE), raw SQL injection sinks, global state mutations, and fixed-point integer overflows.
For Kiroween 2026 (Resurrection Category), we built NecroSpec AI to replace blind "vibe rewrites" with Spec-Driven Necromancy—proving mathematically that resurrected code is safer and behaviorally equivalent before it ever ships.
What it does
NecroSpec AI orchestrates a 4-agent Kiro Crew assembly line to dissect, specify, resurrect, and formally verify legacy code:
- Dr. Frankenstein (MCP AST Coroner): Invokes our custom Model Context Protocol server (
/.kiro/mcp/ast-autopsy-server.js) to scan raw legacy source code for cursed anti-patterns (eval(),mysql_query(),GO TOjumps,varhoisting) and calculates a real-time Rot Index (0–100). - The Spec Oracle (EARS Architect): Extracts legacy business intent into formal EARS (Easy Approach to Requirements Syntax) contracts (
WHEN / IF / THEN THE SYSTEM SHALL) and renders a visual Topology Resurrection Diff before generating a single line of target code. - Necromancer (TypeScript Synthesizer): Synthesizes strict, zero-dependency, pure TypeScript modules guided by our
/.kiro/steering/architectural standards. - The Inquisitor (PBT Verifier): Triggered via our
/.kiro/hooks/pbt-verification-hook.mdagent hook, executing 100+ randomizedfast-checkproperty-based shrink tests directly in the browser to prove non-negativity, idempotency, and SQL template immutability. - Live Interactive Attack Sandbox: Lets users inject negative prices, RCE payloads (
process.exit()), and SQL injection strings side-by-side—watching the legacy runtime get compromised while the Kiro-resurrected TypeScript module neutralizes every exploit cleanly.
How we built it (Deep Kiro Architecture)
- Spec-Driven Development (
/.kiro/specs/): We structured formalrequirements.md(EARS syntax),design.md(system architecture & Mermaid topology), andtasks.mdmilestones to enforce contract-first code generation. - Steering Docs (
/.kiro/steering/): Createdproduct.mdandtech.mdto enforce strict TypeScript typing, safeResult<T, E>return unions, and our Gothic Cyber-Necromancy visual design system. - Custom MCP Server (
/.kiro/mcp/ast-autopsy-server.js): Built a JSON-RPC stdio MCP server exposing theperform_code_autopsytool for deterministic static analysis. - Agent Hooks & Property-Based Testing (
/.kiro/hooks/): AutomatedonFileSaveverification runningfast-checkrandomized adversarial inputs against synthesized modules. - Full-Stack Tech Stack: React 19, TypeScript, Vite, Tailwind CSS v4, Node.js/Express, Google Gemini 2.5 Flash (
@google/genai), andfast-check.
Challenges we ran into
- Preventing Silent Bug Translation: Early LLM prompts faithfully reproduced legacy bugs (such as allowing negative cart totals or COBOL
PIC 9(7)truncation). Enforcing an intermediate EARS specification layer (REQ-1toREQ-3) eliminated silent behavioral drift. - Running Real Property-Based Testing in the Browser: Compiling and running
fast-checkshrinks dynamically in a live web sandbox without freezing the UI required lightweight deterministic AST evaluation paired with asynchronous shrink loops. - Dual-Mode Resilience: Designing the architecture so that custom user functions leverage live Gemini 2.5 Flash + Node MCP analysis locally while seamlessly falling back to an in-browser deterministic AST/PBT engine on static deployments.
Accomplishments that we're proud of
- Turning legacy code migration from guesswork into a mathematically verified, 4-stage Kiro Crew pipeline.
- Building an interactive Attack Sandbox where anyone can test live exploits against legacy vs. resurrected code in one click.
- Full compliance with
/.kirospecs, steering, hooks, custom MCP server, and MIT open-source licensing.
What we learned
Spec-first development changes how you collaborate with AI: when formal EARS contracts and fast-check invariants act as guardrails, AI stops being an unpredictable code generator and becomes a deterministic engineering compiler.
What's next for NecroSpec AI
- Multi-file repository ingestion (uploading full legacy
.ziparchives or GitHub branches for cross-module dependency graph resurrection). - Automated Pull Request generation via GitHub MCP integration with attached EARS specs and
fast-checkcoverage reports.
Built With
- fast-check
- gemini-api
- kiro
- mcp
- node.js
- react
- tailwindcss
- typescript
- vite