Skip to main content

Putting It All Together: Workflows in Practice

From the crash course?

You may have arrived here from the 90-minute Problem Solving Crash Course. This lesson is the capstone: it weaves all seven principles into end-to-end workflows you'll use daily.

You've learned the seven principles of general agent problem solving. Knowing the principles is one thing. Applying them together in real workflows is another. Before we walk through workflows, it helps to see the seven not as a flat list but as a structure with a specific shape.

The Shape of the Seven

The seven principles are listed in build-order, not importance-order. Each rests on the ones below. They also split cleanly into two groups: five that produce work and two that govern how the work is run.

The Five Doing Principles (P1-P5)

These are what make the work actually happen: the agent acts, produces structured output, checks itself, breaks things into small pieces, and remembers across sessions.

  1. Bash is the Key: terminal access turns the agent from advisor into operator. It acts.
  2. Code as Universal Interface: the agent emits structured artifacts (code, schemas, specs) instead of fluent prose.
  3. Verification as Core Step: every produced thing is checked against ground truth before it is trusted.
  4. Small, Reversible Decomposition: work is broken into atomic, revertable units so failure is cheap.
  5. Persisting State in Files: durable context (rules file, ADRs, journals) survives session boundaries.

The Two Operating Principles (P6-P7)

These are what make the discipline survive in real projects under real pressure. They do not produce code; they constrain and observe the code that gets produced.

  1. Constraints and Safety: scope, permissions, and approval modes set at the session boundary. The wrapper around the four-phase workflow.
  2. Observability: progress reporting, activity logs, and visibility into what the agent did and why.

Why the Order Matters: a Dependency Pyramid

              ┌─────────────────────┐
│ P7 Observability │ apex
└─────────────────────┘
┌─────────────────────────┐
│ P6 Constraints/Safety │
└─────────────────────────┘
┌─────────────────────────────┐
│ P5 Persisting State │
└─────────────────────────────┘
┌─────────────────────────────────┐
│ P4 Small, Reversible Decomp. │
└─────────────────────────────────┘
┌─────────────────────────────────────┐
│ P3 Verification as Core Step │
└─────────────────────────────────────┘
┌─────────────────────────────────────────┐
│ P2 Code as Universal Interface │
└─────────────────────────────────────────┘
┌─────────────────────────────────────────────┐
│ P1 Bash is the Key │ widest base
└─────────────────────────────────────────────┘

Read from the bottom up. P1 is the widest foundation: without action, nothing else happens. P2 sits on P1: you can only produce a structured artifact if the agent can run something. P3 sits on P2: verification is impossible without an artifact to check. P4 sits on P3: you can only decompose into reversible steps if each step can be verified. P5 sits on P4: persistence is meaningful only when you have small, trustworthy units to persist. P6 sits on P5: constraints can be enforced only where state and behavior are well-defined. P7 sits on P6: observability is the apex because you need everything below it to have something worth observing.

Skip a layer and the layers above it become unstable. A team that verifies (P3) without producing structured artifacts (P2) is verifying prose. A team that decomposes (P4) without verification (P3) is just making more, smaller mistakes faster. A team that adds constraints (P6) without persistence (P5) re-writes the rules every session.

Your New Role: From Typist to Director

Here's the mindset shift: You're no longer the one typing code. You're the director managing an agent.

Think of the AI as a junior developer with infinite energy but no institutional knowledge. It will work tirelessly, but it needs:

  • Clear direction (what to do)
  • Context (why and how)
  • Guardrails (what NOT to do)
  • Verification (did it work?)

Your job is no longer typing,it's directing, reviewing, and approving. The seven principles are your management framework.

                    THE DIRECTOR'S LOOP

YOU (Director) AI (Agent)
┌───────────┐ ┌───────────┐
│ Intent │──── P2 ────►│ Investigate│
│ & Context│ (Code) │ & Propose │
│ │◄── P7 ─────│ │
│ Review │ (Observe) │ Implement │
│ & Approve│──── P6 ────►│ & Verify │
└─────┬─────┘ (Safety) └─────┬──────┘
│ │
│ P3 (Verify) │
└─────── P4 (Small) ──────┘
P5 (Persist)

P1 (Bash) underlies every AI action

The Integration Challenge: Principles in Combination

Real workflows rarely involve a single principle in isolation. They require multiple principles working together:

TaskKey PrinciplesWhy These Principles Matter
Debug production issue1, 3, 7Terminal access to investigate, verification of fixes, observability to understand what happened
Refactor large module2, 4, 5Code as specification, small reversible steps, context persistence for patterns
Add new featureAll principlesComplete workflow needs all aspects
Set up new project1, 5, 6Terminal for setup, context files, safety for new environment
Optimize performance1, 3, 7Terminal for profiling, verification of improvements, observability to find bottlenecks

Workflow 1: Debugging a Production Issue

Scenario

You get a report: "Users are seeing 'Invalid token' errors when logging in."

Applying the Principles

Principle 1: Bash is the Key

# AI can investigate directly
tail -f /var/log/app.log # Real-time logs
grep "Invalid token" /var/log/app.log # Find related errors
ps aux | grep node # Check running processes

Principle 7: Observability

# Trace through the system
# AI reads logs to understand the sequence:
# 14:32:15 - Login request from user@example.com
# 14:32:16 - Token generated: eyJhbGc...
# 14:32:17 - Token validation: FAIL
# 14:32:17 - Error: Invalid token

Principle 3: Verification as Core Step

# AI proposes fix, then verifies
# "I see the issue: Token validation uses wrong secret"
# AI reads .env file
# AI confirms: TOKEN_SECRET mismatch
# AI proposes: Fix secret in .env
# You verify: Is this the correct secret?
# AI tests: Login with test credentials

Principle 4: Small, Reversible Decomposition

# Fix in one step, verify, then move on
Step 1: Update .env with correct secret
Step 2: Restart application
Step 3: Verify login works
Step 4: Monitor logs for recurrence

Principle 6: Constraints and Safety

# AI doesn't automatically modify production .env
# Requires your confirmation
# You: "Show me the diff before applying"
# AI shows: -TOKEN_SECRET=old +TOKEN_SECRET=new
# You approve, AI applies change

Complete Workflow

You: "Users getting 'Invalid token' errors. Help debug."

AI: "Let me investigate.
[Reads logs]
I see: Token validation failing for all logins.
[Checks .env]
Found: TOKEN_SECRET doesn't match what's encoded in tokens.
[Checks token generation code]
Confirmed: app.js uses TOKEN_SECRET from .env, but .env has wrong value.

Proposed fix:
1. Update .env with correct TOKEN_SECRET
2. Restart application
3. Test login
4. Monitor logs

Shall I proceed?"

You: "Show me the diff first."

AI: [Shows .env diff]

You: "Approved."

AI: [Applies change]
[Restarts app]
[Tests login]
✓ Login working
[Monitoring logs]
✓ No new errors

Fixed. Summary: TOKEN_SECRET mismatch caused validation failures.
Corrected secret, restarted, verified login working."

Workflow 2: Implementing a New Feature

Scenario

You need to add: "Users can reset their password via email."

Applying the Principles

Principle 5: Persisting State in Files

# First, update CLAUDE.md with new context

## Current Work

### In Progress

- Password reset feature: email token generation, reset endpoint, UI

### Requirements

- Token expires in 1 hour
- Single-use tokens
- Email sent via SendGrid

Principle 2: Code as Universal Interface

// Write specification as code (test)
test("password reset flow", async () => {
// Request reset
const response1 = await requestReset("user@example.com");
expect(response1.success).toBe(true);

// Get token from email (mock)
const token = await getLastEmailToken();

// Use token to reset
const response2 = await resetPassword(token, "newPassword123");
expect(response2.success).toBe(true);

// Login with new password
const response3 = await login("user@example.com", "newPassword123");
expect(response3.success).toBe(true);
});

Principle 4: Small, Reversible Decomposition

Break into 8 steps:
1. Add password reset token to database schema
2. Create token generation utility
3. Create password reset email template
4. Add POST /auth/reset-request endpoint
5. Add POST /auth/reset-confirm endpoint
6. Add password reset UI
7. Add tests
8. Integrate with SendGrid

Principle 3: Verification as Core Step

# After each step:
npm test # Run tests
git diff # Review changes
npm run build # Verify build

Principle 1: Bash is the Key

# AI executes each step
# Step 1: Modify schema
npx prisma migrate dev --name add-reset-tokens

# Step 2: Create utility
# [AI writes src/utils/token-generator.ts]

# Step 3: Create email template
# [AI writes emails/reset-password.html]

# Continue through all steps...

Principle 6: Constraints and Safety

# Safety checkpoints:
- Database migration: Show SQL before applying
- Email sending: Use sandbox API key first
- UI changes: Review before committing

Principle 7: Observability

AI provides progress updates:
"Step 3 complete: Created email template
Files: +emails/reset-password.html
Next: Add reset-request endpoint
Continue?"

Complete Workflow Timeline

TimeStepPrinciple(s) Applied
0:00Write test specification2 (Code as Interface)
0:05Update CLAUDE.md with context5 (Persist State)
0:10Break into 8 steps4 (Decomposition)
0:15Step 1: Database migration + verify1, 3, 6
0:20Step 2: Token utility + verify1, 3, 6
0:25Step 3: Email template + verify1, 3, 6
0:30Step 4: Reset-request endpoint + verify1, 3, 6, 7
0:35Steps 5-8: Remaining work1, 3, 6, 7
0:50Full test suite + integration tests3 (Verification)
0:55Review all changes with git diff7 (Observability)
1:00Commit if satisfied4 (Reversible)

Workflow 3: Refactoring a Large Module

Scenario

Refactor src/auth/auth.js (500 lines) into smaller, testable modules.

Applying the Principles

Principle 5: Persisting State in Files

# Document before starting

## Refactoring Plan: src/auth/auth.js

Current issues:

- 500-line file, hard to understand
- Mixed concerns: validation, storage, tokens
- No tests

Target structure:
src/auth/
├── validation.js # Input validation
├── storage.js # Database operations
├── tokens.js # Token generation/validation
├── auth.js # Orchestration (small)
└── **tests**/
├── validation.test.js
├── storage.test.js
└── tokens.test.js

Principle 4: Small, Reversible Decomposition

Step 1: Extract validation logic (reversible via git)
Step 2: Extract storage logic (reversible via git)
Step 3: Extract token logic (reversible via git)
Step 4: Write tests for extracted modules
Step 5: Update auth.js to use new modules
Step 6: Add integration tests
Step 7: Remove old auth.js code
Step 8: Full test suite

Principle 2: Code as Universal Interface

// Before: Show current code
// After: Show refactored code
// AI proposes diff, you review

Principle 3: Verification as Core Step

# After each extraction:
npm test # Ensure tests still pass
npm run lint # Ensure code quality
npm run build # Ensure build succeeds

Principle 1: Bash is the Key

# AI executes refactor steps
git checkout -b refactor/auth-extraction
# [Performs extractions]
git diff --stat # Show summary

Principle 6: Constraints and Safety

# Work on feature branch
# Commit after each successful step
# Easy rollback if needed

Principle 7: Observability

AI provides progress:
"Extracted validation (87 lines)
Created: src/auth/validation.js
Modified: src/auth/auth.js (-87 lines)
Tests: PASS
Commit? [y/n]"

Principle Selection Guide: Which Principles When?

Not all principles are equally important for every task. Use this guide to prioritize:

Task TypeMost Critical PrinciplesWhy
Quick bug fix1, 3, 7Fast investigation, verify fix, see what happened
New featureAllComplete workflow needs all aspects
Refactoring2, 4, 5Code precision, small steps, context persistence
Debugging1, 3, 7Terminal access, verification, visibility
Learning codebase1, 7, 5Read files, observe patterns, understand context
Setup/install1, 5, 6Terminal commands, state files, safety in new env
Performance work1, 3, 7Profiling (terminal), verification, observability

Workflow Templates: Ready-to-Use Patterns

Template 1: Quick Fix Pattern

1. Describe problem to AI
2. AI reads files to understand (Principle 1, 7)
3. AI proposes solution as code diff (Principle 2)
4. You review and approve (Principle 6)
5. AI applies change (Principle 1)
6. AI verifies with tests (Principle 3)
7. AI shows summary (Principle 7)
8. You commit if satisfied (Principle 4)

Template 1b: When the Fix Fails

What happens when step 6 (verification) fails? Don't panic,follow this recovery path:

6. AI verifies with tests → TESTS FAIL

6b. AI identifies WHY it failed (Principle 7: Observability)
"Tests fail because: [specific reason]"

6c. AI reverts the change (Principle 4: Reversibility)
git checkout -- . OR git reset --hard HEAD

6d. AI proposes NEW approach based on what it learned
"The first approach failed because X. Let me try Y instead."

6e. Return to step 3 with new approach

Key insight: Failure is information. The failed attempt tells you what DOESN'T work, narrowing down what will. Revert cleanly, learn from the failure, try again.

Template 2: Feature Development Pattern

1. Write test/specification (Principle 2)
2. Update CLAUDE.md with context (Principle 5)
3. Break feature into steps (Principle 4)
4. For each step:
a. AI implements (Principle 1)
b. AI verifies (Principle 3)
c. AI shows progress (Principle 7)
d. You approve (Principle 6)
5. Full integration tests (Principle 3)
6. Review all changes (Principle 7)
7. Commit (Principle 4)

Template 3: Refactoring Pattern

1. Document current state (Principle 5)
2. Plan refactoring steps (Principle 4)
3. Create feature branch (Principle 6)
4. For each extraction:
a. AI extracts code (Principle 2)
b. AI verifies tests pass (Principle 3)
c. AI shows what changed (Principle 7)
d. Commit if good (Principle 4)
5. Integration tests (Principle 3)
6. Merge to main when ready (Principle 6)

Evaluating Your Workflow: A Self-Assessment

Use this checklist to evaluate how well you're applying the principles:

Terminal Access (Principle 1)

  • AI can read project files directly
  • AI can run commands (tests, builds, etc.)
  • You're not copying/pasting code manually
  • AI uses terminal for investigation, not just code generation

Code as Interface (Principle 2)

  • You provide specifications as code/tests, not vague descriptions
  • You review AI-generated code as the primary feedback mechanism
  • You use concrete examples to clarify requirements
  • You iterate through code changes, not natural language debate

Verification (Principle 3)

  • You verify after every significant change
  • Tests run automatically or with AI assistance
  • You never accept code without testing
  • You have appropriate verification depth for risk level

Decomposition (Principle 4)

  • You break tasks into small steps
  • Each step can be independently tested
  • Each commit is atomic and reversible
  • You iterate rather than batch

State Persistence (Principle 5)

  • You maintain CLAUDE.md or similar context file
  • Project conventions are documented
  • Current work is tracked
  • Decisions are documented (ADRs)

Safety (Principle 6)

  • Destructive operations require approval
  • You work in sandbox/feature branches
  • You have appropriate permission model
  • You can easily rollback changes

Observability (Principle 7)

  • You can see what AI is doing
  • You understand AI's rationale for changes
  • You review activity logs when debugging
  • AI provides progress updates

Your Project Health Score

Count how many principles you're actively applying (1 point per principle with at least 2 checkboxes marked):

ScoreLevelWhat It Means
0-2Cowboy CoderHigh risk. You're flying blind. Start with Principles 3 (Verification) and 7 (Observability).
3-4CollaboratorGood progress. You're working WITH the AI, not just using it. Focus on the gaps.
5-6Agent ArchitectProfessional grade. You're managing AI effectively. Fine-tune for efficiency.
7Master DirectorFull integration. You've internalized the principles. Now optimize and teach others.

Where to start if you're at 0-2: Begin with just two principles,Verification (always test) and Observability (always see what AI did). These two alone prevent most disasters.

Why This Integration Matters

The principles are powerful individually. Together, they're transformative:

  • Terminal + Code + Verification: AI can investigate, implement, and test autonomously
  • Decomposition + Safety + Observability: Small, safe, visible steps
  • State Persistence: Context accumulates across sessions

When you apply all principles together, you move from "using AI" to "collaborating with an intelligent agent." The workflow becomes:

  1. You provide intent and direction
  2. AI investigates and proposes solutions
  3. You review and redirect
  4. AI implements and verifies
  5. You approve and integrate

This is the Agent Factory paradigm in action.

The Meta-Principle

All seven principles derive from one meta-principle:

General agents are most effective when they leverage computing fundamentals rather than fighting against them.

File systems, shells, code execution, version control,these aren't limitations to work around. They're the foundations that enable reliable, debuggable, powerful agent workflows.

Claude Code makes this explicit through the terminal interface. Cowork makes it accessible through a GUI. But underneath, they're running on the same principles,the same Claude Agent SDK, the same reasoning engine, the same fundamental approach to problem-solving through computing primitives.

Choosing Your Interface Based on Principles

Both interfaces support all seven principles. Choose based on your task characteristics:

If you need...Claude CodeClaude Cowork
Maximum observabilityBest choice (raw terminal)Good (three-panel layout)
Minimal frictionGoodBest choice (GUI)
Custom constraintsBest choice (hooks, settings)Limited (built-in only)
Built-in safety promptsManual configurationBest choice (native dialogs)
Git-based reversibilityNativeRequires setup
Document workflowsRequires Skills/toolsBest choice (built-in Skills)
Programmatic precisionBest choice (code/scripts)Good (structured prompts)
Non-technical usersRequires terminal comfortBest choice (familiar desktop)

The choice isn't "which is better",it's "which fits this task." Many workflows benefit from using both: Claude Code for implementation, Cowork for documentation and review.

The Director's Tip: Invoke Principles Explicitly

Here's a power move: tell the AI which principle to use.

Instead of vague instructions like "refactor this code," try:

"Refactor this using Principle 4—break it into 3 small steps.
After each step, show me what changed and wait for my approval
before continuing."

Or for a bug fix:

"Debug this using Principles 1, 3, and 7. Use the terminal to
investigate, verify your fix with tests, and show me the logs
so I can see what happened."

Why this works: You're giving the AI a framework, not just a task. It knows HOW you want it to work, not just WHAT you want done. This puts you firmly in the director's seat.

Mode 1 and What Comes Next

This chapter trained you for Mode 1: the problem-solving engagement, where you open an agent, solve a specific thing, and ship the outcome. Mode 2 (manufacturing engagements, where you build durable AI Workers that solve a class of problems on a schedule) is governed by Spec-Driven Development (Chapter 16) and the Seven Invariants of the Agent Factory introduced later in the book. The seven principles are foundational to both modes; Mode 2 adds its own discipline on top, not in place of, what you learned here.

Try With AI

Prompt 1: Full Workflow Practice

I want to practice applying all seven principles together.

Here's a task I want to accomplish: [describe a real task you're working on]

Help me design a complete workflow:
1. Which principles are most critical for this task?
2. What steps should I take, in what order?
3. How will each principle be applied in each step?
4. What should I verify at each checkpoint?

Then, let's actually execute this workflow together, with you explaining which principle we're applying at each step and why.

What you're learning: How to integrate all seven principles into a cohesive workflow. You're experiencing how the principles work together to make AI collaboration more effective.

Prompt 2: Workflow Optimization

I want to improve my current AI workflow.

Here's how I currently work with AI:
[Describe your current approach—what you do, how you interact, what tools you use]

Analyze this workflow against the seven principles:
1. Which principles am I applying well?
2. Which principles am I missing or underutilizing?
3. What's the impact of these gaps?
4. What specific changes should I make?

Help me create an improved workflow that applies all principles appropriately.

What you're learning: How to evaluate and optimize your existing workflows using the seven principles as a framework. You're learning to identify gaps and implement improvements.

Prompt 3: Scenario-Based Practice

I want to practice principle selection for different scenarios.

Give me 5 different scenarios (e.g., debugging, refactoring, new feature, learning codebase, setup).

For each scenario:
1. Which 2-3 principles are MOST critical?
2. Why these specifically?
3. What would go wrong if I ignored them?
4. What's a minimal workflow that covers the essentials?

After reviewing all scenarios, help me identify patterns:
- Are some principles always important?
- Does principle priority depend on task type?
- What's a good default approach if I'm unsure?

What you're learning: How to select and prioritize principles based on task characteristics. You're developing judgment about which principles matter most in different contexts.


Next Steps

These seven principles form the foundation for effective problem-solving with General Agents. In Part 2 and beyond, you'll apply these principles to increasingly sophisticated workflows:

  • Complex file processing (Principles 1, 4, 5)
  • Data analysis and reporting (Principles 2, 3, 7)
  • Multi-step research projects (Principles 4, 5, 6)
  • Automated document generation (Principles 2, 3, 4)
  • Browser-based automation (Principles 3, 6, 7)
  • Building Custom Agents (All principles at scale)

Each workflow will demonstrate how the principles combine in practice, using whichever interface,Claude Code or Cowork,best fits the task. The principles don't change; only their application deepens.

Flashcards Study Aid