Skill v1.0.1
currentAutomated scan100/100+4 new
name: irule-optimise description: "Apply LSP optimiser suggestions to an F5 iRule and explain why each optimisation is safe and beneficial. Covers constant folding, propagation, dead code elimination, strength reduction, and expression canonicalisation. Use when optimising iRule code, improving iRule performance, applying F5 iRule optimisations, or refactoring iRules for efficiency." allowed-tools: mcp__tcl-lsp__optimize, mcp__tcl-lsp__analyze, Read, Edit metadata: version: "1.0.1"
iRule Optimise
Apply the optimiser's rewrites to an iRule and explain each one.
Steps
- Read
../_prompts/irules_system.md, then the iRule. - Call
mcp__tcl-lsp__optimizewith the contents assource(profile
defaults to the user's config.ini [optimiser] profile, else full; a named one wins; aggressive iterates to a fixpoint). On a tool error (e.g. a parse failure) report it and suggest fixes; on no findings report the code is already well-optimised.
- Apply the returned optimised source with Edit.
- For each optimisation, one or two sentences: why it preserves behaviour,
and what it gains on the hot path. A grouped item (constant propagation O100–O105 whose dead store O109 was then eliminated) is one transformation — explain it as one.
- Re-validate with
mcp__tcl-lsp__analyzeon the rewritten source; revert
any optimisation that introduced an issue and say why.
- Summarise what was applied.
Optimisation codes
Full table: docs/generated/optimisation_codes.md. Categories:
- Readability (O111, O114, O115, O117, O120, O128): idiomatic rewrites (incr, eq/ne, bracing)
- Constant folding/propagation (O100, O101, O102, O103, O105, O110, O113, O116, O118, O129): inline and simplify known values
- Pattern recognition (O104, O119, O130): fold string chains, pack consecutive sets
- Dead code (O107, O108, O109, O112, O124, O126): remove unreachable or unused code and stores
- Code motion (O106, O125, O127): hoist, sink, and inline assignments
- Recursion (O121, O122, O123): tail-call rewriting and accumulator hints
Profiles: off; readability (editor default: O111, O114, O115, O117, O120, O128); standard (readability + constant folding + pattern recognition); full (every pass, single pass; CLI/AI default); aggressive (every pass, to a fixpoint).
$ARGUMENTS