* Add Java/Kotlin detection to top-level language router Adds pom.xml, build.gradle, build.gradle.kts, settings.gradle, and settings.gradle.kts as markers that route to the codeflash-java router. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Add Java/Kotlin agent definitions for all optimization domains 10 agents covering the full optimization pipeline: - codeflash-java: router/team lead for domain detection - codeflash-java-setup: environment detection (build tool, JDK, profiling tools) - codeflash-java-deep: cross-domain optimizer (default) - codeflash-java-cpu: data structures, algorithms, JIT deopt, JMH benchmarks - codeflash-java-memory: heap/GC tuning, escape analysis, leak detection - codeflash-java-async: virtual threads, lock contention, CompletableFuture - codeflash-java-structure: class loading, JPMS, startup time, circular deps - codeflash-java-scan: quick cross-domain diagnosis via JFR/jdeps/GC logs - codeflash-java-ci: GitHub webhook handler for Java PRs - codeflash-java-pr-prep: JMH benchmarks and PR body templates Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Add Java domain reference guides for all optimization domains 6 guides covering deep domain knowledge for agent consumption: - data-structures: collection selection, autoboxing, JIT patterns, sorting - memory: JVM heap layout, GC algorithms and tuning, escape analysis, leaks - async: virtual threads, structured concurrency, lock hierarchy, contention - structure: class loading, JPMS, CDS/AppCDS, ServiceLoader, Spring startup - database: JPA N+1, HikariCP, pagination, batch operations, EXPLAIN plans - native: JNI, Panama FFM API, GraalVM native-image, Vector API Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Add Java optimization skills: session launcher and JFR profiling - codeflash-optimize: session launcher with start/resume/status/scan/review - jfr-profiling: quick-action JFR profiling in cpu/alloc/wall modes Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Slim Java agents to match Go's concise ~175-line pattern Move inline code examples, antipattern encyclopedias, JMH templates, and deep-dive sections from agent prompts into reference guides. Agents now contain only: target tables, one-liner antipatterns, reasoning checklists, profiling commands, and keep/discard trees. Line counts (before → after): cpu: 636 → 181 memory: 878 → 193 async: 578 → 165 structure: 532 → 167 deep: 507 → 186 scan: 440 → 163 Average: 595 → 176 (vs Go's 175) Adds to data-structures/guide.md: - Collection contract traps table - Reflection → MethodHandle migration pattern - JMH benchmark template Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Fix Makefile build: use rsync merge and portable sed -i Two bugs in the build target: 1. cp -R created nested dirs (agents/agents/, references/references/) instead of merging language overlay into shared base. Fix: rsync -a. 2. sed -i '' is macOS-only; fails silently on Linux. Fix: sed -i.bak (works on both macOS and Linux), then delete .bak files. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Add HANDOFF.md session lifecycle to Java agents Java agents could read HANDOFF.md on resume but never wrote or updated it. A session that hit plateau would lose all context — what was tried, what worked, why it stopped, what to do next. Changes: - Deep agent: init HANDOFF.md on fresh start, record after each experiment, write Stop Reason + learnings.md on session end - Domain agents (CPU, memory, async, structure): record to HANDOFF.md after each keep/discard, write session-end state - Handoff template: make language-agnostic (was Python-specific), add Session status, Strategy & Decisions, and Stop Reason fields Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Close 11 gaps between Java and Python plugins Add missing sections to Java deep agent: experiment loop depth (12 steps), library boundary breaking, Phase 0 environment setup, CI mode, pre-submit review, adversarial review, team orchestration, cross-domain results schema, and structured progress reporting. Add polymorphic dispatch safety to CPU agent and data-structures guide. Add diff hygiene to CPU agent. Add native reference to router. Create two new reference files: library-replacement.md (Guava/Commons/ Jackson/Joda replacement tables) and team-orchestration.md (full dispatch and merge protocol). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
4.6 KiB
| name | description | allowed-tools | argument-hint |
|---|---|---|---|
| codeflash-optimize | Profiles code, identifies bottlenecks, runs benchmarks, and applies targeted optimizations across CPU, async, memory, GC, and codebase structure domains. Use when the user asks to "optimize my code", "start an optimization session", "resume optimization", "check optimization status", "make this faster", "reduce memory usage", "reduce GC pauses", "fix slow functions", "run performance experiments", "scan for performance issues", or "diagnose my code". | Agent, AskUserQuestion, Read, SendMessage | [start|resume|status|scan|review] |
Optimization session launcher for Java/Kotlin projects. Launches the appropriate agent directly.
For start (or no arguments)
Step 1. Use AskUserQuestion to ask:
Before I start optimizing, is there anything I should know? For example: areas to avoid, known constraints, things you've already tried, or specific files to focus on. Or just say 'go' to proceed.
Step 2. After the user responds, launch the language router in the foreground:
- Agent type:
codeflash-java - run_in_background:
false - Prompt: The prompt must contain exactly three parts in this order, and nothing else:
Part 1 — the AUTONOMOUS MODE directive (copy verbatim):
AUTONOMOUS MODE: The user has already been asked for context (included below). Do NOT ask the user any questions — work fully autonomously. Make all decisions yourself: generate a run tag from today's date, identify benchmark tiers from available tests, choose optimization targets from profiler output. If something is ambiguous, pick the reasonable default and document your choice in HANDOFF.md.
Part 2 — the user's original request (verbatim).
Part 3 — the user's answer from Step 1 (verbatim).
Do not add any other instructions — the router sets up the project, creates the team, launches the optimizer in the background, and coordinates the session. Progress streams directly to the user.
For resume
Launch the language router:
- Agent type:
codeflash-java - run_in_background:
false - Prompt: The directive below (verbatim), followed by
resumeand the user's request:
AUTONOMOUS MODE: Work fully autonomously. Do NOT ask the user any questions. Read session state from .codeflash/ and continue where the last session left off.
For status
If an optimizer agent is currently running (the session was started or resumed earlier in this conversation): Use SendMessage(to: "optimizer", summary: "Status request", message: "Report your current status: experiments run, keeps/discards, current target, cumulative improvement.") and show the response to the user.
Otherwise (no active agent in this conversation): Read .codeflash/results.tsv and .codeflash/HANDOFF.md and show:
- Total experiments run (keeps vs discards)
- Current branch
- Best improvement achieved vs baseline
- What was planned next
For scan
Quick cross-domain diagnosis. Profiles CPU, memory, GC behavior, concurrency patterns, and project structure in one pass without making any changes.
Launch the scan agent directly:
- Agent type:
codeflash-java-scan - run_in_background:
false(wait for the result — scan is fast) - Prompt:
scanfollowed by the user's scope if specified (e.g., a specific test or module), otherwise justscan.
Show the scan report to the user. The report includes ranked targets across all domains and recommendations. If the user wants to proceed, they can run /codeflash-optimize start.
For review
Launch the review agent directly:
- Agent type:
codeflash-review - run_in_background:
false(wait for the result) - Prompt: Include the user's request (branch name, PR number, or 'current changes') and any available context:
Review the following: <user's request>
## Session Context
<.codeflash/results.tsv contents if it exists>
<.codeflash/HANDOFF.md contents if it exists>
Show the verdict and key findings to the user.
Mid-session steering
The router runs in the foreground coordinating the session. While it's active, its progress output streams directly to the user. If the user needs to interrupt (e.g., to change focus or stop early), they can press Escape or Ctrl+C. The optimizer (background) may survive the interruption — use status to check.
After an interruption, the user can relay feedback to a still-running optimizer:
SendMessage(to: "optimizer", summary: "User feedback",
message: "<user's instruction verbatim>")
If no optimizer is currently running, tell the user there's no active session and suggest /codeflash-optimize resume.