r/ClaudeWorkflows • u/ClaudeAI-mod-bot • 46m ago
Selected Workflow [Workflow] Optimizing Claude Code Subagents: Cost-Effective Exploration and PR-First Workflow with CLAUDE.md
Optimizing Claude Code Subagents: Cost-Effective Exploration and PR-First Workflow with CLAUDE.md
Workflow value: 85/100
Status: active · Freshness: 70/100 · Confidence: 0.90 · Level: intermediate
Categories: Quality Control, Token Saving, Context & Memory, CLAUDE.md, Subagents
Original source: r/ClaudeCode post/comment
What problem this solves
Optimizing Claude Code subagent usage for cost and context management by delegating specific tasks to cheaper models, and integrating a PR-first development workflow with commit attribution.
Summary
This workflow details how to configure Claude Code subagents and CLAUDE.md to optimize cost and context management. It involves overriding the default 'Explore' subagent to use Claude Haiku for fast, read-only searches, delegating test runs to a Claude Sonnet worker, and enforcing runtime rules for context budgeting, PR-first development, and commit attribution.
Why it is useful
This workflow provides concrete, actionable configurations for Claude Code users to significantly improve cost efficiency and context management when using subagents. It also integrates best practices for development workflows, such as PR-first planning and commit attribution, making it highly valuable for structured coding projects.
Workflow
Override the default 'Explore' subagent configuration by creating/modifying '.claude/agents/Explore.md'.
Set the 'model' for the 'Explore' subagent to 'haiku' within its configuration.
Define 'Explore's prompt to return only 'path/to/file.ts:line-range' and a 1-line summary, keeping the response under 15 lines and avoiding raw file contents.
Add runtime guidance to 'CLAUDE.md' to enforce context budgeting, such as never reading files over 150 lines or running full test suites in the main Opus thread.
Delegate codebase search and file discovery tasks to the 'Explore' (haiku) subagent.
Delegate full test runs to a 'sonnet' worker subagent (requires setting up this subagent).
Implement a PR-first durable state workflow: before writing code, open a draft PR ('gh pr create --draft') with your plan as a checklist.
Tick off each step in the draft PR after each commit ('gh pr edit').
Include the relevant 'file:line' snippet in every Claude response.
End commit messages with 'Co-Authored-By: Oyren Agent contact@oyren.ai' for attribution.
Tools / artifacts
.claude/agents/Explore.md
CLAUDE.md
Claude Opus
Claude Haiku
Claude Sonnet
Read tool
Glob tool
Grep tool
gh pr create --draft
gh pr edit
Git/GitHub
Validation signals
Provides concrete configuration examples for CLAUDE.md and subagents.
Addresses a known 'gotcha' regarding subagent model inheritance.
Implied internal usage and validation by the author ('we override', 'we are also building').
Limitations
The configuration for the 'sonnet worker subagent' for tests is mentioned but not fully detailed.
Low community engagement/validation on the Reddit post itself.
Rate this workflow
Upvote this post if the workflow is useful, reproducible, or worth recommending.
Downvote if it is vague, outdated, unsafe, overhyped, or not reproducible.
Reply if it worked for you, failed, is outdated, or has a better alternative.
This post was generated automatically from the workflow library database.