Skip to main content

rp usages

rp usages walks your working tree, detects RedPennon SDK call sites, captures the variable key argument, and prints every reference. It is side-effect-free — it never posts anything. The GitHub Action runs it with --format json and uploads the result.

rp usages
rp usages --format json -o usages.json

How matching works​

The scanner looks for SDK call sites and captures the key — it does not need a list of your keys. The defaults cover the real SDK shapes:

LanguageDetected calls
Nodeclient.variable('key'), client.variableValue('key', …), batch client.variables([...])
Goclient.Variable(ctx, "key", …), client.VariableValue(ctx, "key", …)
Pythonclient.variable('key'), client.variable_value('key'), batch client.variables([...])

Matches on full-line comments are ignored for the built-in patterns (//, /*, * in TypeScript, JavaScript and Go; # in Python), and a call whose key sits on a following line is still matched:

client.variable(
'dark-mode',
)

Custom --match-pattern regexes are applied exactly as written.

Batch calls carry several keys in one call, so the array form is captured as multiple keys, not one. Captured keys that don't exist in the project are still reported; --only-unused cross-checks them against rp keys.

Flags​

FlagDescription
--format console|jsonOutput format. console (default) is human-readable; json is machine-parseable.
-o, --output <file>Write output to a file.
--include <glob>Restrict the scan to matching files (repeatable).
--exclude <glob>Skip matching files (repeatable).
--client-name <name>Treat <name> as an SDK client variable in addition to the defaults.
--match-pattern ext=<regex>Add a custom pattern for files with extension ext (exactly one capture group = the key).
--var-alias <from>=<to>Rewrite a captured key before reporting.
--show-regexPrint the effective patterns and exit.
--only-unusedList only captured keys that are not in the project (needs API access).
--no-apiScan without contacting the API (no credentials needed).
--headlessMachine-parseable output for CI.

Repository config — .redpennon/config.yml​

Run rp repo init to scaffold it. The CLI merges these settings with the built-in defaults.

# .redpennon/config.yml
clientNames:
- client
- featureClient
variableAliases:
old-key: new-key
matchPatterns:
ts: "client\\.variable\\(['\"]([\\w-]+)['\"]\\)"
includeFiles:
- "src/**/*.{ts,tsx,js,go,py}"
excludeFiles:
- "**/*.test.*"
- "**/node_modules/**"
KeyMeaning
clientNamesVariable names treated as SDK clients.
variableAliasesMap a scanned key to a canonical key.
matchPatternsPer-extension regex; exactly one capture group, which is the variable key.
includeFiles / excludeFilesGlobs that bound the scan.

Limits and validation​

  • Custom patterns must compile, contain exactly one capture group, and be at most 500 characters. At most 50 are allowed. The same checks apply to --match-pattern and matchPatterns in the config file.
  • Include globs must be relative to the repository root. Absolute paths and .. segments are rejected.
  • Large files: files over 1 MB are skipped.
  • Snippets: each reference's snippet is capped at 200 characters, and common secret shapes (rpa_ tokens, AWS access keys, Bearer …, password/secret/token assignments) are replaced with [REDACTED].