Back to skills
SKILL.md
Max Optimize
ASecurityAutonomous multi-round audit, refactor & benchmark loop to `PERFECT_CONVERGED` (native or 1–3 models). Use for `max-optimize`, "tối ưu tuyệt đối", "review phân tích và sửa lại tới khi hoàn hảo", "lặp tới khi hoàn hảo nhất"; not review-only.
- 2 stars
- 0 votes
- 0 copies
- 3 views
- Added December 4, 2026
Works with
Security analysis
100/100npx -y skills add hothiennhan021/ai-review-skills --skill max-optimize --agent claude-codeAre you the author of Max Optimize?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/hothiennhan021-max-optimize)---
name: max-optimize
description: >-
Autonomous multi-round audit, refactor & benchmark loop to `PERFECT_CONVERGED`
(native or 1–3 models). Use for `max-optimize`, "tối ưu tuyệt đối", "review
phân tích và sửa lại tới khi hoàn hảo", "lặp tới khi hoàn hảo nhất"; not
review-only.
---
# Max Optimize v3 (`max-optimize`)
Engine: `$af = "$env:USERPROFILE\.gemini\config\ai-flow.ps1"` (fallback `"D:\ai-review-skills\scripts\ai-flow.ps1"`).
## 1. Cascading Models
- **None (Default)**: Native model = Brain & Worker; `flash` subagents for digests; fresh **Sharded Cold-Eye Reviewers** (`run_workflow` `parallel()` / `invoke_subagent` `inherit`) prevent self-rubber-stamping.
- **`M1`**: `M1` = Brain & Final Judge; Native edits & verifies.
- **`M1, M2`**: `M1` = Brain & Judge; `M2` = Worker & Verifier.
- **`M1, M2, M3`**: `M1` (Brain) → `M2` (Inspector) → `M3` (Worker).
- **CLI Bindings**: `& $af -Action ask-claude -Profile brain|review|write [-Model <m>] -Effort medium|high -InFile <in> -OutFile <out>` (use `-Profile review` whenever `map` reports `truncated=True`); `& $af -Action ask-codex -Mode readonly|write [-Model <m>] -Effort medium|high [-SchemaFile .ai-workflow/strict-schema.json] -InFile <in> -OutFile <out>` (use `-Effort high` for `M1` deep root-cause / disputed `[P0]` concurrency, timing, or algorithmic hotspots). *(PS 5.1 `cmd --%` fallbacks: `cmd --% /d /s /c ""claude.exe" -p --tools="" --disable-slash-commands --strict-mcp-config --no-chrome --exclude-dynamic-system-prompt-sections --no-session-persistence --effort medium < in.md > out.md 2> err.log"` in `C:\Users\Public\ai-flow-clean-cwd` [or `--permission-mode bypassPermissions` in `$ProjectDir`]; `cmd --% /d /s /c ""codex.exe" exec -s read-only --ephemeral -c "mcp_servers={}" -c "plugins={}" -c "notify=[]" --disable plugins --disable apps --disable browser_use --disable computer_use --disable image_generation -o out.md - < in.md > log.txt 2> err.log"`, or `-s workspace-write -c "approval_policy='never'"` for write)*.
## 2. Six-Dimension Rubric
1. **`[P0]` Correctness**: Logic/FSM, bounds/null/overflow, race/lock/re-entrancy, RTL clock/reset/timing.
2. **`[P1]` Efficiency**: Complexity, hot-path allocs, batching, handle/timer disposal, LUT/FF/DSP/BRAM/Fmax.
3. **`[P1]` Architecture**: Clean boundaries, zero dead/duplicate code, single source of truth.
4. **`[P1]` Security & Secrets**: Parameterized queries, input validation, zero secrets in tree/history.
5. **`[P1]` Verification**: Regression tests + reproducible benchmarks vs. `BASELINE.md`.
6. **`[P2]` Zero-Nit Polish**: `0` warnings, accurate docs.
## 3. Perfection Loop (`MAX_ROUNDS = 10`, Hands-Off)
1. **Phase 0 (Baseline)**: Run `& $af -Action init`, `map -Targets`, `snapshot -Round 0`, and `verify -CommandLine "<cmd>"` → save `.ai-workflow/BASELINE.md` + `STATE.md`.
2. **Step 1 (Sharded Audit → Delta → Cold-Eye Gate)**:
- **`> 15` files (R1)**: Fan out 4 parallel shards (`Core/FSM`, `Concurrency`, `Security/Secrets`, `Perf/Tests`) emitting `strict-schema.json` or JSONL `{"id":"F-01","s":"P0","f":"path:line","w":"trace","x":"fix"}`.
- **Stateful `run_workflow`**: Within a single `run_workflow` script, keep shard handles (`h = agent(...)`) and pass deltas via `h(delta)` (handles do not cross separate `run_workflow` calls).
- **Follow-Up (`R2+`)**: `& $af -Action slice-diff -Round $k` + `pack` (`[Rubric] + [BASELINE.md] + [EOF ISSUES_LEDGER.md] + [DIFF_SLICE.md]`).
- **Convergence Gate**: When Delta Slice hits `0` issues, run **1 fresh cold-eye audit on `-FullCumulative`** to certify **`PERFECT_CONVERGED`**.
3. **Step 2 (Fix & Ratchet)**: Append findings (`ledger-append`), batch-fix all `[P0]`–`[P2]` + tests, and run `-Action verify`. Reject any edit that adds warnings, drops assertions, regresses `BASELINE.md`, or oscillates `A → B → A`. Fail-fast to `STATE.md` on CLI quota/auth error (never swap user-chosen models).
**Report**: (1) Models/shards, (2) Rounds & ledger count, (3) Key fixes, (4) `BASELINE.md` vs. Final metrics.
Attribution
Related skills
View all in ai-agents →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.