This is the command script used to generate input for my Gain Ground run, used for every stage from 1-7 through completion (almost 90% of the run). It's generic enough that many games could be tracked using it by scrapping the contents of the stageScripts and syncPoints tables, although it has some limits since it was designed for Gain Ground: It does not support holding non-directional buttons for longer than a frame and does not support left+right or down+up.
The way this works is that the run is chopped up into units, which was done so that early-level edits could be easily resynchronized. Originally, this was done by tagging commands with the original frame numbers and adjusting the actual start frame if that changed. This later changed to using 0 as the starting frame number instead and having the HUD script display the relative frame number.
This script will generate input for a unit up through the last frame that has a numbered command, which means things like continuous motion will only work if there's a later command to keep the input block going (even if the command is a "stop"). Most stages were made by first adding a "stop" 1000 frames in the future.