The Problem

AI coding agents often lose context when asked to implement multi‑file features, producing large, unfocused pull requests that require extensive manual cleanup. Shotgun attempts to keep the agent on‑track by ingesting the whole repository, planning a staged rollout, and emitting precise, file‑by‑file instructions.

What This Does

The core logic lives under src/shotgun/. The CLI entry point src/shotgun/main.py parses commands and hands off to the run routine in src/shotgun/cli/run.py, which orchestrates the autopilot pipeline (src/shotgun/agents/autopilot/*). Specs are modelled in src/shotgun/agents/config/models.py and turned into concrete actions by the router (src/shotgun/agents/router/router.py).

File‑system and code‑base interactions are encapsulated in src/shotgun/codebase/core/manager.py and the various tool modules (e.g., src/shotgun/agents/tools/codebase/*). Test suites in test/ validate each component, while the evals/ package provides deterministic evaluation of generated PRs.

How It Is Wired

Execution starts at src/shotgun/main.py:109 (main). It creates a ConfigManager (called 108 times) and then invokes run (src/shotgun/cli/run.py:28), which reaches 351 functions. The most‑used internal symbols are:

  • exists – referenced from 128 locations.
  • ConfigManager – 108 callers.
  • track_event – 52 callers.

run eventually calls ParallelExecutor (42 callers) to launch stages. Each stage is rendered by src/shotgun/tui/app.py (the TUI entry point) and ultimately triggers filesystem writes via write_report (e.g., main → write_report → Path.parent.mkdir).

The codebase manager (src/shotgun/codebase/core/manager.py) performs the heaviest external work: it reads/writes files, talks to the Neo4j database, and runs cryptographic helpers (46 functions, 3 classes, called from 21 files). The router (src/shotgun/agents/router/router.py) is a hub: 24 modules import it, making it a high‑blast‑radius component.

Import cycles are present in 13 modules, notably evals/models.py, src/shotgun/tui/app.py, and src/shotgun/agents/config/models.py. These cycles increase cognitive load and risk of subtle breakage when refactoring. Deep nesting (max depth 8) appears in src/shotgun/tui/app.py and several agent modules, further complicating maintenance.

How To Use It

# Clone the repository
git clone https://github.com/moses-y/shotgun
cd shotgun

# Install Python dependencies (requires Python 3.11+)
uv sync   # uv reads pyproject.toml; alternatively: pip install -r <(uv pip compile)

# Optional: build the Docker image (uses Dockerfile)
docker build -t shotgun:latest .

# Run the CLI (the primary entry point)
python -m shotgun.main --help

Configuration defaults are provided in .env.example; copy it to .env and adjust any required keys (e.g., API tokens for LLM providers). The TUI can be launched with python -m shotgun.tui.app.

Real‑World Use

A development team using Cursor can invoke Shotgun to generate a feature spec. Shotgun reads the repo, produces a staged plan, and writes a series of PR branches (git checkout -b feature-stage‑1, …). Each PR contains only the files the AI is instructed to modify, dramatically reducing review overhead and preventing accidental deletions.

Code Health & Issues

  • HIGH – Pin third‑party GitHub Actions to commit SHAs (.github/workflows/*).
  • HIGH – Remove continue-on-error from correctness‑gate steps (.github/workflows/installation-tests.yml).
  • HIGH – Stop baking secrets into the Docker image (Dockerfile ARG SHOTGUN_POSTHOG_API_KEY).
  • MEDIUM – Declare least‑privilege GITHUB_TOKEN permissions (.github/workflows/installation-tests.yml).
  • MEDIUM – Pin the base image by digest (Dockerfile python:3.13-slim).
  • MEDIUM – Add a dependency‑vulnerability scan to CI (.github/workflows).
  • MEDIUM – Supply a timeout for outbound requests calls (identified in Dockerfile).
  • MEDIUM – Set persist-credentials: false on checkout steps (.github/workflows/deploy.yml).
  • LOW – Define timeout-minutes on workflow jobs (.github/workflows/deploy.yml).

Additional static findings include 13 import cycles, deep nesting in several modules, duplicated code blocks across the evals/ package, and a few files that open resources without context managers.

The Bottom Line

Shotgun provides a concrete, spec‑driven workflow that can tame AI‑generated code changes, and its modular design (CLI, autopilot, router, codebase manager) is well‑instrumented with tests. However, the codebase suffers from import cycles, deep nesting, and several high‑severity CI/security issues that should be addressed before production use. Teams comfortable with Python and containerized deployments will find the tool usable after the listed hygiene fixes.