sg
Verified for current stable LTS
Sg Command: Rewrite Code Current Directory
Use for rewrite code current directory with Sg. Exact CLI syntax to rewrite code current directory using Sg.
When to use this: Use for rewrite code current directory with Sg.
Command Syntax
sg run --pattern '<foo>' --rewrite '<bar>' --lang <python> sg run --pattern '<foo>' --rewrite '<bar>' --lang <python> Command Breakdown
--pattern- Command Option
- Tool-specific option used by this command invocation.
--rewrite- Command Option
- Tool-specific option used by this command invocation.
--lang- Command Option
- Tool-specific option used by this command invocation.
FAQ
Purpose: Exact syntax to rewrite code current directory using Sg.
Test path: Replace placeholders and run destructive commands in a disposable workspace first.
Flag behavior: Tool version, platform, and shell can change behavior.
Improve This Command
Suggest a correction, safer default, or version-specific note for this entry.
Related Operations
Sg Command: Output Json Extract Info
sg run --pattern '<Some($A)>' --rewrite '<None>' --json | jq '<.[].replacement>' | jless Sg Command: Scan Queries Interactive sg scan --interactive Sg Command: Visualize Code Changes sg run --pattern '<useState<number>($A)>' --rewrite '<useState($A)>' --lang <typescript> Ast Grep Command: Search For Pattern In Files ast-grep run {-p|--pattern} '<pattern>' {path/to/file} Ast Grep Command: Search Pattern Files ast-grep run -p '<pattern>' <path/to/file>