Skip to main content

AI-powered coding assistant optimized for local LLMs

Project description

PocketCoder

PyPI version Python 3.10+ License: MIT

CLI coding assistant supporting Ollama, OpenAI, Claude.

Features session persistence, multi-step task planning, project-aware context (RepoMap), and interactive file editing with human-in-the-loop approval.

PocketCoder CLI


Quick Start

pip install pocketcoder
pocketcoder
With Ollama (free, local)
# Install Ollama: https://ollama.com
ollama pull qwen2.5-coder:7b
pocketcoder
With OpenAI
export OPENAI_API_KEY="sk-..."
pocketcoder --provider openai --model gpt-4o

Key Features

  • Multi-provider — Ollama, OpenAI, Anthropic, vLLM, LM Studio
  • Session memory — agent remembers context across requests
  • Task planning — TODO tracking with automatic breakdown
  • RepoMap — project structure awareness for better context
  • Human-in-the-loop — approve/reject every file change
  • Offline capable — works fully local with Ollama

Demo: Building a Calculator

Ask PocketCoder to create a GUI calculator — it plans, asks clarifying questions, writes code, and runs it:

Agent asks clarifying question

Agent reasons about the task and asks what type of calculator you need

Code preview before writing

Shows code preview before writing — you approve with [y] or skip with [n]

Working calculator

Result: working tkinter calculator created and executed


Features

Session Memory

Agent remembers what you're working on across requests. No need to re-explain context.

Project Awareness

RepoMap shows your codebase structure to the LLM. Agent knows your file layout.

Multi-step Tasks

TODO tracking with automatic planning. Agent breaks complex tasks into steps.

SESSION_CONTEXT

SESSION_CONTEXT: what the LLM sees about your project

Human-in-the-loop

Every file write requires your approval. Ask questions, reject changes, cancel tasks.

Task control

Full control: reject changes, explain why, cancel entire task


Architecture

PocketCoder Architecture

How the Agent Loop works
  1. Task Initialization — TaskSummarizer captures your goal
  2. Reconnaissance Rule — READ before WRITE, never blind edits
  3. RepoMap — Automatic codebase structure (gears by project size)
  4. Tool Execution — Execute tools, get raw results
  5. ContentPreview — Smart summarization (LLM sees actual code)
  6. State Tracking — FileTracker + TodoStateMachine
  7. Episodic Memory — Checkpoint progress, search history
  8. SESSION_CONTEXT — XML with files, task, repo_map, todo, history
  9. REFLECT prompt — Self-check before next iteration
  10. Parser — Auto-sync KNOWN_TOOLS with available tools

Commands

Type / to see all commands:

Commands menu

Command Description
/help Show available commands
/model Switch LLM model
/add <file> Add file to context
/drop <file> Remove file from context
/files List files in context
/undo Undo last file change
/clear Clear conversation history
/quit Exit

Supported Providers

Provider Type Setup
Ollama Local ollama serve then ollama pull model
OpenAI Cloud Set OPENAI_API_KEY
Anthropic Cloud Set ANTHROPIC_API_KEY
vLLM Local/Cloud Any OpenAI-compatible endpoint
LM Studio Local Run server, point to localhost

Recommended Models

For local use with 16GB+ RAM:

Model Size Speed Quality
qwen2.5-coder:7b 4.7GB Fast Good
qwen2.5-coder:14b 9GB Medium Better
deepseek-coder:6.7b 4GB Fast Good
codellama:13b 7GB Medium Good

Configuration

Config stored in ~/.pocketcoder/config.yaml:

provider:
  type: ollama
  base_url: http://localhost:11434
  default_model: qwen2.5-coder:7b

thinking:
  mode: smart           # smart | always | never
  show_reasoning: true  # show agent's thinking process

Project Structure

PocketCoder stores session data in .pocketcoder/ directory:

.pocketcoder/
  project_context.json  # Current session state
  episodes.jsonl        # Conversation history
  memory.json           # Long-term facts

Development

git clone https://github.com/Chashchin-Dmitry/pocketcoder.git
cd pocketcoder
pip install -e ".[dev]"
pytest

Support the Project

If PocketCoder saves you money on AI subscriptions, consider supporting development:

Network Address
ETH / USDT (ERC-20) 0xdF5e04d590d44603FDAdDb9f311b9dF7E5dE797c
BTC bc1q3q25vw4jm8v4xe2g6uezq35q2uyn5jt6e00mj9
USDT (TRC-20) TQj3X5nFQWqPEmRUWNFPjkaRUUFLxmCdok
SOL 5s5uP66VmnLMSApjq8ro639tXvSp59XEwQittzxF64mF

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pocketcoder-1.0.2.tar.gz (5.9 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pocketcoder-1.0.2-py3-none-any.whl (181.0 kB view details)

Uploaded Python 3

File details

Details for the file pocketcoder-1.0.2.tar.gz.

File metadata

  • Download URL: pocketcoder-1.0.2.tar.gz
  • Upload date:
  • Size: 5.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.2

File hashes

Hashes for pocketcoder-1.0.2.tar.gz
Algorithm Hash digest
SHA256 0bf733ff00e93a78f57039ef991cb495a2fd9b72cc73f9881e0a8968fcb234a1
MD5 31495e719b1c75b55806c3dcaeb9d307
BLAKE2b-256 7f353bc24500a7ecee339949293fb4472395e10e5c688d893f8b9a93beb2cf88

See more details on using hashes here.

File details

Details for the file pocketcoder-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: pocketcoder-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 181.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.2

File hashes

Hashes for pocketcoder-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 77e42fa540570d6584a3d1d38c568fd8f96de0727cf8cfc9efd2450c21e84267
MD5 e3615e1e01198ba074b45c1ef6750f94
BLAKE2b-256 ae607445dd559003e9dd068b8ff5008931d388f57141ec6bc418ef801e393b98

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page