Srgn cli

From OutlineDriven/odin-codex-plugin · View interactive version

Srgn cli is an AI agent skill from the GitHub repository OutlineDriven/odin-codex-plugin. Build safe, syntax-aware srgn CLI commands for source-code search and transformation. Use for srgn commands, scoped refactors (comments/docstrings/imports/functions), multi-file rewrites with --glob, tree-sitter queries, or CI checks with --fail-any/--fail-none.

How to use this skill

Skill file

srgn CLI

Overview

Use this skill to convert user intent into precise srgn commands with safe defaults.

Focus on CLI workflows for search, transformation, scoped migrations, and lint-like checks.

Workflow Decision Tree

  1. Classify the request.
  1. Identify scope strategy.
  1. Identify action strategy.
  1. Apply safety controls.
  1. Choose output mode.
  1. Validate behavior.

Safety Protocol

  1. Default to non-destructive behavior first.
  1. For file edits, require preview path.
  1. Protect shell parsing boundaries.
  1. --glob accepts exactly one pattern (cannot repeat).

fd -e <ext> --strip-cwd-prefix -x srgn --glob '{}' --stdin-detection force-unreadable [OPTIONS] [PATTERN]

  1. Use the narrowest scope that solves the task.
  1. Treat -d and -s as high-risk operations.

Command Construction Template

Use this template when building commands:

srgn [LANGUAGE_SCOPE_FLAGS...] [GLOBAL_FLAGS...] [ACTION_FLAGS...] [SCOPE_REGEX] -- [REPLACEMENT]

Build incrementally:

  1. Scope first.
  1. Regex filter second.
  1. Action third.
  1. File mode flags fourth (if needed).
  1. CI behavior last.

High-Value Task Recipes

  1. Rename module imports in Python only:
srgn --python 'imports' '^old_pkg' --glob '**/*.py' --dry-run -- 'new_pkg'
  1. Convert print calls to logging in Python call-sites only:
srgn --python 'function-calls' '^print$' --glob '**/*.py' --dry-run -- 'logging.info'
  1. Rename Rust use prefixes without touching strings/comments:
srgn --rust 'uses' '^good_company' --glob '**/*.rs' --dry-run -- 'better_company'
  1. Remove C# comments only:
srgn --csharp 'comments' -d '.*'
  1. Search for Rust unsafe language keyword usage only:
srgn --rust 'unsafe'
  1. Fail CI if undesirable pattern appears in Python docstrings:
srgn --python 'doc-strings' --fail-any 'param.+type'
  1. Force machine-readable output for downstream parsers:
srgn --python 'strings' --stdout-detection force-pipe '(foo|bar)'
  1. Preview multi-file changes with deterministic ordering:
srgn --typescript 'imports' '^legacy-lib' --glob 'src/**/*.ts' --sorted --dry-run -- 'modern-lib'

For broader, categorized examples, load references/cli-cookbook.md.

Failure and Debug Playbook

  1. No matches when matches are expected.
  1. Too many matches.
  1. Wrong files targeted.
  1. --glob used multiple times.
  1. Unclear behavior across multiple language scopes.
  1. Special characters misinterpreted as regex.

Reference Loading Guide

Load reference files based on request type:

  1. references/cli-cookbook.md
  1. references/language-scopes.md
  1. references/advanced-patterns.md
  1. references/deepwiki-recursive-notes.md

Intent-to-Command Map

Use this map to respond quickly:

  1. "Rename imports safely"
  1. "Update function calls only"
  1. "Only comments/docstrings"
  1. "CI should fail if pattern appears"
  1. "CI should fail if required pattern is missing"
  1. "I need parseable output"
  1. "Regex escaping is painful"

Execution Checklist

Before returning a final command, verify:

  1. Scope is minimal and syntax-aware where possible.
  2. Replacement argument is after -- (if replacement is used).
  3. Globs are quoted.
  4. --dry-run is present for file edits unless user requested direct apply.
  5. Join semantics are explicit when multiple language scopes are used (-j vs default intersect).
  6. Failure flags align with user intent (--fail-any, --fail-none, --fail-no-files).
  7. Output mode is explicit if user needs machine parsing.
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.