Skip to content

Fresh session per task causes redundant project exploration, high token usage #149

@slice-arpits

Description

@slice-arpits

Problem

Each task runs in a completely fresh Claude Code session (claude -p), which means Claude has zero memory of the project between tasks. Every task re-explores the codebase from scratch - reading files, running git log, grepping for patterns, etc.

For a 10-task plan on a medium-sized project, tasks 2-10 each spend a significant chunk of tokens just re-discovering what task 1 already learned about the project structure, key files, and architecture.

Where this happens:

  • pkg/executor/executor.go:174 - fresh claude -p invocation per task
  • pkg/processor/runner.go:336,384 - same prompt sent every iteration, no accumulated context

The plan file and progress file help Claude know what to do next, but they don't help it understand the project itself without re-exploring.

Possible approach

Generate a project context summary (e.g. .ralphex/project-context.md) once at the start of a plan, then include it in subsequent task prompts. Could contain:

  • key directories and their purpose
  • main packages/modules and architecture
  • important file paths
  • patterns and conventions discovered

This would be auto-generated by Claude in a dedicated "exploration" step before task 1, then referenced (not re-discovered) in tasks 2-10. Could cut per-task exploration overhead significantly.

Alternatively, CLAUDE.md partially serves this role if the user maintains it, but most projects don't have one, and it doesn't capture the dynamic context ralphex discovers during execution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions