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.

To upgrade an existing installation to get the latest optimization fixes:

uv tool upgrade forgeoptimizer

Important Usage Guidelines

[!IMPORTANT] Always run commands inside your specific project directories.

Forge scans the files in your current working directory to build context.

  • Do not run forge commands inside your home directory (~) or root (/), as this will cause Forge to scan all unrelated system/home directories and files, leading to long scans or freezes.
  • Always cd into your specific project folder or Git repository before running commands like forge claude, forge cursor, or forge antigravity.

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.4.tar.gz (372.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.4-py3-none-any.whl (342.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: forgeoptimizer-1.0.4.tar.gz
  • Upload date:
  • Size: 372.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.4.tar.gz
Algorithm Hash digest
SHA256 548ff73a2aac9bbc3a253933f89da23f4835db573fbb0811a2320d9497081975
MD5 dc07b4bd7515f5a7d874df13cf5c339a
BLAKE2b-256 dd7ae08d2a2f25706acffe848679f0ce4c99b72e50d009c7806937d1020d62e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for forgeoptimizer-1.0.4.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.4-py3-none-any.whl.

File metadata

  • Download URL: forgeoptimizer-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 342.0 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f168dc2e0a814d0e02f07c016f8dbe1680eb65c4152c651c67727cbf89008cca
MD5 2d0ca492e3bb2afc168777e583793766
BLAKE2b-256 12f5758f58f7630aceede09b369f40cd1839e04d2bae7c30a30bb7e6128df2d4

See more details on using hashes here.

Provenance

The following attestation bundles were made for forgeoptimizer-1.0.4-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