👻 Ghost Protocol
The silent guardian of your AI-assisted workflow
Stop wasting tokens on garbage files.
Stop committing 50MB SQLite databases.
Stop explaining to AI why your project has 847 PNG files.
Installation • Quick Start • Features • Configuration
🤔 The Problem
You're vibe-coding with Claude/Cursor/Copilot. Life is good.
Then you notice:
- 💸 Token costs are through the roof
- 🐌 AI responses are slow because context is bloated
- 😱 You accidentally committed a 200MB video file
- 🔄 AI keeps "seeing" your
node_modulesor__pycache__
Ghost Protocol fixes all of this. Automatically. In the background.
✨ Features
| Feature | What it does |
|---|---|
| 🚫 Auto-Ignore | Detects heavy files (images, videos, databases) and adds them to .gitignore + .cursorignore |
| 🧹 Self-Cleaning | Removes stale entries when you delete the original files |
| 🛡️ Commit Guard | Blocks git commit if you try to push oversized source files |
| 📊 Live Monitor | Beautiful TUI dashboard showing token count & estimated API cost |
| ⚡ Zero Config | Works out of the box. Sensible defaults. |
| 🔇 Silent | Runs in background. No notifications. No interruptions. |
📦 Installation
From PyPI (Recommended)
pip install ghost-protocol
After installation, the ghost command will be available globally.
From Source
# Clone the repo
git clone https://github.com/Adrena1ine-ai/Ghost-Protocol.git
cd Ghost-Protocol
# Install in development mode
pip install -e .
🚀 Quick Start
Three commands. That's it.
# 1. Install the git hook (one time only)
ghost --install
# 2. Start the guardian daemon (run in background)
ghost --ghost
# 3. (Optional) Open the monitor in another terminal
ghost --monitor
Now forget about it. Ghost Protocol handles the rest.
📊 The Monitor
┌──────────────────────────────────────────────────────────────┐
│ 👻 Ghost Protocol v21.0.0 | Status: ACTIVE │
├─────────────────────────────┬────────────────────────────────┤
│ 📊 Project Stats │ 🧠 The Brain │
│ │ │
│ Total Tokens 1,247,832 │ • Writer: IgnoreManager (DRY) │
│ Files Tracked 342 │ • Scanner: Auto-updating (30s)│
│ Est. Cost ($3/M) $3.74 │ • Config: Cached & Valid │
│ │ │
│ │ Press Ctrl+C to exit. │
└─────────────────────────────┴────────────────────────────────┘
⚙️ Configuration
Create ghost_config.json in your project root:
{
"limits": {
"max_asset_size_mb": 1.0,
"max_code_size_mb": 0.5,
"debounce_seconds": 0.5
},
"skip_dirs": ["my_custom_folder", "secrets"],
"extensions": {
"garbage": [".custom", ".mybigfile"],
"code": [".mycode"]
}
}
Default Settings
| Setting | Default | Description |
|---|---|---|
max_asset_size_mb |
1.0 | Auto-ignore assets larger than this |
max_code_size_mb |
0.5 | Warn/block code files larger than this |
debounce_seconds |
0.5 | Wait time before processing file changes |
Pre-configured Skip Directories
venv, .venv, node_modules, __pycache__, .git,
.idea, .vscode, dist, build, coverage, target...
Pre-configured Garbage Extensions
.log, .sqlite, .db, .zip, .mp4, .mp3, .pdf,
.png, .jpg, .gif, .exe, .dll, .bin...
🏗️ How It Works
┌─────────────┐ ┌─────────────┐ ┌─────────────────┐
│ Watchdog │────▶│ Queue │────▶│ IgnoreManager │
│ (Events) │ │ (Debounce) │ │ (Atomic Write) │
└─────────────┘ └─────────────┘ └─────────────────┘
│
▼
┌─────────────┐
│ .gitignore │
│.cursorignore│
└─────────────┘
Key Design Decisions:
- Singleton Config — Thread-safe, cached sets for O(1) lookups
- File Locking — Cross-platform advisory locks (fcntl/msvcrt)
- Atomic Writes — temp file → os.replace() for data integrity
- Fail-Closed — Git hook blocks commit on any error
🧑💻 For Developers
# Project structure
ghost-protocol/
├── main.py # Entry point & CLI
├── requirements.txt # Dependencies
└── src/
├── config.py # Singleton configuration
├── core.py # Logger & console
├── utils.py # Atomic write, file locking
├── watcher.py # File system events → queue
├── scanner.py # Project stats & git integration
├── pruner.py # Cleanup stale ignore entries
├── ignore_manager.py # DRY: single source for ignore logic
└── monitor.py # Rich TUI dashboard
🤝 Contributing
PRs are welcome! Please:
- Fork the repo
- Create a feature branch (
git checkout -b feature/amazing) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing) - Open a Pull Request
🆘 Troubleshooting
Command ghost not found (Windows)
This is a common issue on Windows when Python Scripts folder is not in PATH.
Quick fix - Use Python module instead:
python -m src --install
python -m src --ghost
Permanent fix - Add Scripts to PATH:
-
Find your Scripts folder:
python -c "import site; import os; print(os.path.join(site.getuserbase(), 'Scripts'))"
-
Add to PATH temporarily:
$env:Path += ";C:\Users\YourName\AppData\Roaming\Python\Python314\Scripts"
-
Add to PATH permanently:
- Press
Win + R, typesysdm.cpl, press Enter - Go to Advanced → Environment Variables
- Under User variables, find
Path→ Edit - Click New and add the Scripts path
- Click OK and restart your terminal
- Press
Other Issues
- Not a git repo: Make sure you're in a git repository (
git initif needed) - Import errors: Reinstall with
pip install --upgrade ghost-protocol
📄 License
MIT © 2024 — Do whatever you want with it.
Made for vibe coders, by a vibe coder.
Because life's too short to manually edit .gitignore
⭐ Star this repo if Ghost saved your tokens ⭐
Release files for ghost-protocol 1.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ghost_protocol-1.3.1.tar.gz | 19.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ghost_protocol-1.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 42.5 kB
Release files / ghost_protocol-1.3.1.tar.gz
| Download URL | ghost_protocol-1.3.1.tar.gz |
|---|---|
| Size | 19.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e70490c7cccc0045be51534349b18ae18bedf872d5fe5a8b9e91f506af781d56
|
|
BLAKE2b-256 checksum How to use checksums |
e4007db3f8c3a79973892f188623339f059b301c79fe01b3b9e48431feae3adc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Release files / ghost_protocol-1.3.1-py3-none-any.whl
| Download URL | ghost_protocol-1.3.1-py3-none-any.whl |
|---|---|
| Size | 23.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
04ae981e98b91f931639a4f855b8526e6feaccac2556543f4776fc94c293948e
|
|
BLAKE2b-256 checksum How to use checksums |
e788abc9c06f989003db287aa3839b7ae6364bd32b792a50048be677aa225e53
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|