| name | irule-migrate |
| description | Convert nginx, Apache, or HAProxy configuration to an F5 BIG-IP iRule. Detects the source format and applies appropriate construct mappings. Use when migrating load balancer config to iRules, converting nginx rules to F5, translating Apache RewriteRule to iRules, or converting HAProxy ACLs to iRule logic. |
| allowed-tools | Bash, Read, Write |
iRule Migrate
Convert load balancer configuration from nginx, Apache, or HAProxy to an iRule.
Steps
-
Read the domain knowledge from ai/prompts/irules_system.md (includes migration patterns)
-
Read the source configuration file
-
Detect the format and apply these mappings:
nginx:
location -> switch -glob [HTTP::path] or class match
proxy_pass -> pool <pool_name>
rewrite -> HTTP::uri / HTTP::redirect
add_header -> HTTP::header insert
return 301/302 -> HTTP::redirect
if ($host) -> string match or class match on [HTTP::host]
Apache:
RewriteRule -> HTTP::uri / HTTP::redirect
RewriteCond -> if/switch conditions
ProxyPass -> pool <pool_name>
Header set -> HTTP::header insert/replace
<VirtualHost> -> switch on [HTTP::host]
<Location> -> switch on [HTTP::path]
HAProxy:
acl -> if conditions or class match
use_backend -> pool <pool_name>
http-request redirect -> HTTP::redirect
http-request set-header -> HTTP::header replace
http-request add-header -> HTTP::header insert
frontend bind -> handled by virtual server (note in comments)
-
Generate the iRule following security best practices
-
Write to a file and validate:
uv run --no-dev python ai/claude/tcl_ai.py diagnostics $FILE
-
If the tool fails (e.g. parse error), report the error and adjust the generated code
-
Fix any issues and re-validate (up to 5 iterations)
-
If issues persist after 5 iterations, report what was migrated and what remains
-
Add comments explaining the mapping from the original config
-
Note anything that cannot be directly translated (e.g., backend health checks, rate limiting)
$ARGUMENTS