Forge
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:
- Repository scan — Extracts files, symbols (classes/functions), and dependencies (imports/requires) using parallel regex-based parsers for Python, JS, TS, JSX, and TSX.
- Semantic ranking — Ranks files by TF-IDF query relevance with dependency centrality scoring.
- AST pruning — Uses tree-sitter to prune files to only relevant symbols, keeping context lean.
- Behavior injection — Prepends intensity-gated Ponytail (YAGNI) and Caveman (conciseness) instructions.
- Compression — Collapses whitespace, strips boilerplate, and removes redundant content.
- Caching — Fingerprints repositories and caches context between launches.
- Launch — Sets
FORGE_CONTEXTenv 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
forgecommands 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
cdinto your specific project folder or Git repository before running commands likeforge claude,forge cursor, orforge antigravity.
Interfaces
Forge provides two ways to connect with your AI coding tools:
- Convenience Wrappers (
forge claude,forge cursor,forge codex,forge antigravity) — Automatically prepare context, configure MCP, and launch the target AI CLI. - 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 filteringget_summary— Repository layout, file count, and size summaryget_dependency_graph— Module/file import relationshipsfile_lookup— File contents by relative pathsymbol_lookup— Class/function definitions and locationssemantic_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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file forgeoptimizer-1.0.3.tar.gz.
File metadata
- Download URL: forgeoptimizer-1.0.3.tar.gz
- Upload date:
- Size: 372.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f62b918157e0fb9ff4b563dde22e35774c77c0fcb49a716bc8ef2b75bd1b05b
|
|
| MD5 |
ea105db467beabd81fbcbeb062883432
|
|
| BLAKE2b-256 |
02e5e8e042b73870b6a669d16f318c1468b798be5517d94872778e8cc4d9390c
|
Provenance
The following attestation bundles were made for forgeoptimizer-1.0.3.tar.gz:
Publisher:
ci.yml on mdshzb04/Forge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
forgeoptimizer-1.0.3.tar.gz -
Subject digest:
1f62b918157e0fb9ff4b563dde22e35774c77c0fcb49a716bc8ef2b75bd1b05b - Sigstore transparency entry: 2173971346
- Sigstore integration time:
-
Permalink:
mdshzb04/Forge@6a96dffa652c247e0e03c2b94e1e8770b636340c -
Branch / Tag:
refs/tags/v1.0.3 - Owner: https://github.com/mdshzb04
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@6a96dffa652c247e0e03c2b94e1e8770b636340c -
Trigger Event:
push
-
Statement type:
File details
Details for the file forgeoptimizer-1.0.3-py3-none-any.whl.
File metadata
- Download URL: forgeoptimizer-1.0.3-py3-none-any.whl
- Upload date:
- Size: 341.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
921579ecd8405f64bc9abc8ef80522979dbbcd0123cc05fae30d9ec6a3fea5aa
|
|
| MD5 |
56d034d469e227f1c88e2e37f8a4d101
|
|
| BLAKE2b-256 |
1aad51005c7c7b59b2affe15f24d1dd62e3b48c315c7335d6c24c286187389c0
|
Provenance
The following attestation bundles were made for forgeoptimizer-1.0.3-py3-none-any.whl:
Publisher:
ci.yml on mdshzb04/Forge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
forgeoptimizer-1.0.3-py3-none-any.whl -
Subject digest:
921579ecd8405f64bc9abc8ef80522979dbbcd0123cc05fae30d9ec6a3fea5aa - Sigstore transparency entry: 2173971382
- Sigstore integration time:
-
Permalink:
mdshzb04/Forge@6a96dffa652c247e0e03c2b94e1e8770b636340c -
Branch / Tag:
refs/tags/v1.0.3 - Owner: https://github.com/mdshzb04
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@6a96dffa652c247e0e03c2b94e1e8770b636340c -
Trigger Event:
push
-
Statement type: