# Finish One Job, Then Keep Going: Extending a Claude Code Workflow Across Turns

> How a Claude Code workflow grows across several chat turns — append a step, resume from the last run, and only pay for the new part.

Author: Shumin Fu  
Published: 2026-10-14  
Tags: claude-code, ai-agents, workflow  
Canonical: https://funfun.zone/posts/claude-code-workflow-multi-turn/

<div class="wf-report not-prose">
<p class="lead">How a workflow grows across several chat turns without redoing the work that is already done</p>
<div class="chips">
<span class="chip">tool <b>Workflow</b></span>
<span class="chip">key input <b>resumeFromRunId</b></span>
<span class="chip ok">scope <b>same session only</b></span>
</div>
<div class="verdict ok">
<div class="verdict-head">
<span class="verdict-word">APPEND → RESUME</span>
<span class="verdict-zh">Add the new step at the end of the saved script, then resume from the last run.</span>
</div>
<div class="verdict-body">
<p>Every run saves its script to a file and returns a <code>runId</code>. Next turn, I edit that file and call
<code>Workflow({scriptPath, resumeFromRunId})</code>. Steps at the front that did not change come back
<strong>from the cache</strong>, instantly and for free. Only the new step runs for real.</p>
<p>One catch: the cache works on the <strong>longest unchanged prefix</strong>. Change an early step, and that step
plus everything after it runs again. So add new work at the <em>end</em>.</p>
</div>
<div class="vstats">
<div class="vstat"><b>0 tokens</b><span>for cached steps on resume</span></div>
<div class="vstat"><b>1 file</b><span>the saved script you keep editing</span></div>
<div class="vstat"><b>1 session</b><span>resume does not cross sessions</span></div>
</div>
</div>
<section aria-labelledby="s01">
<h2 id="s01"><span class="n">01</span>The four pieces</h2>
<p class="sub">Think of a recipe card plus a box of finished dishes. You can add a line to the card; the dishes already cooked stay in the box.</p>
<div class="pg-grid g2">
<div class="card"><h3><span class="pill teal">recipe</span>The script file</h3><p>The JavaScript that says which agents to run. Each run saves it as a file in this session's folder; the tool result prints the path. I edit it with <code>Edit</code>, then pass it back as <code>scriptPath</code>.</p></div>
<div class="card"><h3><span class="pill blu">receipt</span>The run ID</h3><p>A name for one run, like <code>wf_…</code>. It points to that run's saved results. You pass it as <code>resumeFromRunId</code>.</p></div>
<div class="card"><h3><span class="pill grn">dish box</span>The journal</h3><p><code>journal.jsonl</code> in the run's folder records what each <code>agent()</code> call returned. Resume reads it. I also read it when a result looks empty or odd.</p></div>
<div class="card"><h3><span class="pill amb">order note</span><code>args</code></h3><p>Input handed to the script. It is part of the cache key: same script + same <code>args</code> = full cache hit. Use it to pass a result into a <em>different</em> workflow.</p></div>
</div>
</section>
<section aria-labelledby="s02">
<h2 id="s02"><span class="n">02</span>The whole flow, turn by turn</h2>
<p class="sub">Example: review a branch, then fix what was found, then double-check the fixes. Three chat turns, one growing script.</p>
<div class="tl">
<div class="turn" data-n="1">
<div class="who">Turn 1 · you</div>
<div class="say">"Use a workflow to review the changes on this branch."</div>
<div class="box"><ol>
<li>I call <code>Workflow({script})</code> with phases <b>Review → Verify</b>.</li>
<li>The tool returns right away with a <code>runId</code> and the saved <code>scriptPath</code>. The run continues in the background.</li>
<li>When it ends, a notification wakes me. I read the result and report the confirmed findings to you.</li>
</ol>
<div class="runs"><span class="run live">Review ×N · live</span><span class="run live">Verify ×M · live</span><span class="run id">→ run A</span></div>
</div>
</div>
<div class="turn" data-n="2">
<div class="who">Turn 2 · you</div>
<div class="say">"Good. Now fix the confirmed ones."</div>
<div class="box"><ol>
<li>I <code>Edit</code> the saved script and <b>append</b> a <b>Fix</b> phase after Verify. It uses the confirmed findings already in the script.</li>
<li>I call <code>Workflow({scriptPath, resumeFromRunId: "run A"})</code>.</li>
<li>Review and Verify did not change, so they replay from the journal in no time. Only Fix runs.</li>
</ol>
<div class="runs"><span class="run cache">Review · cached</span><span class="run cache">Verify · cached</span><span class="run live">Fix · live</span><span class="run id">→ run B</span></div>
</div>
</div>
<div class="turn" data-n="3">
<div class="who">Turn 3 · you</div>
<div class="say">"Add a final check that the tests pass."</div>
<div class="box"><ol>
<li>I append a <b>Check</b> phase and resume from the <em>latest</em> run, run B.</li>
<li>Everything before Check is cached; Check runs live.</li>
</ol>
<div class="runs"><span class="run cache">Review · cached</span><span class="run cache">Verify · cached</span><span class="run cache">Fix · cached</span><span class="run live">Check · live</span><span class="run id">→ run C</span></div>
</div>
</div>
<div class="turn" data-n="!">
<div class="who">Any turn · mid-run</div>
<div class="say">"Wait — change the plan before it finishes."</div>
<div class="box"><ol>
<li>I stop the running workflow first with <code>TaskStop</code>.</li>
<li>Then I edit the script and resume from that run's ID. Agents that already finished come from the cache.</li>
</ol></div>
</div>
</div>
<div class="tldr"><p><span class="hl">In one line:</span> each turn = edit the same file, add at the end, resume from the newest run ID. The script grows; the cost only covers the new part.</p></div>
</section>
<section aria-labelledby="s03">
<h2 id="s03"><span class="n">03</span>What the script looks like</h2>
<p class="sub">Turn 2's edit, simplified. Green lines are the append; nothing above them changes.</p><pre><span class="dim">export const meta = {
  name: 'review-then-fix',
  description: 'Review branch changes, verify, then fix confirmed findings',
  phases: [{ title: 'Review' }, { title: 'Verify' },</span> <span class="add">{ title: 'Fix' }</span><span class="dim">],
}
<span></span>
const found = await pipeline(DIMENSIONS, d =&gt; agent(d.prompt, { phase: 'Review', schema: FINDINGS }))
const confirmed = await verifyAll(found)          // unchanged → replayed from the journal</span>
<span class="add">
// --- appended in turn 2 ---
const fixes = await parallel(confirmed.map(f =&gt; () =&gt;
  agent(`Fix ${f.title} in ${f.file}`, { phase: 'Fix', isolation: 'worktree' })))
return { confirmed, fixes }</span></pre><p class="pg-prose" style="margin-top:12px">Two small rules: the <code>meta</code> block must be a plain literal, and the script cannot use
<code>Date.now()</code>, <code>Math.random()</code>, or <code>new Date()</code>. Those would give a different answer on every replay and break the cache.
Pass a timestamp in through <code>args</code> instead.</p>
</section>
<section aria-labelledby="s04">
<h2 id="s04"><span class="n">04</span>The cache rule: longest unchanged prefix</h2>
<p class="sub">Resume walks the <code>agent()</code> calls in order. It reuses them until it meets the first one that is new or different. From there on, everything runs live.</p>
<div class="flow">
<div class="lane good">
<div class="hd">✓ Append at the end</div>
<div class="bd">
<div class="step">Review — same → cached</div>
<div class="arrow">↓</div>
<div class="step">Verify — same → cached</div>
<div class="arrow">↓</div>
<div class="step">Fix — new → live</div>
<div class="res">→ pay only for Fix</div>
</div>
</div>
<div class="lane bad">
<div class="hd">✗ Edit an early prompt</div>
<div class="bd">
<div class="step">Review — prompt changed → live</div>
<div class="arrow">↓</div>
<div class="step">Verify — after the change → live</div>
<div class="arrow">↓</div>
<div class="step">Fix — live</div>
<div class="res">→ pay for the whole run again</div>
</div>
</div>
</div>
<div class="tablebox" style="margin-top:16px">
<table>
<thead><tr><th>You change…</th><th>Effect on resume</th></tr></thead>
<tbody>
<tr><td>Nothing (same script, same <code>args</code>)</td><td class="y">✓ 100% cached</td></tr>
<tr><td>Add steps after the last one</td><td class="y">✓ old steps cached, new ones live</td></tr>
<tr><td>An early <code>agent()</code> prompt or its options</td><td class="n">✗ that step and all later steps rerun</td></tr>
<tr><td><code>args</code></td><td class="n">✗ any step whose prompt uses them reruns</td></tr>
</tbody>
</table>
</div>
<div class="insight" style="margin-top:14px"><p><b>Easy to get wrong.</b> It is tempting to think "any unchanged call is cached." In fact, only the unchanged calls <em>before the first change</em> are cached. That is why appending is the safe habit.</p></div>
</section>
<section aria-labelledby="s05">
<h2 id="s05"><span class="n">05</span>Other ways to continue</h2>
<p class="sub">Resume is the default. Pick another path when the next job is not really "more of the same run."</p>
<div class="tablebox">
<table>
<thead><tr><th>Situation</th><th>What I call</th><th>Why</th></tr></thead>
<tbody>
<tr><td>Next job builds on this run's data</td><td class="note"><code>Workflow({scriptPath, resumeFromRunId})</code></td><td class="note">Reuses finished agents; one growing script.</td></tr>
<tr><td>Want a clean rerun of the edited script</td><td class="note"><code>Workflow({scriptPath})</code></td><td class="note">No cache; everything runs fresh.</td></tr>
<tr><td>Next job is a different kind of work</td><td class="note">New <code>Workflow({script, args})</code></td><td class="note">Feed the last result in via <code>args</code>; each workflow stays small and readable.</td></tr>
<tr><td>One script should call another</td><td class="note"><code>workflow(name or {scriptPath}, args)</code> inside the script</td><td class="note">Runs the child inline. Only one level deep.</td></tr>
<tr><td>Reuse it in later sessions</td><td class="note">Save under <code>.claude/workflows/</code>, call by <code>name</code></td><td class="note">Resume can't cross sessions; a saved workflow can be rerun anywhere.</td></tr>
</tbody>
</table>
</div>
<p class="pg-prose" style="margin-top:12px">For big tasks, the guidance is to run phases as <strong>separate workflows in sequence</strong>—understand → design → implement → review—so I read each result before choosing the next step. That keeps you in the loop between phases.</p>
</section>
<section aria-labelledby="s06">
<h2 id="s06"><span class="n">06</span>Limits and gotchas</h2>
<div class="pg-grid g2">
<div class="phase">
<div class="ph">Hard limits</div>
<ul>
<li><b>Same session only.</b> A new session cannot resume an old run.</li>
<li><b>Stop before you resume</b> a run that is still going (<code>TaskStop</code>).</li>
<li><b>Nesting is one level.</b> A child workflow can't call another.</li>
<li><b>Opt-in.</b> I only start a workflow when you ask (e.g. "use a workflow").</li>
</ul>
</div>
<div class="phase">
<div class="ph">Habits that keep it cheap</div>
<ul>
<li><b>Add new work at the end</b> of the script.</li>
<li><b>Don't reword</b> early prompts unless you want them to rerun.</li>
<li><b>Odd or empty result?</b> Check <code>journal.jsonl</code> before guessing.</li>
<li><b>Mention the run</b> ("extend the last workflow…") so I know which run ID to resume.</li>
</ul>
</div>
</div>
<div class="tldr"><p><span class="hl">What to tell me:</span> "Extend the last workflow with &lt;new step&gt; and resume." I'll append to the saved script, resume from the newest run ID, and only the new step will cost anything.</p></div>
</section>
<footer class="footer">
<div>Source: Claude Code <code>Workflow</code> tool description and <code>workflow-authoring</code> reference (Resume section).</div>
<div class="legend">
<span><span class="dot" style="background:var(--grn)"></span>cached / safe</span>
<span><span class="dot" style="background:var(--amb)"></span>runs live (costs tokens)</span>
<span><span class="dot" style="background:var(--red)"></span>cache broken</span>
<span><span class="dot" style="background:var(--blu)"></span>run ID</span>
</div>
</footer>
</div>
