Inspiration

Every codebase collects ghosts—unused imports, forgotten functions, and unreachable lines sitting after a return. Standard linters just dump walls of terminal warnings and walk away. For Kiroween 2026, I wanted to turn dead-code cleanup into an interactive haunted graveyard where you can inspect dead Python code at a glance and immediately act on it.

What it does

  • AST Detection: Parses pasted code, uploaded .py files, or one-click Haunted Samples with Python's ast module to find unused imports, unused functions, and unreachable code.
  • The Graveyard: Renders every finding as a color-coded, arched slate tombstone sized in proportion to its dead line count.
  • Bury Forever: Cumulatively removes selected dead blocks, animates the stones sinking out of the graveyard, and exports a clean, runnable buried.py file.
  • Resurrect: Uses the Google Gemini API (with an offline rule-based fallback) to explain why a snippet died and show a red/green side-by-side refactored diff you can copy in one click.

How I built it

The backend runs on Python, Flask, ast, and google-genai, paired with a Tailwind CSS, vanilla JS, and custom inline SVG frontend.

To make large unused functions visually tower over single-line imports without breaking the layout, each tombstone's pixel height scales from its line span \(n \ge 1\) and clamps at 420px:

$$H(n) = \min(420, \; 212 + 20(n - 1))$$

How I used Kiro

I built Code Necromancer end-to-end inside Kiro IDE, leaning on five core workflows rather than ad-hoc prompting:

  • Spec-Driven Development vs. Vibe Coding: Inside .kiro/specs/code-necromancer/, I structured the project into requirements, system design, and an ordered tasks.md implementation plan covering the Python ast analyzer, burial engine, Gemini resurrection service, and Flask routes. Compared to vibe coding—where later prompts often overwrite earlier logic or drift off-architecture—the spec forced Kiro to implement and verify one module at a time against fixed acceptance criteria, cutting out rework.
  • Steering Docs (.kiro/steering/): I separated product intent from engineering constraints using product.md (graveyard atmosphere, proportional tombstones, Bury/Resurrect flows) and tech.md (Python/Flask stack, Tailwind, exact /api/analyze, /api/bury, and /api/resurrect JSON contracts). The strategy that made the biggest difference was locking the frontend-to-backend API contract and DOM IDs in steering: during a major Costume Contest UI overhaul, Kiro redesigned the entire templates/index.html with arched gravestones, inline SVGs, and cumulative burial while leaving every backend .py file untouched and all tests green.
  • Agent Hooks (.kiro/hooks/python-save.json): I configured a file-save hook that automatically runs pytest whenever any .py file is saved. Instead of batching bugs and debugging them at the end, every edit to analyzer.py, burial.py, or resurrection.py gave immediate pass/fail feedback inside Kiro IDE.
  • Property-Based Testing (PBT): Alongside unit tests, I enabled Hypothesis property-based tests (11 passing tests total) for the hardest correctness requirements—ensuring burial.py removes targeted dead-code nodes without breaking Python syntax or deleting live functions, and verifying AST analysis invariants across varied inputs. PBT caught subtle indentation and offset edge cases that hand-written examples missed.
  • Automated Visual Verification in Kiro IDE: During the final graveyard redesign, Kiro spun up an isolated local test server (without burning Gemini API quota) and ran headless Chrome captures at desktop (1440px) and mobile (390px) viewports to verify hover states, the side-by-side diff modal, burial animations, and zero console errors before committing.

Challenges I ran into

  • Safe cumulative burial: Stripping lines across multiple clicks without breaking Python indentation or shifting offsets required careful AST-based removal so buried.py always stays valid and matches the screen.
  • Frontend overhaul without regressions: Upgrading flat cards into arched gravestones, flickering candles, drifting fog, and side-by-side diffs without touching any backend .py file or breaking existing tests.
  • Proportional sizing: Tuning the height baseline (212px) and step (20px per extra line) so short imports and long functions looked clearly distinct on both desktop and mobile.

Accomplishments that I'm proud of

  • Cohesive Costume Contest UI: Transformed a basic dark interface into an interactive haunted graveyard—with proportionally scaled arched gravestones, flickering candles, drifting fog, an SVG graveyard footer, and custom inline SVGs—without touching or breaking a single backend file.
  • Syntax-Safe Cumulative Burial: Engineered reliable AST-based removal so repeated burials stay synced with the graveyard on screen and always export a clean, runnable buried.py file.
  • Resilient AI Refactoring: Built Gemini-powered side-by-side code resurrection with one-click copying and a deterministic offline fallback so the app works smoothly even without an API key.
  • Disciplined Kiro Workflow & Test Coverage: Used .kiro/ steering docs, specs, and a save-triggered pytest hook to ship cleanly with all 11 unit and Hypothesis property-based tests passing.

What I learned

  • Spec-Driven Discipline Saves Hours: Defining Kiro steering docs (product.md, tech.md), ordered specs (tasks.md), and a save-triggered pytest hook upfront prevented architecture drift and caught regressions the second code changed.
  • AST Internals & Property-Based Testing: Working directly with Python's ast node spans—and validating code removal with Hypothesis—exposed subtle syntax and indentation edge cases that manual unit tests would have missed.
  • Decoupled Architecture Enables Bold Redesigns: Keeping strict separation between Flask API contracts and frontend markup made it possible to completely overhaul the UI into arched gravestones, custom inline SVGs, and side-by-side diffs without breaking a single backend file.
  • Graceful AI Fallbacks Matter: Pairing the Google Gemini API with a deterministic rule-based fallback ensures Resurrect stays dependable even when an API key or network connection isn't available.

What's next for Code Necromancer

  • Multi-File Repository Graveyards: Connect a GitHub repository URL or upload a .zip archive to detect dead functions, unused classes, and orphaned modules across an entire codebase rather than a single file.
  • Expanded AST Detectors: Surface unused local variables, redundant conditional branches, shadowed definitions, and dead class methods alongside imports and functions.
  • One-Click Cleanup Pull Requests: Turn buried tombstones directly into a downloadable git diff patch or an automated "Graveyard Cleanup" PR ready for code review.
  • CLI & GitHub Actions Integration: Package the AST engine as a lightweight CLI tool and CI check that flags newly introduced dead code on pull requests before it ever reaches main.

Built With

Share this project:

Updates

Submission history