Practical playbook for AI agents using msr, nin, and vscode-msr aliases.
This document focuses on execution strategy (what to run, in what order, and why), not full parameter dictionaries.
Parameter schemas:
Human scenario catalog:
This guide is optimized for agent tasks:
- reduce token consumption
- avoid risky edits
- keep outputs script-friendly
- compose msr + nin + aliases into repeatable workflows
It intentionally avoids duplicating long option tables already maintained in reference docs.
These rules prevent the most common agent mistakes:
-
-Pstrips location info In msr,-P(--no-path-line) removes location prefix (file:row:orfile:row:col:). Use-Ponly when location info is not needed (pipe extraction / text-only output). Prefer:-Cwhen location is needed-PCwhen pure text is needed
-
Location is not always
file:row:col:msr /find-*/gfind-*may output:file:row:(no column), orfile:row:col:(with column) Column appears only when--out-indexis enabled (orMSR_OUT_INDEX=1).
-
-Ihas opposite meanings in msr vs nin- msr
-I= suppress extra info (--no-extra) - nin
-I= route summary to stdout (--info-normal-out)
Never assume cross-tool semantic equivalence for short flags. See Parameter Semantic Differences.
- msr
-
Keep summary by default; avoid unnecessary
-M/-ASummary is stderr by default and does not pollute stdout pipes. It is useful for diagnostics and count parsing. Prefer keeping summary unless strict silent mode is required. -
Cross-platform count safety: use
--exitwhen thresholds matter On non-Windows shells, large counts can be truncated. Use--exit gt255-to-255(orgt127-to-127for MinGW) for stable threshold gates. -
BOM replacement is risky without explicit intent
--forceon non-UTF8 BOM files converts output to UTF-8 no BOM. Use-RK --forceonly when encoding conversion is acceptable. -
Always bound output when exploring unknown scope Start with
-H N(and-Jfor early global stop when applicable).
-
Scope selection
- git repo and tracked files preferred:
gfind-* - include untracked files / no git:
find-* - sibling repos:
rgfind-*
- git repo and tracked files preferred:
-
Intent selection
- content search:
*-{ext} -t .../-x ... - definition/reference: prefer
-ref+ disambiguation (-x class,-x function) when-defis unstable
- content search:
-
Output mode
- with location for navigation (
file:row:orfile:row:col:):-C - pure text for pipes:
-PC
- with location for navigation (
-
Risk mode
- read-only exploration first
- replace only after preview and scope verification
Alias runtime discovery: vscode-msr AI Agent Reference.
Use the same 3-step pipeline for all replacements.
# Use gfind-{ext} when language is known (most cases); use gfind-small only for unknown/mixed file types
gfind-cs -t "\bOldSymbol\b" -l -PC
gfind-cs -t "\bOldSymbol\b" -H 30 -Cgfind-cs -t "\bOldSymbol\b" -o "NewSymbol" -j -Cgfind-cs -t "\bOldSymbol\b" -o "NewSymbol" -RKThen verify residual hits:
gfind-cs -t "\bOldSymbol\b" -H 1 -JFor block-scoped replacement (INI/XML/YAML fragments), use -b/-Q patterns from msr User Guide.
# existence
msr -p file.py -t "\bTargetSymbol\b" -H 1 -J
# count mode (no matched line output)
msr -p file.py -t "\bTargetSymbol\b" -H 0gfind-py -t "class\s+TargetProcessor\b" -l -PC
msr -p src/target/processor.py -t "class\s+TargetProcessor\b" -U 2 -D 25 -C# Use gfind-{ext} for known language; gfind-small for broad/unknown file types
gfind-py -t "\bTargetSymbol\b" --nt "^.{300,}$" -H 40 -C- navigation output:
-C - pure extraction output:
-PC - avoid unnecessary decorative verbosity
msr -rp logs/ -f "\.log$" -t "(\w+Exception)" -PC | nin nul "(\w+Exception)" -pd --sum -H 20git diff --name-only HEAD~1 | msr -t "\.(cs|java|ts|py)$" -PC > /tmp/scope.txt
msr -w /tmp/scope.txt -t "\S\s+$" --no-check -l
msr -w /tmp/scope.txt -t "\bdeprecatedApi\b" --no-check -H 1 -Jmsr -rp services/ -f "\.log$" -F "(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})" -B "2024-01-15 10:00:00" -E "2024-01-15 10:30:00"msr -p config.ini -b "^\[production\]" -Q "^\[" -y -t "host\s*=\s*old-host" -o "host = new-host" -RKRecommended agent usage:
- yes/no gate:
-H 1 -J(safe cross-platform) - count mode:
-H 0(returns count; no matched-line stdout)
Important platform caveat:
- non-Windows shells truncate exit code width
- for large counts, use capped exit strategy or parse summary
- full behavior: Return Value Cross-Platform Behavior
Use this guide as orchestration layer, and defer details to source docs:
- msr parameters: msr AI Agent Reference
- nin parameters: nin AI Agent Reference
- shared semantics (encoding, exit, color, short-flag differences): msr and nin Shared Reference
- alias runtime rules: vscode-msr AI Agent Reference
- human scenario examples: Practical Use Cases and Tool Comparisons
- quick onboarding: Quick Start