Deterministic Command Line Parsing
Purpose
This skill keeps command parsing deterministic and reproducible so title derivation does not drift across runs. It is used to classify commands and extract primary targets predictably.
When to Use
- •When parsing terminal
commandLinevalues. - •When adjusting parser rules for new command forms.
- •When debugging title mismatches from command text.
Inputs
- •Raw terminal command line strings.
- •Parsing rules and tokenization constraints.
- •Known command patterns (python, R, shell, node, pytest, and other).
Outputs
- •Stable parse objects (kind/target/title fields).
- •Predictable command classification.
- •Fewer false positives in terminal renaming.
Procedure
- •Tokenize command input deterministically.
- •Segment the primary command portion using deterministic separators.
- •Classify command kind using fixed matching rules.
- •Extract primary target only when rules clearly support it.
Constraints
- •Must:
- •Use deterministic parsing rules.
- •Keep behavior predictable for the same input.
- •Must Not:
- •Depend on runtime side effects or filesystem checks to parse.
- •Infer targets from ambiguous tokens without explicit rules.
- •Avoid:
- •Opportunistic parsing expansions without tests/examples.
Examples
- •Example 1:
- •Context:
python3 "with space.py"is executed. - •Steps:
- •Tokenize with quote-aware handling.
- •Identify python file-run shape.
- •Extract basename target.
- •Expected result:
- •Stable title output for repeated executions.
- •Context:
Verification
- •Run parser examples through unit-test-friendly calls.
- •Confirm same inputs always produce the same parse output.
Notes
The source statement does not define exact grammar depth. Keep deterministic behavior primary and avoid adding non-deterministic heuristics.