Back to Post
Agent Workflows That Stick: Short Threads, External Memory, Staged Diffs
1 / 1

TL;DR:

📖 Quick Start

📋 Workflow Checklist

The Problem with Long Threads

You: “Fix the authentication bug” Agent: ✅ Done

You: “Now add logging” Agent: ✅ Done

You: “Refactor the API client” Agent: ✅ Done

You: “Add tests” Agent: 🤔 Forgets the auth fix, breaks the logger, introduces new bugs

What happened? Context sprawl. Beyond ~100k tokens, quality degrades—the model:

The Desk Analogy

Think of your thread as a desk:

The fix: Clear your desk often. Start new threads.

Start New Threads Often

When to start a new thread:

How to carry context forward:

Example:

Thread 1: Fix authentication bug → Commit
Thread 2: Add logging to auth flow → Commit
Thread 3: Refactor API client → Commit
Thread 4: Add tests for all of the above → Commit

Each thread: focused, verifiable, committable.

External Memory: The context.md Pattern

Instead of: Keeping everything in thread context Do this: Write it down, reference it later

Pattern:

You: "Summarize the key decisions and constraints from this
conversation to .agents/context/auth-refactor.md"

[Agent writes context.md]

[Start new thread]

You: "Read @.agents/context/auth-refactor.md and continue
adding the JWT middleware"

What to store:

Naming convention: Name files predictably: .agents/context/<topic>.md (e.g., auth-refactor.md, api-migration.md)

Benefits:

Feedback Loops: Reproducible Scripts

The pattern:

goal → action → verify → adjust → repeat

Make verification automatic:

For tests:

npm test -- @tests/auth.test.ts

For builds:

npm run build && npm run check

For UI:

npm run storybook
# Agent looks at localhost:6006 and screenshots

For databases:

psql -d mydb -c "SELECT * FROM users LIMIT 5;"
# Agent verifies schema changes

Why this matters:

Git Discipline: Your Quality Gate

The workflow:

  1. Agent makes changes
  2. Review diff (git diff or VS Code)
  3. Stage good changes: git add <file>
  4. Discard bad changes: git restore <file>
  5. Repeat until satisfied
  6. Commit staged changes

Why this is powerful:

Pro tip: Use git staging interactively:

git add -p  # Review changes chunk by chunk

Forking Threads: Try Different Approaches

Scenario: Agent suggests approach A, but you want to try B.

Don’t: Keep arguing in the same thread Do: Fork the thread

How to fork: Use the Fork action in VS Code (right-click message → “Fork from here”) or CLI

Benefits:

Confirm the Fix: Add/Modify Tests

Pattern:

You: "Fix the authentication bug AND add a test that
verifies the fix. Show me the test passing."

Why:

For bug fixes:

"Write a test that reproduces the bug, verify it fails,
then fix the bug and verify the test passes."

For features:

"Implement the feature and add tests that cover the
happy path and two error cases."

💡 Token Management: Token sprawl degrades quality beyond ~100k tokens. Cap exploration, focus reads, prune logs, and start new threads often. For comprehensive token hygiene strategies and mode selection, see Power Patterns

Real Example: Refactoring a Component

Bad approach (one long thread):

You: Refactor UserProfile to use hooks
Agent: [makes changes]
You: Add loading states
Agent: [makes changes]
You: Add error boundaries
Agent: [makes changes, context at 120k tokens]
You: Add tests
Agent: [breaks the refactor, forgets loading states]

Good approach (multiple focused threads):

Thread 1:

You: Refactor @components/UserProfile.tsx to use hooks instead of class
syntax. Verify existing tests still pass.
Agent: [refactor + verify]
You: [Review, stage, commit]

Thread 2:

You: Add loading and error states to @components/UserProfile.tsx.
Write tests for both states.
Agent: [implement + test]
You: [Review, stage, commit]

Thread 3:

You: Add error boundary around @components/UserProfile.tsx.
Add a test that verifies it catches render errors.
Agent: [implement + test]
You: [Review, stage, commit]

Result: Three clean commits, each verifiable, no context rot.

Takeaways

Patterns that work:

Patterns that fail:

This Week: Practice These 3 Workflows

🔨 Try It Now: Three Workflow Exercises

Exercise 1: External Memory Extraction

Prompt:

Extract the key architectural decisions from this conversation
to .agents/context/architecture.md. Include constraints,
patterns we're using, and what to avoid.

Verification: File exists, readable by a fresh thread Success criteria: Start a new thread, reference the file, agent understands context

Exercise 2: Fork and Compare

Prompt in Thread A:

Refactor this component using approach A (hooks)

Then fork thread and prompt in Thread B:

Refactor this component using approach B (composition)

Verification: Compare diffs side by side Success criteria: Pick the better approach, discard the other

Exercise 3: Test-First Fix

Prompt:

Write a test that reproduces the bug in [component].
Verify it fails. Then fix the bug and verify the test passes.

Verification: See test fail, then pass Success criteria: Bug fixed with proof via passing test

Expected outcome: These patterns become muscle memory for your daily workflow.

Exercise 1: Short Thread Discipline

Task: Fix a bug or implement a small feature in a new thread, commit, close

Prompt:

"Fix [specific bug] in a fresh thread. Run tests to verify the fix, then show me the diff."

Success criteria:

Exercise 2: External Memory

Task: Create .agents/context/decisions.md for your main project

Prompt:

"Review the architecture of [your project] and create .agents/context/decisions.md
documenting 3-5 key architectural decisions with rationale. Include: tech choices,
API patterns, and known constraints."

Success criteria:

Exercise 3: Test-Driven Fix

Task: Fix a bug AND verify it with a test

Prompt:

"Fix [specific bug]. First write a test that reproduces the bug and verify it fails.
Then fix the bug and verify the test passes. Commit both together."

Success criteria:


Next: Amp Power Patterns — When to use subagents, Oracle, Librarian, and Rush mode for maximum leverage.

Practice Path:

  1. What is an Agent
  2. First Win in 15 Minutes
  3. You are here: Workflows That Stick
  4. Power Patterns
  5. Planning Workflow

Related: