Your AI coding assistant that actually writes code, not just explanations!
GhostCoder is a Python tool that connects to your local Ollama server to help you write, modify, and understand code. Unlike other AI assistants that often just explain things, GhostCoder is designed to generate actual code and modify your files directly.
- Python 3.8 or higher
- Ollama installed and running
# 1. Create virtual environment
python3 -m venv venv && source venv/bin/activate
# 2. Install dependencies
pip3 install -r requirements.txt
# 3. Run setup wizard
python ghostcoder.py --setup๐ก Pro tip: Always activate your virtual environment (source venv/bin/activate) before using GhostCoder!
The setup wizard automates everything:
python3 ghostcoder.py --setupWhat it does:
- Detects your shell (zsh or bash)
- Configures environment variables
- Creates
ghostandghostcoderaliases - Updates your shell RC file
- Install Ollama from https://ollama.ai
- Pull a coding model:
ollama pull deepseek-coder:6.7b-instruct
- Set environment variables in your
~/.zshrcor~/.bashrc:export OLLAMA_BASE_URL="http://localhost:11434" export OLLAMA_MODEL="deepseek-coder:6.7b-instruct"
- Create an alias:
alias ghost="python /path/to/ghostcoder.py"
# Generate code
ghost "create a web scraper"
# Modify a specific file
ghost "fix the bug in @main.py"
# Modify multiple files
ghost "add logging to @main.py @utils.py @config.py"
# Force code generation (recommended!)
ghost --code "implement user authentication"
# Auto-apply changes without asking
ghost --skip-confirm "add logging to @utils.py"
# Just get explanations (no code changes)
ghost --no-apply "explain how this function works"The @filename syntax lets you reference files for modification:
# Single file
ghost "add input validation to @app.py"
# Multiple files at once
ghost "add logging to @main.py @utils.py @config.py"
ghost "update error handling in @auth.py @user.py @middleware.py"Multifile Processing: When you reference multiple files, GhostCoder processes each file individually with progress tracking and individual confirmations.
Run ghost without arguments to enter interactive mode:
ghost
# You: add a function to calculate square roots
# Ghost: [generates code]
# You: modify @math.py to use this function
# Ghost: [modifies the file]
# You: exitThe most important feature! Forces GhostCoder to generate actual code instead of explanations:
# Without --code (might just explain)
ghost "implement a calculator"
# With --code (guaranteed to generate code)
ghost --code "implement a calculator"Reference any file in your project for modification:
# Single file modifications
ghost "add error handling to @main.py"
ghost "optimize the algorithm in @utils.py"
# Multiple file modifications
ghost "add logging to @main.py @utils.py @config.py"
ghost "add type hints to @auth.py @user.py @middleware.py"Skip the confirmation prompt:
ghost --skip-confirm "add comments to @script.py"When you only want explanations, not code changes:
ghost --no-apply "explain how this sorting algorithm works"ghost --code "create a function that validates email addresses"Output:
def validate_email(email):
import re
pattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
return re.match(pattern, email) is not Noneghost "add logging to @app.py"GhostCoder will:
- Read your
app.pyfile - Show you the proposed changes
- Ask for confirmation
- Apply the changes if you approve
ghost
# You: create a simple web server
# Ghost: [generates Flask server code]
# You: add error handling to it
# Ghost: [modifies the code with error handling]
# You: exit- Use
python3instead ofpythonon macOS/Linux - Make sure Python 3.8+ is installed:
python3 --version
- Solution: Always use a virtual environment:
python3 -m venv venv source venv/bin/activate pip install -r requirements.txt
- Make sure Ollama is running:
ollama serve - Check the URL:
curl http://localhost:11434
- Use the
--codeflag:ghost --code "your request" - Be more specific:
ghost --code "write a function that..."
- Always activate your virtual environment before running GhostCoder
- Never install packages globally with pip
- Keep your virtual environment in the project directory
GhostCoder maintains a fun, spooky theme:
- ๐ป "Spectral changes" = file modifications
- ๐ฎ "Interactive sรฉance" = interactive mode
- ๐ "Banish the ghost" = exit command
- โจ "Manifested changes" = successful file updates
Feel free to contribute improvements! The ghost is always learning new tricks.
Happy coding with your spectral assistant! ๐ปโจ