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:

  1. 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 TO jumps, var hoisting) and calculates a real-time Rot Index (0–100).
  2. 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.
  3. Necromancer (TypeScript Synthesizer): Synthesizes strict, zero-dependency, pure TypeScript modules guided by our /.kiro/steering/ architectural standards.
  4. The Inquisitor (PBT Verifier): Triggered via our /.kiro/hooks/pbt-verification-hook.md agent hook, executing 100+ randomized fast-check property-based shrink tests directly in the browser to prove non-negativity, idempotency, and SQL template immutability.
  5. 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 formal requirements.md (EARS syntax), design.md (system architecture & Mermaid topology), and tasks.md milestones to enforce contract-first code generation.
  • Steering Docs (/.kiro/steering/): Created product.md and tech.md to enforce strict TypeScript typing, safe Result<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 the perform_code_autopsy tool for deterministic static analysis.
  • Agent Hooks & Property-Based Testing (/.kiro/hooks/): Automated onFileSave verification running fast-check randomized 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), and fast-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-1 to REQ-3) eliminated silent behavioral drift.
  • Running Real Property-Based Testing in the Browser: Compiling and running fast-check shrinks 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 /.kiro specs, 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 .zip archives or GitHub branches for cross-module dependency graph resurrection).
  • Automated Pull Request generation via GitHub MCP integration with attached EARS specs and fast-check coverage reports.

Built With

Share this project:

Updates

Submission history