Skip to content

Commit 17e4189

Browse files
committed
feat(flow): add --resume flag to resume Claude Code sessions
Thread --resume [session-id] through the full CLI pipeline so users can resume previous Claude Code sessions via Flow.
1 parent a068e13 commit 17e4189

File tree

6 files changed

+18
-1
lines changed

6 files changed

+18
-1
lines changed

packages/flow/src/commands/flow-command.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export const flowCommand = new Command('flow')
2727
.option('--dry-run', 'Show what would be done without making changes')
2828
.option('-p, --print', 'Headless print mode (output only, no interactive)')
2929
.option('-c, --continue', 'Continue previous conversation (requires print mode)')
30+
.option('-r, --resume [session-id]', 'Resume a previous Claude Code session')
3031
.option('--merge', 'Merge Flow settings with existing settings (default: replace all)')
3132

3233
// Prompt argument

packages/flow/src/commands/flow/execute-v2.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ export async function executeFlowV2(
306306
prompt,
307307
print: options.print,
308308
continue: options.continue,
309+
resume: options.resume,
309310
};
310311

311312
// Suppress SIGINT in parent — child process handles its own Ctrl+C.

packages/flow/src/commands/flow/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export interface FlowOptions {
2626
// Execution modes
2727
print?: boolean;
2828
continue?: boolean;
29+
resume?: string | boolean;
2930

3031
// Attach strategy
3132
merge?: boolean; // Merge with user settings instead of replacing (default: replace)

packages/flow/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export function createCLI(): Command {
5858
.option('--dry-run', 'Show what would be done without making changes')
5959
.option('-p, --print', 'Headless print mode (output only, no interactive)')
6060
.option('-c, --continue', 'Continue previous conversation (requires print mode)')
61+
.option('-r, --resume [session-id]', 'Resume a previous Claude Code session')
6162
.option('--merge', 'Merge Flow settings with existing settings (default: replace all)')
6263

6364
.action(async (prompt, options) => {

packages/flow/src/targets/claude-code.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ export const claudeCodeTarget: Target = {
199199
async executeCommand(
200200
systemPrompt: string,
201201
userPrompt: string,
202-
options: { verbose?: boolean; dryRun?: boolean; print?: boolean; continue?: boolean } = {}
202+
options: { verbose?: boolean; dryRun?: boolean; print?: boolean; continue?: boolean; resume?: string | boolean } = {}
203203
): Promise<void> {
204204
// Sanitize and validate inputs
205205
const sanitizedSystemPrompt = sanitize.yamlContent(systemPrompt);
@@ -220,6 +220,12 @@ Please begin your response with a comprehensive summary of all the instructions
220220
if (options.continue) {
221221
dryRunArgs.push('-c');
222222
}
223+
if (options.resume) {
224+
dryRunArgs.push('--resume');
225+
if (typeof options.resume === 'string') {
226+
dryRunArgs.push(options.resume);
227+
}
228+
}
223229
dryRunArgs.push('--system-prompt', '"<agent content>"');
224230
if (sanitizedUserPrompt.trim() !== '') {
225231
dryRunArgs.push(`"${sanitizedUserPrompt}"`);
@@ -247,6 +253,12 @@ Please begin your response with a comprehensive summary of all the instructions
247253
if (options.continue) {
248254
args.push('-c');
249255
}
256+
if (options.resume) {
257+
args.push('--resume');
258+
if (typeof options.resume === 'string') {
259+
args.push(options.resume);
260+
}
261+
}
250262

251263
args.push('--system-prompt', enhancedSystemPrompt);
252264
if (options.verbose) {

packages/flow/src/types/cli.types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,5 @@ export interface RunCommandOptions {
8484
prompt?: string;
8585
print?: boolean; // Headless print mode
8686
continue?: boolean; // Continue previous conversation
87+
resume?: string | boolean; // Resume a previous session
8788
}

0 commit comments

Comments
 (0)