@@ -36,7 +36,14 @@ export interface CommandContext {
3636 startNewSession: () => void;
3737
3838 connectMcpServer: (name: string) => Promise<void>;
39- runSubagent: (prompt: string, model?: string) => Promise<SubagentOutput>;
39+ runSubagent: (
40+ prompt: string,
41+ agentName?: string,
42+ model?: string,
43+ ) => Promise<SubagentOutput>;
44+
45+ activeAgent: string | null;
46+ setActiveAgent: (name: string | null, systemPrompt?: string) => void;
4047
4148 cwd: string;
4249 }
@@ -326,54 +333,6 @@ async function handleMcp(ctx: CommandContext, args: string): Promise<void> {
326333 }
327334 }
328335
329-// ─── Review ───────────────────────────────────────────────────────────────────
330-
331-const REVIEW_PROMPT = (cwd: string, focus: string) => `\
332-You are a code reviewer. Review recent changes and provide actionable feedback.
333-
334-Working directory: ${cwd}
335-${focus ? `Review: ${focus}` : "Review the current changes"}
336-
337-Perform a sensible code review:
338-
339-- Correctness: Are the changes in alignment with the goal?
340-- Code quality: Is there duplicate, dead or bad code patterns introduced or as a result of the changes?
341-- Is the code performant?
342-- Never flag style choices as bugs, don't be a zeolot.
343-- Never flag false positives, if you think something is wrong, check before saying it's an issue.
344-
345-Output a small summary with only the issues found. If nothing of note was found reply saying that.
346-`;
347-
348-async function handleReview(
349- ctx: CommandContext,
350- args: string,
351-): Promise<CommandResult> {
352- const focus = args.trim();
353- writeln(
354- `${PREFIX.info} ${c.cyan("review")} ${c.dim("— spawning review subagent…")}`,
355- );
356- writeln();
357-
358- try {
359- const output = await ctx.runSubagent(REVIEW_PROMPT(ctx.cwd, focus));
360- assertSubagentMerged(output);
361-
362- // Show review results.
363- write(renderMarkdown(output.result));
364- writeln();
365-
366- // Send results to LLM as well.
367- return {
368- type: "inject-user-message",
369- text: `Code review output:\n\n${output.result}\n\n<system-message>Review the findings and summarize them to the user.</system-message>`,
370- };
371- } catch (e) {
372- writeln(`${PREFIX.error} review failed: ${String(e)}`);
373- return { type: "handled" };
374- }
375-}
376-
377336 function handleNew(ctx: CommandContext): void {
378337 ctx.startNewSession();
379338 writeln(
@@ -398,7 +357,7 @@ async function handleCustomCommand(
398357 writeln(`${PREFIX.info} ${label} ${src}`);
399358 writeln();
400359 try {
401- const output = await ctx.runSubagent(prompt, cmd.model);
360+ const output = await ctx.runSubagent(prompt, cmd.agent, cmd.model);
402361 assertSubagentMerged(output);
403362
404363 write(renderMarkdown(output.result));
@@ -414,6 +373,61 @@ async function handleCustomCommand(
414373 }
415374 }
416375
376+// ─── Agent ────────────────────────────────────────────────────────────────────
377+
378+function handleAgent(ctx: CommandContext, args: string): void {
379+ const raw = args.trim();
380+ const agents = loadAgents(ctx.cwd);
381+
382+ if (!raw) {
383+ // List all agents
384+ if (agents.size === 0) {
385+ writeln(
386+ c.dim(" no agents found (~/.agents/agents/ or .agents/agents/)"),
387+ );
388+ writeln(
389+ c.dim(" /agent <name> to activate · /agent off to deactivate"),
390+ );
391+ return;
392+ }
393+ writeln();
394+ writeln(c.dim(" agents:"));
395+ for (const agent of agents.values()) {
396+ const modeTag = agent.mode ? c.dim(` [${agent.mode}]`) : "";
397+ const srcTag =
398+ agent.source === "local" ? c.dim(" (local)") : c.dim(" (global)");
399+ const active = ctx.activeAgent === agent.name ? c.cyan(" ◀ active") : "";
400+ writeln(
401+ ` ${c.magenta(`@${agent.name}`.padEnd(26))} ${c.dim(agent.description)}${modeTag}${srcTag}${active}`,
402+ );
403+ }
404+ writeln();
405+ writeln(
406+ c.dim(" /agent <name> to activate · /agent off to deactivate"),
407+ );
408+ writeln();
409+ return;
410+ }
411+
412+ if (raw.toLowerCase() === "off" || raw.toLowerCase() === "none") {
413+ ctx.setActiveAgent(null);
414+ writeln(`${PREFIX.info} ${c.dim("active agent cleared")}`);
415+ return;
416+ }
417+
418+ const agent = agents.get(raw);
419+ if (!agent) {
420+ writeln(`${PREFIX.error} agent ${c.cyan(raw)} not found`);
421+ return;
422+ }
423+
424+ // Pass the resolved system prompt so setActiveAgent never needs to re-lookup.
425+ ctx.setActiveAgent(raw, agent.systemPrompt);
426+ writeln(
427+ `${PREFIX.success} active agent → ${c.cyan(raw)} ${c.dim("(instructions appended to system prompt)")}`,
428+ );
429+}
430+
417431 // ─── Help ─────────────────────────────────────────────────────────────────────
418432
419433 function handleHelp(
@@ -430,7 +444,7 @@ function handleHelp(
430444 "/ralph",
431445 "toggle ralph mode (autonomous loop, fresh context each iteration)",
432446 ],
433- ["/review [focus]", "run a structured code review on recent changes"],
447+ ["/agent [name]", "set or clear active primary agent"],
434448 ["/mcp list", "list MCP servers"],
435449 ["/mcp add <n> <t> [u]", "add an MCP server"],
436450 ["/mcp remove <name>", "remove an MCP server"],
@@ -461,10 +475,11 @@ function handleHelp(
461475 writeln();
462476 writeln(c.dim(" agents (~/.agents/agents/ or .agents/agents/):"));
463477 for (const agent of agents.values()) {
478+ const modeTag = agent.mode ? c.dim(` [${agent.mode}]`) : "";
464479 const tag =
465480 agent.source === "local" ? c.dim(" (local)") : c.dim(" (global)");
466481 writeln(
467- ` ${c.magenta(`@${agent.name}`.padEnd(26))} ${c.dim(agent.description)}${tag}`,
482+ ` ${c.magenta(`@${agent.name}`.padEnd(26))} ${c.dim(agent.description)}${modeTag}${tag}`,
468483 );
469484 }
470485 }
@@ -536,6 +551,10 @@ export async function handleCommand(
536551 handleRalph(ctx);
537552 return { type: "handled" };
538553
554+ case "agent":
555+ handleAgent(ctx, args);
556+ return { type: "handled" };
557+
539558 case "mcp":
540559 await handleMcp(ctx, args);
541560 return { type: "handled" };
@@ -544,9 +563,6 @@ export async function handleCommand(
544563 handleNew(ctx);
545564 return { type: "handled" };
546565
547- case "review":
548- return await handleReview(ctx, args);
549-
550566 case "help":
551567 case "?":
552568 handleHelp(ctx, custom);