Skip to main content

Add your description here

Project description

erk

erk is a CLI tool for plan-oriented agentic engineering.

For the philosophy and design principles behind erk, see The TAO of erk.

User Setup

Prerequisites

Ensure you have these tools installed:

  • python (3.10+)
  • claude - Claude Code CLI
  • uv - Fast Python environment management
  • gt - Graphite for stacked PRs
  • gh - GitHub CLI

Initialize Erk

erk init

This command:

  • Prompts for worktrees root directory (where all worktrees are stored)
  • Creates global config at ~/.erk/config.toml
  • Detects Graphite (gt) availability for branch creation
  • Creates repo-specific config.toml with preset selection (auto, generic, dagster)
  • Offers to add .env, .erk/scratch/, and .impl/ to .gitignore
  • Shows shell integration setup instructions (completion + auto-activation)

Shell Integration

erk init will display shell integration instructions to add to your .zshrc or .bashrc. Copy these instructions manually - erk doesn't modify your shell config automatically.

Why manual setup? Shell integration is essential for the core workflow: it enables commands such as erk br co and erk wt co to change your terminal's directory and activate the correct Python environment. Without it, these commands run in a subprocess and have no effect on your shell. We ask you to add it manually so you stay in control of your shell configuration.

To view the instructions again later: erk init --shell

Or append directly:

erk init --shell >> ~/.zshrc  # or ~/.bashrc

Verify Setup

Run the doctor command to verify your environment:

erk doctor

This checks that all prerequisites are installed and configured correctly.

Local Plan-Driven Workflow

The primary workflow: create a plan, save it, implement it, ship it. Often completes without touching an IDE.

Planning Phase

  1. Start a Claude Code session:

    claude
    
  2. Enter plan mode and develop your plan

  3. Save plan to GitHub issue (system prompts automatically after plan mode)

Implementation

  1. Execute the plan:

    erk implement <issue-number>
    

    This creates a worktree, activates the environment, and runs Claude Code with the plan.

PR Submission

  1. Submit the PR:

    erk pr submit
    

    Or from within Claude Code: /erk:pr-submit

Code Review Iteration

  1. Review PR feedback in GitHub

  2. Address feedback:

    /erk:pr-address
    
  3. Repeat until approved

Landing

  1. Merge and clean up:
    erk pr land
    

Note: This entire workflow—from planning through shipping—can happen without opening an IDE. You create plans, submit code, review feedback in GitHub, address it via Claude Code, and land.

Iteration Patterns

Quick Iteration

For rapid commits within a worktree:

/quick-submit

Commits all changes and submits with Graphite.

Rebasing and Stack Management

When your stack needs rebasing:

erk pr auto-restack --dangerous

Or from Claude Code: /erk:auto-restack

To fix merge conflicts during a rebase:

/erk:fix-conflicts

Common Workflows

Auto-Restack: Intelligent Conflict Resolution

When working with stacked PRs, rebasing is a frequent operation. erk pr auto-restack automates this process with intelligent conflict resolution.

What it does:

  1. Runs gt restack to rebase your stack onto the latest trunk
  2. If conflicts occur, launches Claude Code with the /erk:fix-conflicts command
  3. After resolution, automatically continues the restack process
  4. Repeats until the entire stack is cleanly rebased

Basic usage:

erk pr auto-restack --dangerous

From within Claude Code:

/erk:auto-restack

Note: The --dangerous flag acknowledges that auto-restack invokes Claude with --dangerously-skip-permissions.

When to use it:

  • After merging a PR that's below yours in the stack
  • When trunk has been updated and you need to incorporate changes
  • When Graphite shows your stack needs rebasing
  • After running erk pr land on a parent branch

How conflict resolution works:

When conflicts are detected, erk spawns a Claude Code session that:

  1. Identifies all conflicting files
  2. Analyzes the nature of each conflict (content vs import conflicts)
  3. Resolves conflicts while preserving the intent of both changes
  4. Stages resolved files and continues the rebase

Example scenario:

trunk ← feature-a ← feature-b ← feature-c (you are here)

If feature-a merges into trunk, running erk pr auto-restack --dangerous will:

  1. Rebase feature-b onto the new trunk
  2. Resolve any conflicts (with Claude's help if needed)
  3. Rebase feature-c onto the updated feature-b
  4. Resolve any conflicts at this level too

The result: your entire stack is cleanly rebased with minimal manual intervention.

Checkout PR from GitHub

When reviewing or debugging a PR—whether from a teammate or a remote agent run—you can check it out directly using the PR number or URL from the GitHub page.

Basic usage:

# Using PR number
erk pr checkout 123

# Using GitHub URL (copy directly from browser)
erk pr checkout https://github.com/owner/repo/pull/123

This creates a local worktree for the PR branch and changes your shell to that directory.

Syncing with Graphite:

After checkout, sync with Graphite to enable stack management:

erk pr sync --dangerous

This registers the branch with Graphite so you can use standard gt commands (gt pr, gt land, etc.).

Note: The --dangerous flag acknowledges that sync invokes Claude with --dangerously-skip-permissions.

Complete workflow:

# 1. Checkout the PR (copy URL from GitHub)
erk pr checkout https://github.com/myorg/myrepo/pull/456

# 2. Sync with Graphite
erk pr sync --dangerous

# 3. Now iterate normally
claude
# ... make changes ...
/quick-submit

# 4. Or land when approved
erk pr land

When to use it:

  • Reviewing a teammate's PR locally
  • Debugging a PR created by remote agent execution
  • Taking over a PR that needs local iteration
  • Running tests or making fixes on someone else's branch

Documentation Extraction

Erk supports extracting reusable documentation from implementation sessions into the docs/learned/ folder—a directory of agent-generated, agent-consumed documentation.

This documentation:

  • Captures patterns discovered during implementation
  • Gets loaded by future agent sessions via AGENTS.md routing
  • Builds institutional knowledge over time

To extract documentation from a session:

/erk:create-extraction-plan

Remote Execution

For sandboxed, parallel execution via GitHub Actions:

  1. Create a plan (via Claude Code plan mode)

  2. Submit for remote execution:

    erk plan submit <issue-number>
    

The agent runs in GitHub Actions and creates a PR automatically.

Debugging Remote PRs

When a remote implementation needs local iteration:

erk pr checkout <pr-number>
erk pr sync --dangerous

This checks out the PR into a local worktree for debugging and iteration.

Planless Workflow

For smaller changes that don't require formal planning:

  1. Create a worktree:

    erk wt create <branch-name>
    
  2. Iterate normally in Claude Code

  3. Submit PR:

    erk pr submit
    
  4. Merge and clean up:

    erk pr land
    

File Locations

Location Contents
.erk/ Erk configuration, scratch storage, session data
.impl/ Implementation plans (at worktree root)
.claude/ Claude Code commands, skills, hooks

Gitignore

erk init automatically adds these entries to your .gitignore. If you ran erk init, this is already configured:

.erk/scratch/
.impl/

.impl/ contains temporary implementation plans that shouldn't be committed. .erk/scratch/ holds session-specific working files.

Plan Mode GitHub Integration

By default, erk modifies Claude Code's plan mode behavior. When you exit plan mode, erk prompts you to save the plan to GitHub as an issue before proceeding. This enables the plan-driven workflow where plans become trackable issues that can be implemented via erk implement <issue-number>.

To disable this behavior and use standard Claude Code plan mode:

erk config set github_planning false

To re-enable:

erk config set github_planning true

When disabled, exiting plan mode works exactly as it does in standard Claude Code.

Project details


Download files

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

Source Distribution

erk-0.4.4.tar.gz (1.9 MB view details)

Uploaded Source

Built Distribution

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

erk-0.4.4-py3-none-any.whl (584.4 kB view details)

Uploaded Python 3

File details

Details for the file erk-0.4.4.tar.gz.

File metadata

  • Download URL: erk-0.4.4.tar.gz
  • Upload date:
  • Size: 1.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for erk-0.4.4.tar.gz
Algorithm Hash digest
SHA256 d3b8992a182c9d3b4a1475d029462ed5a5b7ac46279aeffb5ebe04208538c357
MD5 26e5aa232709e51494d2d1ece9b44fc3
BLAKE2b-256 99a08314f8aeca46c10ca71de24bb29a4c7fad7b14d09cddbc79c4f5c57721ca

See more details on using hashes here.

File details

Details for the file erk-0.4.4-py3-none-any.whl.

File metadata

  • Download URL: erk-0.4.4-py3-none-any.whl
  • Upload date:
  • Size: 584.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for erk-0.4.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d7b7516fd919b24509d9de1613954719365939549ff3593d3bd4e944f5eca65f
MD5 3fa29367abdd0bd3b4b926e864b6bb39
BLAKE2b-256 b8c0a0ad0cba94dd6b17069726368aefe7209ea2e614e172c66693a0b14f7b68

See more details on using hashes here.

Supported by

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