👻 Phantom-Shell — The Haunted Terminal
Your terminal remembers what went wrong. Your AI investigates why.
What if your terminal could remember its failures, investigate the evidence, and help you understand problems that would otherwise disappear into a sea of logs?
Phantom-Shell is an open-source, local-first AI terminal investigator designed to turn mysterious command-line failures into structured, evidence-backed investigations. Instead of treating every error as an isolated event, it captures execution history, connects related incidents, investigates problems with local AI, and aims to preserve verified knowledge for future sessions.
The goal is simple: make debugging less like guessing and more like detective work.
What I Built
🕵️ A terminal that investigates its own failures
Developers spend a surprising amount of time reconstructing what happened before a failure. Which command caused it? Was the same issue encountered before? Does the configuration actually support the proposed explanation?
Phantom-Shell explores a different approach: turn terminal activity into a persistent investigation trail.
Here's what the project includes:
- Terminal event capture: Records command execution information, output, exit codes, and working-directory context.
- Persistent local storage: Uses SQLite to preserve events and investigation state.
- Local AI investigation: Integrates with Ollama to investigate incidents using locally hosted language models.
- Evidence validation: Includes components intended to distinguish supported conclusions from assumptions.
- Read-only investigation tools: Allows the investigator to inspect project information through constrained tools.
- Human-controlled actions: Provides an approval workflow for proposed actions rather than giving AI unrestricted control.
- Investigation dashboard: Offers a local web interface for reviewing investigation activity.
- Incident memory: Implements memory management intended to preserve and reuse verified knowledge.
👻 How it fits the theme
The ghost in the machine is the history of a failure that developers can no longer remember.
A build breaks. A test fails. A configuration behaves unexpectedly. The clues are scattered across commands, output, and project files.
Phantom-Shell gives those clues a persistent place to live and uses AI to help investigate them.
Rather than presenting AI as an infallible oracle, the project explores how local models, structured evidence, controlled tools, and persistent memory can work together to make AI-assisted debugging more transparent.
Demo
Dashboard: http://127.0.0.1:8765/ when running locally.
The dashboard is intended for local access; it is not a publicly hosted deployment.
The basic capture workflow has been demonstrated:
phantomshell run --no-model -- bash -lc 'echo "PhantomShell capture works"'
phantomshell report
The first command executes a command through Phantom-Shell, and the second displays the captured event and output.
For the current implementation, interactive shell capture and some end-to-end investigation scenarios are still being verified.
Phantom-Shell in Action 👻
The Phantom-Shell dashboard brings terminal activity into a single investigation timeline. Each captured command is displayed alongside its exit code and output, making successful executions and failures easier to trace.
In this example, the timeline shows a successful build alongside a configuration-related failure caused by a missing src/app.py entry point. Rather than losing the error in terminal scrollback, Phantom-Shell preserves it as part of the project's execution history.
The dashboard runs locally, with the displayed status indicating that inference uses Ollama through a loopback connection rather than external model API calls.
The idea: preserve the evidence, reconstruct the failure, and make debugging more systematic.
Code
GitHub repository: NiranjanRSoorej06/Phantom-Shell
The project is organized into separate components for terminal capture, event persistence, investigation, evidence handling, memory, policy enforcement, and the local dashboard.
The modular structure is intended to make it easier for contributors to improve individual capabilities without having to rebuild the entire application.
How I Built It
Phantom-Shell is implemented in Python, with local persistence, model integration, and a lightweight web dashboard.
Core technologies:
- Python: CLI, event processing, orchestration, and investigation logic.
- Ollama: Local inference through a locally hosted language model.
- SQLite: Persistent storage for terminal events and investigation state.
- FastAPI: Dashboard and API layer.
- Uvicorn: Local web server.
- Pytest: Automated testing.
The architecture
The application separates its responsibilities into several layers:
- Capture: Collect command execution information and output.
- Storage: Persist structured events and investigation data in SQLite.
- Episode management: Associate related events with recurring incidents.
- Investigation: Use available evidence and local AI to analyze an incident.
- Evidence and policy: Apply checks and restrictions to investigation outputs and proposed actions.
- Memory: Manage incident knowledge and its verification status.
- Dashboard: Provide a local interface for reviewing investigation activity and proposed actions.
One important design decision was to separate AI reasoning from action execution. Generating a plausible fix is not the same as proving that it is correct, and proposing an action should not automatically authorize it.
Testing and current status
The existing automated test suite passes 25 tests in 0.82 seconds. Basic one-shot command capture and event reporting have also been demonstrated.
However, passing unit tests is not the same as proving every end-to-end workflow. Interactive shell capture, cross-session memory promotion, network-isolated operation, clean-clone setup, and live-model investigation quality remain areas for further verification.
Why Does Open Innovation Matter?
An AI terminal investigator operates close to a developer's source code, command history, configuration, and debugging workflow. That makes transparency and control especially important.
Open innovation makes it possible to inspect the implementation, experiment with different models, improve the investigation pipeline, and contribute tools without depending on a single proprietary provider.
Using Ollama also allows the application to work with locally hosted models rather than requiring every investigation to be sent to a remote AI API. Actual offline operation still depends on the model and its dependencies being available locally, and is a scenario that needs dedicated verification.
An open-source implementation also makes the safety boundaries inspectable. Developers can review how events are stored, how tools are constrained, how proposed actions are handled, and how evidence is used.
I want Phantom-Shell to be something developers can question, modify, test, and improve — not a black box they have to trust.
My Agent Session
Phantom-Shell itself is the project built for this challenge. Its development involved working through implementation details, testing capture behavior, examining failures, and identifying remaining integration gaps.
The Spirit of It
There is something unsettling about a failure that appears to come out of nowhere.
You rerun the command. It fails again. You inspect the logs, change a configuration, try another command, and eventually discover that the answer was hiding in something you had already seen.
The machine has been telling you what happened all along. The problem is that the evidence is fragmented, the context disappears, and yesterday's solution becomes tomorrow's mystery.
That is the ghost I wanted to explore.
Phantom-Shell is an attempt to give those forgotten failures a memory — and to make the process of understanding them more systematic.
Not an AI that magically knows every answer, but one that can help gather clues, explain its reasoning, acknowledge uncertainty, and leave the final decision with the developer.
The terminal remembers. Now it is time to investigate.

Top comments (0)