Standalone AI CLI for repositories that contain a .ai/ directory.
Forge turns a repo-local .ai workspace into a usable terminal workflow for planning, execution, fixing, review, and prompt inspection. It discovers the target repository automatically, assembles prompts in a fixed context order, and invokes Codex through a dedicated runner.
Most AI-assisted repo workflows start as shell scripts glued to prompt files. That works at first, then breaks down when you need:
- a stable command interface
- reusable behavior across multiple repositories
- deterministic prompt assembly
- backward compatibility for existing task files
- prompt debugging without invoking the model
Forge is the standalone layer that sits on top of .ai/ and handles that orchestration.
- Standalone CLI for any repository that contains
.ai/ - Automatic repository root detection by walking upward to
.ai/ - Deterministic prompt assembly for task-based workflows
- Centralized prompt builder shared by
plan,run,fix,review, andprompt - Per-invocation caching for heavy context files
- Backward compatibility with existing markdown task files
- Interactive and non-interactive Codex execution modes for task commands
- Prompt debugging via
--print-prompt,--save-prompt, andforge prompt - Self-hosted
.aiworkspace in this repository for developing Forge with Forge
git clone <your-repo-url>
cd forge-cli
go build -o forge ./cmd/aigo build -o forge ./cmd/ai
sudo mv ./forge /usr/local/bin/forge- Go 1.24.3+
- Codex CLI available on
PATH - A target repository containing
.ai/
go build -o forge ./cmd/aiForge does not require you to run commands from the repo root. It walks upward from the current directory until it finds .ai/.
cd /path/to/your/repoIf .ai/ is not found, Forge returns:
AI context directory (.ai) not found
forge plan feature_exampleforge run feature_example
forge run feature_example --mode execforge fix feature_example --error "undefined: builder"
forge fix feature_example --error "test is failing" --mode execforge review
forge review --staged
forge review internal/context/builder.goforge prompt feature_example
forge --print-prompt run feature_example
forge --save-prompt /tmp/feature_example.prompt run feature_exampleLoads the task and repository context, assembles the planning prompt, and invokes Codex.
forge plan feature_transaction_historyBuilds the execution prompt for a task and invokes Codex in the selected mode.
forge run feature_transaction_history
forge run feature_transaction_history --mode execBuilds a fix prompt using the task context plus an explicit error message.
forge fix feature_transaction_history --error "panic: nil pointer dereference"Builds a review prompt using either:
- the current worktree diff
- the staged diff
- an explicit path target
forge review
forge review --staged
forge review internal/task/task.goPrints the fully assembled prompt without invoking Codex.
forge prompt feature_transaction_historyStarting from the current working directory, Forge walks upward until it finds:
.ai/
That directory becomes the target repository root.
Forge reads task files from:
.ai/tasks/<task>.md
It supports:
- explicit front matter metadata
- legacy markdown task files
- fallback filename-prefix routing when metadata is missing
Supported fallback prefixes:
feature_*fix_*refactor_*test_*
All prompt construction goes through one builder pipeline. For task-based flows, Forge assembles prompts in this exact order:
- task context
feature-map.mdsymbol-map.mdrepomap.mdfile-index.mdarchitecture.mdframework-go-core.mdengineering-rules.mdownership.md- prompt template
This ordering is deterministic.
Forge caches these files for the lifetime of a single CLI invocation:
feature-map.mdrepomap.mdsymbol-map.md
There is no persistent on-disk cache in the current version.
All Codex CLI execution goes through a runner abstraction that handles:
- command argument construction
- interactive vs exec mode
- prompt delivery via direct argument, stdin, or temp file
- structured execution results
Forge expects a target repository to contain a structure like:
.ai/
context/
architecture.md
engineering-rules.md
feature-map.md
file-index.md
framework-go-core.md
ownership.md
repomap.md
symbol-map.md
prompts/
breakdown.md
execute.md
fix.md
review.md
test.md
tasks/
template.md
feature_example.md
This repository includes its own .ai workspace so Forge can run against forge-cli itself.
go test ./...If your environment has a read-only default Go build cache, use:
GOCACHE=/tmp/forge-go-build go test ./...go build -o forge ./cmd/ai./forge prompt feature_self_host_workspace
./forge plan feature_self_host_workspaceforge-cli/
cmd/ai
internal/
app/
cli/
codex/
context/
repo/
task/
pkg/forge/
.ai/
Package responsibilities:
cmd/ai: binary entrypointinternal/cli: command and flag parsinginternal/app: application orchestrationinternal/repo: repository root detectioninternal/task: task parsing and compatibilityinternal/context: context loading and prompt buildinginternal/codex: Codex runner abstractionpkg/forge: shared public types
Forge currently focuses on:
- local terminal workflows
- task-based prompt assembly
- Codex CLI orchestration
It is designed to grow into:
- CI integration
- multi-service awareness
- PR automation
- richer agent workflows
forge reviewcurrently runs in the interactive review flow.forge promptis the safest way to inspect prompt output while developing.aicontent.- The current README documents the implemented command surface, not planned future subcommands.