DEV Community

Cover image for When the Ghost Takes Over: Building a Possessed AI Code Assistant
arjav patni
arjav patni

Posted on

When the Ghost Takes Over: Building a Possessed AI Code Assistant

Hacktoberfest Open-Source AI Challenge: Ghost in the Machine Submission 👻🌼

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 4: Ghost in the Machine

What I Built

Grimoire is a 100% offline, privacy-first code reviewer powered by a local Gemma 2B model. Instead of a standard, dry linting tool, Grimoire is possessed by a malevolent, gothic spirit. You paste in your messy, undocumented code, and it hunts for technical bugs, anti-patterns, and security flaws—delivering its feedback using terrifying gothic horror metaphors.

Demo

Because Grimoire is a local-only application for privacy reasons, here is a screenshot of the "Altar" (input) and the "Spirit's Judgement" (AI output) in action:

Code

How I Built It

  • Local AI Inference Engine: Powered by Gemma 2B running locally via Ollama.
  • The "Possessed" Backend: A lightweight FastAPI server intercepts the raw code and wraps it in a highly specific system prompt, forcing the model to blend strict software engineering principles with an Edgar Allan Poe-style persona.
  • The Spooky Frontend: Built using Next.js, TypeScript, and Tailwind CSS, featuring a dual-pane UI with a dark, atmospheric design.

Why Does Open Innovation Matter?

Developers cannot legally paste proprietary client code, API keys, or unreleased startup algorithms into closed-source cloud APIs due to NDAs and severe data security risks. By using an open-weight model running locally via Ollama, Grimoire acts as an offline ghost. It keeps corporate secrets locked safely inside the developer's machine with the internet turned completely off, ensuring your proprietary code isn't harvested by a third-party server.

The Spirit of It

The most memorable moment of building Grimoire was experiencing "Persona Lock" with the 2B model. I fed the AI a perfectly safe, parameterized PostgreSQL query with a standard try/catch block to see how it would react to flawless logic.

The gothic horror system prompt completely overpowered the model's technical reasoning. It aggressively hallucinated vulnerabilities just to stay in character, declaring the safe $1 parameter a "monstrous SQL injection beast" and calling the try/catch block a "demon summoning ritual." It was a hilarious, unexpected look into how small models balance strict logical analysis with intense creative constraints.

Prize Categories

  • Best Use of Gemma

Top comments (1)

Collapse
 
robertpaschal profile image
Odinaka Robert Nnamani •

the $1 param getting called a monstrous beast is the whole bug in one line.