Skip to content

Commit d9f33fc

Browse files
aseembits93claude
andcommitted
feat: instruct Claude Code to review optimizations in subagent mode
The subagent action instructions now tell Claude Code to read the original source, compare it against the optimized code, and check for correctness and quality issues before presenting the result to the user. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 417623f commit d9f33fc

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

codeflash/cli_cmds/console.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,12 +469,22 @@ def subagent_log_optimization_result(
469469
xml.append(f' <optimized-code file="{escape(str(path))}">{escape(new_code[path])}</optimized-code>')
470470
xml.append(" <action>")
471471
xml.append(" First, present a short summary: function name, performance improvement, and explanation.")
472+
xml.append(" Then, review the proposed optimization yourself before presenting it to the user:")
473+
xml.append(" - Read the original source file to understand the full context around the function.")
474+
xml.append(" - Compare the original code with the optimized code in the diff above.")
475+
xml.append(" - Check for correctness issues: changed semantics, dropped edge cases, altered error handling,")
476+
xml.append(" missing side effects, or differences in return values/types.")
477+
xml.append(" - Check for code quality issues: readability regressions, removed comments or docstrings")
478+
xml.append(" that were valuable, unnecessary complexity, or non-idiomatic patterns.")
479+
xml.append(" - State your assessment: whether the optimization looks correct and safe to apply,")
480+
xml.append(" or flag specific concerns the user should be aware of.")
481+
xml.append(" After your review:")
472482
xml.append(" If you are running inside an IDE (VS Code, Cursor, Windsurf, etc.):")
473483
xml.append(" For each optimized-code element, use the Write tool to write the optimized code to the file.")
474484
xml.append(" This will surface the diff in the IDE's native diff view for the user to accept or reject.")
475485
xml.append(" If you are running in a terminal without an IDE connection:")
476486
xml.append(" Present this optimization to the user using AskUserQuestion.")
477-
xml.append(" Show the function name, performance improvement, and explanation as the question text.")
487+
xml.append(" Show the function name, performance improvement, explanation, and your review as the question.")
478488
xml.append(" Provide two options: 'Apply' (write the optimized code to the file) and 'Reject' (do nothing).")
479489
xml.append(
480490
" Put the full diff in the 'Apply' option's markdown preview so the user can review the exact changes."

0 commit comments

Comments
 (0)