snippets-to-scripts

A command that finds Bash code blocks in Markdown files and turns them into standalone shell scripts.

In plain words
What is it for?
Use it to scan selected Markdown files, create scripts in a chosen output directory, and set the paths shown in the documentation. A dry-run option previews the changes.
Why use it?
Commands copied through documentation can become inconsistent or difficult to reuse and test. Extracting them into scripts gives the repository reusable files while updating the documentation paths that refer to them.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/patrickclery/ruly/snippets-to-scripts
Clone the repo
git clone --depth 1 https://github.com/patrickclery/ruly
Per session 11 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,498 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00011 $0.02498
Opus 5 $0.00005 $0.01249
Sonnet 5 $0.00002 $0.00500
Haiku 4.5 $0.00001 $0.00250

Measured 2d ago against content hash 713ade6be830, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade B, and why

snippets-to-scripts scanned grade B with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Asks for rootmediumPrivilege escalation

A mod that escalates privileges can change anything on the machine, not only the project.

sudo mkdir -p "$DEPLOY_DIR"
commands/snippets-to-scripts.md · 392 lines

How it starts

The opening of the file, as written. The whole thing — 392 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Snippets to Scripts

Overview

The /snippets-to-scripts command is a Ruly tool that scans markdown files in any repository for bash code snippets and extracts them into standalone shell scripts. This promotes code reuse, maintainability, and testability across your projects.

Path Strategy

When extracting scripts from a target repository:

  • Extraction Location: Scripts are created in the target repo (default: bin/ or specified via --output-dir)
  • Documentation References: Updated to use consistent paths (default: .ruly/bin/ or specified via --reference-path)
  • Installation Path: Where scripts will be deployed in production environments (.ruly/bin/)

This allows:

  • Scripts to be extracted and stored in the target repository
  • Documentation to reference the final installation paths
  • Flexible deployment strategies per project

Usage

/snippets-to-scripts [file-pattern] [options]

Arguments

  • file-pattern - Glob pattern for files to scan (default: **/*.md)
  • --output-dir - Where to create extracted scripts (default: bin/)
  • --reference-path - Path to use in documentation references (default: .ruly/bin/)
  • --dry-run - Preview changes without creating files
  • --min-lines - Minimum lines for extraction (default: 5)
  • --interactive - Prompt for each extraction
  • --target-repo - Path to target repository (default: current directory)

Examples

# Extract from all markdown files in current repo
/snippets-to-scripts

# Extract from specific directory
/snippets-to-scripts "docs/**/*.md"

# Extract with custom output and reference paths
/snippets-to-scripts --output-dir="scripts/extracted" --reference-path="bin/project"

# Preview what would be extracted
/snippets-to-scripts --dry-run

# Extract from another repository
/snippets-to-scripts --target-repo="../other-project" "**/*.md"

# Extract only larger snippets
/snippets-to-scripts --min-lines=10

Process

Step 1: Scan for Snippets

The command searches for bash/sh code blocks in markdown:

Read the full file on GitHub · 392 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 392 lines · 11 tokens per session scan B 713ade6be830

Subscribe to this mod's changes

snippets-to-scripts is a command published in the GitHub repository patrickclery/ruly (5 stars, last pushed 7d ago), licensed MIT. It adds 11 tokens to every session and 2,498 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it B with 1 finding (asks for root). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.