Skip to main content

Overview

Forge creates a specific directory structure to organize tasks, worktrees, configuration, and data. Understanding this structure helps you work effectively with Forge.

Directory Structure

Always add .forge/ to .gitignore! This directory contains:
  • API keys and secrets
  • Local database
  • Temporary worktrees
  • Execution logs

The .forge/ Directory

Configuration Files

file
Main configuration file containing LLM settings, OAuth tokens, and preferences
file
SQLite database storing:
  • Projects and tasks
  • Task attempts and results
  • Execution history
  • User preferences
This file is created automatically on first run. Backup regularly if you want to preserve history!

Worktrees Directory

directory
Contains Git worktrees for each task attempt
Each worktree is a complete copy of your repository at a specific commit, isolated from your main branch.
directory
Execution logs for debugging and audit trail

Git Worktrees Explained

What Are Worktrees?

Git worktrees allow multiple working directories from the same repository. Forge uses this for task isolation.

Why Worktrees?

Complete Isolation

Each task works in its own environment - no conflicts!

Parallel Execution

Run multiple AI agents simultaneously on different tasks

Safe Experimentation

Try risky changes without affecting your main codebase

Easy Comparison

Compare different approaches side-by-side

How It Works

1

Create Task

You create a task in Forge: “Add user authentication”
2

Forge Creates Worktree

Creates a complete copy of your repo at current commit
3

AI Works in Isolation

Claude modifies files in .forge/worktrees/task-1-auth/Your main directory is untouched
4

Review Changes

Compare worktree with main branch:
5

Merge When Ready

If you approve:

Database Schema

The .forge/forge.db SQLite database contains:

Projects Table

Tasks Table

Attempts Table


Backup & Restore

Backing Up Forge Data

Restoring From Backup

Restoring worktrees requires active Git branches. Usually better to just restore config and database.

Cleanup & Maintenance

Clean Old Worktrees

Clean Old Logs

Compact Database

Complete Clean

This deletes all task history, configurations, and worktrees. Backup first!

Multi-User Scenarios

Personal Projects

Standard setup - one developer, one Forge instance

Team Projects

Each team member has their own .forge/ directory:
Add .forge/ to .gitignore so team members don’t conflict

Shared Forge Instance (Advanced)

For teams sharing one Forge deployment:

Best Practices

Version Control .gitignore

.gitignore

Document Structure

Add a README explaining Forge setup:

Regular Backups

Clean Worktrees

Let Forge auto-cleanup, or manually:

Troubleshooting

Error: “fatal: ‘task-1’ is already checked out at ‘.forge/worktrees/task-1’”Solution:
Error: “database is locked”Solution:
  • Close all Forge instances
  • Check for zombie processes: ps aux | grep forge
  • Kill if needed: pkill -f forge
  • Restart Forge
Error: “Configuration file not found”Solution:
Error: “No space left on device”Solution: Worktrees accumulate. Clean them:

Next Steps

Creating Tasks

Learn how to create and manage tasks

Git Worktrees

Deep dive into worktree concepts

Environment Variables

Advanced configuration options

CLI Reference

Command-line interface guide