Every Claude Code Workflow Explained (& When to Use Each)
How to Use Claude Code Effectively
Introduction to Claude Code
- The video emphasizes that using Claude Code in a linear fashion (one conversation at a time) is inefficient. It suggests leveraging its capabilities for parallel task management.
- Viewers will learn five methods to optimize their use of Claude Code, transitioning from simple setups to fully automated workflows.
Built-in Sub Agents
- Claude Code operates with three built-in sub agents: Explore, Plan, and General Purpose, which function automatically without user prompts.
- The Explore agent acts as a read-only scout that can search files and folder structures but cannot modify them. It helps maintain clean conversations by summarizing relevant information.
- The Plan agent activates in plan mode (using /plan or shift tab twice), researching the codebase before presenting strategies while remaining read-only.
- The General Purpose agent performs complex tasks requiring both reading and writing across multiple files, handling heavy lifting automatically based on task complexity.
Pattern One: Sequential Flow
- In sequential flow, each task builds upon the previous one within a single session. This method allows for cumulative context development over time.
- Tasks can be interdependent; outputs from earlier tasks inform subsequent ones. However, this approach risks "context rot" if too much information accumulates beyond the context window's capacity.
Managing Context
- To mitigate context rot, structured skills and commands are essential. Using well-defined claude.md files helps manage references effectively during sessions.
- Commands like /clear and /compact assist in maintaining concise summaries of ongoing conversations.
Pattern Two: Operator Mode
- In operator mode, users act as orchestrators by opening multiple terminal windows with separate instances of Claude Code. Each instance functions independently with its own context window.
- This setup allows for specific contexts tailored to individual tasks, enhancing efficiency when managing complex projects like building a SaaS application.
How to Manage Multiple Tasks in Claude
Orchestrating Independent Tasks
- The speaker discusses the ability to manage multiple independent tasks simultaneously without them interfering with each other, using separate terminals for each task.
- Demonstrates opening three terminals in VS Code for different tasks: onboarding flow, checkout bug fix, and user settings redesign.
- Each terminal operates as a work tree, providing isolated environments that prevent context interference among tasks.
Coordinating Efforts
- The operator coordinates between different terminals, checking progress and merging completed tasks back into the main project.
- Highlights the efficiency of parallel task management compared to sequential workflows; however, dependent tasks cannot be managed this way.
Closing Work Trees
- When closing a work tree session, Claude automatically handles cleanup. If changes are made, it prompts the user for action regarding workspace retention.
- Emphasizes the operator's role in managing multiple sessions while noting limitations on how many terminals can be effectively monitored at once.
Exploring Advanced Task Management with Split and Merge
Introducing Split and Merge Pattern
- The split and merge pattern allows a single Claude session to split work across multiple sub-agents running in parallel.
- This method enables more efficient task completion by breaking down larger tasks into smaller independent pieces handled by sub-agents.
Functionality of Sub-agents
- When given a complex task (e.g., researching competitors), Claude can create several sub-agents that operate independently but report back to the main agent.
- Each sub-agent works on its specific piece of research simultaneously, allowing for faster overall completion compared to sequential processing.
Limitations of Sub-agents
- While up to 10 sub-agents can run concurrently, they cannot communicate with one another; only the main agent receives their findings.
- This structure resembles a hub-and-spoke model where all information flows through the main agent without direct interaction between sub-agents.
Utilizing Agents Effectively
Planning Framework Integration
- The GSD (Get Stuff Done by Tash) framework is recommended for comprehensive project planning by breaking down initial briefs into manageable subtasks executed by agents.
Agent Capabilities
- Users can explore various agents within their folder setup; each agent has defined roles and access tools tailored for specific processes.
Agent Collaboration Patterns in Claude
Offloading Tasks to Sub Agents
- The main agent can decide when to offload tasks to sub agents, either automatically or by user specification. This allows for efficient task management based on the nature of the work.
- A powerful application of this is the "builder-validator chain," where one sub agent builds a task and another reviews it, ensuring quality without manual oversight.
Split and Merge Functionality
- The "split and merge" feature enables parallelization within a single session, allowing multiple sub agents to work simultaneously while keeping the context window clean.
- However, a limitation exists as sub agents cannot communicate directly with each other; all interactions must go through the main agent, which can create bottlenecks.
Agent Teams for Enhanced Coordination
- The concept of "agent teams" allows multiple agents to share findings and adapt collaboratively via a shared task list, enhancing coordination beyond what individual agents can achieve.
- This feature is experimental and requires enabling specific settings in
settings.json, indicating its advanced but resource-intensive nature.
Token Usage and Project Complexity
- Using agent teams significantly increases token usage (estimated 4 to 7 times more), making them suitable only for complex projects that require extensive collaboration among agents.
- Examples include developing complex applications where different roles (front-end, back-end developers) need constant communication without going through a central lead.
Autonomous Workflows: Claude Working Without You
- The final pattern discussed is "Claude working without you," representing autonomous workflows where users set tasks and return later for results—termed headless operation.
- This mode requires no human interaction during execution; users can automate processes using system scheduling functions like cron jobs for seamless report generation.
Creating Automated Workflows with Claude
The Concept of Automation in Workflows
- The idea is to create workflows that operate on a schedule without user input, such as generating a morning report based on previous day's work.
- Users can automate content creation for their business by having scripts pull video transcripts and generate social media posts, which can be scheduled automatically.
Trust and Limitations in Automation
- A significant limitation is the trust factor; users must allow Claude autonomy to perform tasks without constant oversight.
- It's advisable to use automation for tasks where outputs are easy to verify, avoiding complex actions that are hard to reverse.
Implementing Guardrails and Iterative Processes
- Users can set guardrails by restricting Claude's capabilities, such as allowing it only to read data but not write.
- Some community members have developed methods like the Ralph loop, enabling Claude to iterate on its own work until satisfactory results are achieved.
Practical Applications of Automation
- This approach allows users to delegate entire projects overnight, making it ideal for batch processing tasks with easily verifiable outcomes.