Git for the intent behind agent-written code. Records what your coding agent decided and why, and links every commit to it.
JavaScript ai-codingclaudeclaude-codeclaude-code-pluginclicoding-agentsdeveloper-toolsgitllmtypescript
/**
* Builds the shell command shown by the resume button. Kept free of Node
* imports because the browser template imports it too.
*/
/** Single-quotes a value for POSIX shells; embedded quotes are escaped. */
export function shellQuote(value: string): string {
return `'${value.replace(/'/g, `'\\''`)}'`;
}
/** Leaves plain ids alone so the command matches the documented shape. */
function sessionArg(sessionId: string): string {
return /^[A-Za-z0-9._:/-]+$/.test(sessionId) ? sessionId : shellQuote(sessionId);
}
/**
* `cd '<project path>' && claude --resume <sessionId>`; with `fork`, adds
* `--fork-session` so the chat continues as a new session and the original stays.
*/
export function resumeCommand(projectPath: string, sessionId: string, fork = false): string {
const command = `cd ${shellQuote(projectPath)} && claude --resume ${sessionArg(sessionId)}`;
return fork ? `${command} --fork-session` : command;
}