Skip to main content

Forge

CI Status PyPI Version Supported Python Versions License: MIT Code Style: Ruff

Forge is a pre-launch context preparation tool for AI coding assistants. Before you run claude, codex, or cursor, Forge scans your repository, extracts symbols and dependencies, builds a structured summary, injects configurable behavior instructions, and passes the optimized context to the AI tool through environment variables and MCP tools.

Core Philosophy

[!IMPORTANT] Forge optimizes what it controls.

Forge focuses on three areas:

  • Repository Intelligence — Symbol extraction, dependency analysis, file scanning, and native graph generation.
  • Behavior Optimization — Configurable implementation guidance (Ponytail YAGNI rules) and response style optimization (Caveman conciseness rules).
  • Runtime Infrastructure — Zero-configuration wrappers, context caching, background daemon, and MCP server.

Forge prepares context before the AI session begins. It does not modify provider billing, quota accounting, model pricing, model inference, or the AI client's internal tool selection logic.

Architecture

Forge has a single unified context preparation path used by all wrappers:

  1. Repository scan — Extracts files, symbols (classes/functions), and dependencies (imports/requires) using parallel regex-based parsers for Python, JS, TS, JSX, and TSX.
  2. Semantic ranking — Ranks files by TF-IDF query relevance with dependency centrality scoring.
  3. AST pruning — Uses tree-sitter to prune files to only relevant symbols, keeping context lean.
  4. Behavior injection — Prepends intensity-gated Ponytail (YAGNI) and Caveman (conciseness) instructions.
  5. Compression — Collapses whitespace, strips boilerplate, and removes redundant content.
  6. Caching — Fingerprints repositories and caches context between launches.
  7. Launch — Sets FORGE_CONTEXT env var and starts the AI CLI.

Advanced Graph

The native builder works out of the box with no extra setup. For the advanced graph (Leiden clustering and LLM-powered analysis), Forge will automatically detect and install the external graphify tool and its required provider dependencies when you run the build command.

You only need to configure your API key and run the command:

# 1. Provide an API key for your provider
export ANTHROPIC_API_KEY="your-key-here"

# 2. Build the graph (Forge automatically manages the graphify installation)
forge graph build

Installation

uv tool install forgeoptimizer

The CLI entrypoint is forge.


Interfaces

Forge provides two ways to connect with your AI coding tools:

  1. Convenience Wrappers (forge claude, forge cursor, forge codex, forge antigravity) — Automatically prepare context, configure MCP, and launch the target AI CLI.
  2. MCP Server (forge mcp) — Standard stdio JSON-RPC interface exposing 6 tools that AI clients can call during sessions.

Command Reference

Command Description
forge claude Launch Claude Code with optimized context
forge codex Launch Codex CLI with optimized context
forge cursor Launch Cursor CLI with optimized context
forge antigravity Launch Antigravity CLI with optimized context
forge commit Generate a Conventional Commit message from staged changes
forge mcp Start the stdio MCP server
forge start Start the background daemon
forge graph build Build a codebase graph (native or external)
forge config Configure optimization profiles
forge status Show repository, daemon, and optimization status
forge doctor Verify installation and dependencies
forge inspect Display active pipeline and optimization stages
forge stats Show cache metrics and pipeline performance
forge profile View or set optimization profiles
forge explain Explain pipeline stages, concepts, or topics
forge --version Show version

Use --refresh to bypass the cache on any wrapper command:

forge claude --refresh

MCP Tools

Forge exposes 6 tools over MCP:

  • get_optimized_context — Full optimized repository context with optional query filtering
  • get_summary — Repository layout, file count, and size summary
  • get_dependency_graph — Module/file import relationships
  • file_lookup — File contents by relative path
  • symbol_lookup — Class/function definitions and locations
  • semantic_search — Keyword search across codebase chunks

[!IMPORTANT] Forge exposes these tools, but whether they are called depends on the AI client's internal orchestration. Forge does not control tool selection.


Environment Variables

Variable Purpose
FORGE_CONTEXT Optimized pre-launch context text
FORGE_CONTEXT_FILE Path to the cached context file
FORGE_REPO_ROOT Detected repository root

Development

git clone https://github.com/mdshzb04/Forge
cd Forge
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest
ruff check forgecli tests

License

MIT

Download files

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

Source Distribution

forgeoptimizer-1.0.1.tar.gz (371.3 kB view details)

Uploaded Source

Built Distribution

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

forgeoptimizer-1.0.1-py3-none-any.whl (341.1 kB view details)

Uploaded Python 3

File details

Details for the file forgeoptimizer-1.0.1.tar.gz.

File metadata

  • Download URL: forgeoptimizer-1.0.1.tar.gz
  • Upload date:
  • Size: 371.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for forgeoptimizer-1.0.1.tar.gz
Algorithm Hash digest
SHA256 6834d64e05a2efc8c195cc3c94991dbfc58d1203f3a189d22e80062f1235cf14
MD5 e50548aed0c40be0426b0d6fee81003f
BLAKE2b-256 ed34aa151744fa18a95b2ecef28628989405c083c73f4bf40018a546f95dba57

See more details on using hashes here.

Provenance

The following attestation bundles were made for forgeoptimizer-1.0.1.tar.gz:

Publisher: ci.yml on mdshzb04/Forge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file forgeoptimizer-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: forgeoptimizer-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 341.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for forgeoptimizer-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 86f0ee7c3559f18e8600bea034bf911e8b62cb4392e834c65baa7bdb9fcd3ec0
MD5 ebd7bd2e1b606131b003f7fc1a97f41e
BLAKE2b-256 c33b254cc7ce5c8be6fd149933230518352a51fa759f0a9a4678e17be011a089

See more details on using hashes here.

Provenance

The following attestation bundles were made for forgeoptimizer-1.0.1-py3-none-any.whl:

Publisher: ci.yml on mdshzb04/Forge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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