.claude/skills/bytecode-compare/SKILL.md
Compare our compiler's bytecode output against tclsh reference disassembly (8.5, 8.6, 9.0). Use when verifying bytecode correctness, investigating instruction sequence differences, or checking that our codegen matches C Tcl.
npx skillsauth add bitwisecook/tcl-lsp bytecode-compareInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Compares the bytecode produced by our compiler pipeline (lexer → lowering → IR → CFG → codegen) against tclsh reference disassembly (8.5, 8.6, 9.0) for a set of 30 test snippets.
Run from the project root:
python3 .claude/skills/bytecode-compare/bytecode_compare.py [-v VERSION] <subcommand> [args...]
| Flag | Description |
|---|---|
| -v, --version | Tcl version to compare against: 8.5, 8.6, 9.0 (default: 9.0) |
| Subcommand | Arguments | What it does |
|---|---|---|
| all | | Compare all 30 snippets, show summary table |
| diff | <snippet> | Detailed instruction-by-instruction diff for one snippet (e.g. 08_while) |
| summary | | One-line per snippet: match/mismatch with instruction counts |
| instructions | <snippet> | Side-by-side normalised instruction listing |
| refresh | | Regenerate our bytecode reference and re-compare |
| categories | | Group differences by category (variable access, jumps, opcodes, etc.) |
| versions | <snippet> | Compare one snippet against all Tcl versions (8.5, 8.6, 9.0) |
01_set_simple MISMATCH ours: 3 instrs 9.0: 4 instrs
03_expr_braced MATCH ours: 2 instrs 9.0: 2 instrs
22_puts_invoke MATCH ours: 4 instrs 9.0: 4 instrs
MATCH means identical normalised instruction sequences. MISMATCH means differences exist.
=== 08_while ===
9.0: (0) push1 0 # "i"
9.0: (2) push1 1 # "0"
9.0: (4) storeStk
ours: (0) push1 0 # "0"
ours: (2) storeScalar1 %v0 # var "i"
--- variable access: storeStk (name-based) vs storeScalar1 (LVT-indexed)
Groups all divergences into categories:
server/compiler/codegen.py — verify instruction sequencessummary as a gate check$ARGUMENTS
development
Apply LSP optimiser suggestions to a Tcl file and explain why each optimisation is safe and beneficial. Covers constant folding, propagation, dead code elimination, strength reduction, and expression canonicalisation. Use when optimising Tcl code, improving .tcl file performance, refactoring Tcl scripts for efficiency, or applying language server optimisation suggestions.
development
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.
development
Create Tk GUI code from a description with proper widget hierarchy. Generates the code, validates with the LSP analyser (including TK-specific checks), and iterates until clean. Use when creating Tk GUIs, generating Tcl/Tk code from descriptions, building Tk widget layouts, or scaffolding Tk applications.
development
Run full LSP validation on a Tcl file and produce a categorised report of all issues: errors, security, style, and optimiser suggestions. Use when validating Tcl code, linting .tcl files, checking Tcl script quality, or running static analysis on Tcl scripts.