Agent skill

Optimize Skill

by meain in meain/dotfiles

Analyze agent skills to find deterministic command chains that should be extracted into scripts.

MITAuto-check passedDevelopment

Install Optimize Skill

skills CLI
$ npx skills add meain/dotfiles --skill optimize-skill -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install meain/dotfiles optimize-skill --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/meain/dotfiles.git skills-src && mkdir -p .claude/skills && cp -r skills-src/agents/.agents/skills/optimize-skill .claude/skills/optimize-skill && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
optimize-skill
GitHub stars
285
Token cost
~2.3k tokens
SKILL.md length
808 words
Files
1
Skills in repo
36
Repo updated
First seen
Licence
MIT

At a glance

Analyze agent skills to find deterministic command chains that should be extracted into scripts.

  • Works in 10 steps: Read the Skill → Identify Command Patterns → Score Each Command Block → …
  • Tasks that involve Refactoring
  • SKILL.md covers When to Use, Principle, What to Extract and Analysis Steps, plus 5 more sections
  • Calls curl, jq and gh; reaches api.github.com

What it does

Optimize Skill is an agent skill from meain/dotfiles. Analyze agent skills to find deterministic command chains that should be extracted into scripts. Follows the principle: use AI to decide which tool to call, not to execute deterministic logic repeatedly. Triggers: /optimize-skill, "optimize this skill", "extract deterministic commands", "refactor this skill", "find command chains to extract"

Its SKILL.md is about 2.3k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Development, covering Refactoring. The repository describes itself as: If there is a shell, there is a way! The licence is MIT.

When your agent uses it

  • Tasks that involve Refactoring

Example prompts

  • “optimize this skill”
  • “extract deterministic commands”
  • “refactor this skill”
  • “/optimize-skill”

Workflow steps

10 steps, taken from the step headings in SKILL.md.

  1. Read the Skill
  2. Identify Command Patterns
  3. Score Each Command Block
  4. Group Related Commands
  5. Propose Scripts
  6. Show Before/After
  7. Estimate Impact
  8. Ask for Confirmation
  9. Implement (if approved)
  10. Document Changes

What it can do on your machine

Read from SKILL.md and the folder at commit f469fb6. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • curl
    • jq
    • gh

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Hosts in commands or code, which the agent is likely to contact:

    • api.github.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Optimize Skill loads about 2.3k tokens when it runs. Until then it costs about 90 tokens; SKILL.md has 808 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~90
When it runs · the whole SKILL.md, loaded when a task matches
~2.3k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from meain/dotfiles at commit f469fb6, republished under its MIT licence (© meain). 808 words, ~2,321 tokens.

Download SKILL.mdSave it as .claude/skills/optimize-skill/SKILL.md (or your agent's skills folder).
name
optimize-skill
description
Analyze agent skills to find deterministic command chains that should be extracted into scripts. Follows the principle: use AI to decide which tool to call, not to execute deterministic logic repeatedly. Triggers: /optimize-skill, "optimize this skill", "extract deterministic commands", "refactor this skill", "find command chains to extract"
user_invocable
true
argument-hint
[path to skill or skills directory]

Optimize Skill - Extract Deterministic Commands

Analyze agent skills and extract multi-step deterministic command chains into standalone scripts.

When to Use

  • User says "optimize this skill", "check if we can improve this skill"
  • User points to a skill directory or SKILL.md file
  • After creating a new skill with complex command sequences
  • Periodic skill maintenance/refactoring

Principle

From "Stop Using AI For This" video:

Don't make AI execute deterministic logic repeatedly. Write the logic once as a script, let AI decide when to call it.

What to Extract

Extract when you see:
  1. Multi-step pipelines — query → filter → transform → output

    bash
    # Before: encoded in skill
    curl ... | jq '.data' | filter | transform
    bash
    # After: single script call
    ~/.agents/skills/foo/scripts/fetch-data.sh
  2. Parallel operations — multiple commands with wait/merge logic

    bash
    # Before: skill describes parallel pattern
    for repo in ...; do cmd & done; wait; merge
    bash
    # After: script handles parallelism
    ~/.agents/skills/foo/scripts/gather-parallel.sh
  3. Complex conditionals — date calculations, token extraction, nested if/else

    bash
    # Before: case statement in skill
    case "$DAY" in Sat) date -d "3 days ago" ;; ...
    bash
    # After: script handles logic
    ~/.agents/skills/foo/scripts/calculate-date.sh
  4. GraphQL/API queries — hardcoded query structure with filtering

    bash
    # Before: 10+ lines of query + curl + jq
    curl -H "..." -d '{"query":"... 100 chars ..."}'
    bash
    # After: script encapsulates query
    ~/.agents/skills/foo/scripts/graphql-query.sh
  5. Data gathering that's reused — same fetch pattern across skills

    bash
    # Can be shared across skills
    ~/.agents/skills/common/scripts/fetch-sprint-tickets.sh
Do NOT extract:
  • Single CLI tool calls (jira issue list ...)
  • Simple file operations (cat, echo, basic jq)
  • Context-dependent decisions (which skill to invoke, which tool to use)
  • Commands where arguments vary significantly each time
  • Operations that need immediate user feedback

Analysis Steps

1. Read the Skill

Read the SKILL.md file(s) in the target directory.

2. Identify Command Patterns

Scan for these patterns:

  • Code blocks with bash or sh language
  • Multi-line command sequences
  • Hardcoded queries or data structures
  • Comments like "run in parallel", "wait for all", "filter results"
  • Repeated patterns (same command structure appears multiple times)
  • Token calculations (date math, string extraction, credential fetching)
3. Score Each Command Block

For each command block, score on:

  • Complexity: 0 (single command) to 5 (multi-step pipeline)
  • Determinism: 0 (highly variable) to 5 (always runs the same)
  • Reusability: 0 (one-off) to 5 (used across skills)
  • Token cost: estimate tokens saved per invocation

Extract if: Complexity ≥ 2 AND Determinism ≥ 3

Look for:

  • Commands that always run together
  • Commands with shared setup (export variables, cd to directory)
  • Commands that feed into each other (output of A → input of B)
5. Propose Scripts

For each extraction candidate, propose:

  • Script name and location (scripts/<name>.sh)
  • Script purpose (comment header)
  • Input parameters (if any)
  • Output format (JSON, text, exit code)
  • Error handling strategy
6. Show Before/After

Present side-by-side:

Before:

markdown
### Step 3: Fetch Data
\`\`\`bash
TOKEN=$(security find-generic-password -s "..." -w)
if [[ "$TOKEN" == go-keyring-base64:* ]]; then
  TOKEN=$(echo "${TOKEN#go-keyring-base64:}" | base64 -d)
fi
curl -H "Authorization: bearer $TOKEN" \
  -d '{"query":"..."}' https://api.github.com/graphql | jq '.data.nodes'
\`\`\`

After:

markdown
### Step 3: Fetch Data
\`\`\`bash
~/.agents/skills/skill-name/scripts/fetch-github-data.sh
\`\`\`
Returns JSON array of nodes.

Script: scripts/fetch-github-data.sh

bash
#!/usr/bin/env bash
set -e
# Fetch GitHub data via GraphQL
# Returns: JSON array of nodes
TOKEN=$(security find-generic-password -s "gh:github.com" -w 2>&1)
if [[ "$TOKEN" == go-keyring-base64:* ]]; then
  TOKEN=$(echo "${TOKEN#go-keyring-base64:}" | base64 -d)
fi
curl -s -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" \
  -d '{"query":"{ ... }"}' https://api.github.com/graphql | jq -c '.data.nodes'
7. Estimate Impact

Calculate savings:

  • Token reduction per skill invocation
  • Number of times skill is typically invoked per day/week
  • Total weekly token savings
  • Reliability improvement (deterministic execution)
8. Ask for Confirmation

Present the analysis and proposed changes. Ask:

  1. Should I create these scripts?
  2. Should I update the skill file to reference them?
  3. Any scripts to skip or modify?
9. Implement (if approved)

For each approved script:

  1. Create scripts/ directory in skill folder if needed
  2. Write script with proper shebang, error handling, comments
  3. Make executable (chmod +x)
  4. Update SKILL.md to replace inline commands with script call
  5. Test the script (run it, check output format)
  6. Report any issues
Show full SKILL.md (337 more words)Show less
10. Document Changes

Create a summary file at /tmp/skill-optimization-<skill-name>.md:

  • Scripts created
  • Skill sections modified
  • Token savings estimate
  • Test results

Output Format

Present findings as:

markdown
# Skill Optimization Analysis: <skill-name>

## Summary
- X command blocks analyzed
- Y extraction candidates found
- Estimated Z tokens saved per invocation

## Candidates for Extraction

### 1. <name> (Complexity: 4, Determinism: 5, Tokens: ~150)
**Current:** Steps 3-4 in SKILL.md (lines X-Y)
**Proposed:** `scripts/<name>.sh`
**Savings:** ~150 tokens per invocation
**Rationale:** Multi-step pipeline with hardcoded GraphQL query

[Show before/after]

### 2. <name> (Complexity: 3, Determinism: 4, Tokens: ~80)
...

## Scripts NOT Worth Extracting

### Step 6: Simple file read
**Reason:** Single command, context-dependent path
**Keep as-is:** `cat /path/to/file`

## Recommendations

1. Extract candidates 1, 2, 4 (high impact)
2. Leave candidates 3, 5 inline (low complexity)
3. Consider sharing candidate 2 with <other-skill>

Proceed? [y/n]

Edge Cases

  • Skill uses MCP tools: Don't extract MCP calls, they're already encapsulated
  • Skill has existing scripts/: Analyze if they can be improved or consolidated
  • Multi-skill extraction: If multiple skills share a pattern, propose a shared script location
  • Sandbox requirements: Note if scripts need dangerouslyDisableSandbox: true
  • Credentials: Ensure scripts handle token/password extraction properly

Testing Protocol

For each created script:

  1. Run with typical inputs
  2. Verify output format matches expectations
  3. Check error handling (missing deps, failed commands)
  4. Test cross-platform compatibility (GNU vs BSD date, etc.)
  5. Ensure it works from skill context (paths, environment)

Common pitfalls to check:

  • Tab-delimited output: If parsing --plain output from CLIs, check for variable tab alignment. Prefer --raw or --json flags when available.
  • Date commands: Use date --version to detect GNU vs BSD, not uname
  • Temp files: Use mktemp for safe temp filenames, especially when names contain slashes
  • JSON parsing: Always prefer native JSON output (--raw, --json) over parsing formatted text

Tool-specific flags:

  • jira issue list --raw → JSON array of issues
  • jira sprint list --plain → No JSON mode, grep/awk is fine
  • gh pr list --json <fields> → JSON output
  • confluence search --cql → No JSON mode, text parsing necessary

Examples

See existing optimized skills:

  • backlog/scripts/ — date calculation, GraphQL query, sprint tickets (uses --raw)
  • my-weekly-report/scripts/ — parallel PR fetching, confluence search
  • copy-for-teams/copy_teams.py — clipboard HTML formatting
  • recall/scripts/ — session search and reading

Key improvements from testing:

  • sprint-tickets.sh: Switched from --plain --columns to --raw for reliable JSON parsing
  • user-prs.sh: Used mktemp instead of hardcoded temp file paths with slashes
  • date-before.sh: Detects date command flavor via --version, not OS name

Notes

  • Always show full before/after for user review
  • Don't optimize prematurely — wait for complexity to appear
  • Scripts should be self-contained and testable
  • Prefer simple bash over complex awk/sed unless necessary
  • Use jq for JSON manipulation when available
  • Test scripts with real data before committing — tab alignment, temp files, date commands all have edge cases

© meain, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in agents/.agents/skills/optimize-skill of meain/dotfiles.

Open the folder on GitHubat commit f469fb6

Compare with similar skills

Optimize Skill next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Optimize Skill compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Optimize Skill this skillmeain/dotfiles285—~2.3kAutomated safety check: PassMIT
Guidelinesakash-network/node1.1k22 repos~577Automated safety check: PassMIT
Component Refactoringlangflow-ai/langflow156k—~3.5kAutomated safety check: PassMIT
Migrate Core Code to Submodulestinyhumansai/openhuman41k—~2.6kAutomated safety check: PassGPL-3.0
ast-grep Structural Searchcode-yeongyu/oh-my-openagent70k—~3.3kAutomated safety check: PassMIT
Systematic Code Refactoringluongnv89/claude-howto42k—~3kAutomated safety check: PassMIT

Similar skills

  • Guidelines

    akash-network/node

    Behavioral guidelines to reduce common LLM coding mistakes. An agent skill from akash-network/node.

    1.1k GitHub starsUsed in 22 repos~577 tokens
    DevelopmentAuto-check passed
  • Component Refactoring

    langflow-ai/langflow

    Refactor high-complexity React components in Langflow frontend.

    156k GitHub stars~3.5k tokensUpdated today
    DevelopmentAuto-check passed
  • Migrate Core Code to Submodules

    tinyhumansai/openhuman

    Plans and carries out moving non-host-specific code and its tests from the OpenHuman core into vendored tiny submodule libraries, then releases the submodule and re-pins the host.

    41k GitHub stars~2.6k tokensUpdated today
    DevelopmentAuto-check passed
  • ast-grep Structural Search

    code-yeongyu/oh-my-openagent

    Searches and rewrites code by syntax-tree shape across 25 languages with ast-grep, for codemods, structural queries and YAML lint rules, using a Python wrapper script.

    70k GitHub stars~3.3k tokensUpdated today
    DevelopmentAuto-check passed
  • Systematic Code Refactoring

    luongnv89/claude-howto

    Guides refactoring in phases based on Martin Fowler's method: research, test coverage check, planning and small tested steps, with your approval at each phase.

    42k GitHub stars~3k tokensUpdated 7 days ago
    DevelopmentAuto-check passed
  • Codex

    skills-directory/skill-codex

    A skill your agent uses when the user asks to run Codex CLI (codex exec, codex resume) or references OpenAI Codex for code analysis, refactoring, or automated editing

    1.5k GitHub starsUsed in 3 repos~1.8k tokens
    DevelopmentAuto-check passed

More from meain/dotfiles

All 36 skills in this repo
  • Recall

    meain/dotfiles

    Search past Claude Code and Codex sessions. An agent skill from meain/dotfiles.

    285 GitHub starsUsed in 1 repo~684 tokens
    Auto-check passed
  • Grill With Docs

    meain/dotfiles

    Grilling session that challenges your plan against the existing domain model, sharpens terminology, and updates documentation (CONTEXT.md, ADRs) inline as decisions crystallise.

    285 GitHub starsUsed in 21 repos~875 tokens
    Auto-check passed
  • Backlog

    meain/dotfiles

    Daily backlog management — full planning review OR add a single entry from a URL.

    285 GitHub stars~3k tokensUpdated 1 mo ago
    Auto-check passed
  • Concern Review

    meain/dotfiles

    Generate an interactive local HTML review page for a large PR or diff, grouping the changed files by logical concern (not just by file) so a reviewer can go through one theme at a time instead of a…

    285 GitHub stars~2.2k tokensUpdated 1 mo ago
    Auto-check passed
  • My Weekly Report

    meain/dotfiles

    Generate a concise weekly status update in team format. An agent skill from meain/dotfiles.

    285 GitHub stars~2.5k tokensUpdated 1 mo ago
    Auto-check passed
  • Web Search

    meain/dotfiles

    Search the web using lynx and DuckDuckGo. An agent skill from meain/dotfiles.

    285 GitHub stars~830 tokensUpdated 1 mo ago
    Auto-check passed

Categories

Questions about Optimize Skill

What does Optimize Skill do?

Analyze agent skills to find deterministic command chains that should be extracted into scripts. Optimize Skill is an agent skill from meain/dotfiles. Analyze agent skills to find deterministic command chains that should be extracted into scripts.

When should I use Optimize Skill?

Optimize Skill fits situations like: tasks that involve Refactoring.

How do I install Optimize Skill in Claude Code?

Run `npx skills add meain/dotfiles --skill optimize-skill -a claude-code`. Or copy the skill folder (agents/.agents/skills/optimize-skill in meain/dotfiles) into .claude/skills/optimize-skill in your project. Claude Code loads it when a task matches its description.

How do I install Optimize Skill in Codex?

Run `npx skills add meain/dotfiles --skill optimize-skill -a codex`. Or copy the skill folder (agents/.agents/skills/optimize-skill in meain/dotfiles) into .agents/skills/optimize-skill in your project. Codex loads it when a task matches its description.

Can I use Optimize Skill in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add meain/dotfiles --skill optimize-skill -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/optimize-skill, .gemini/skills/optimize-skill, .github/skills/optimize-skill and .opencode/skills/optimize-skill in your project.

What does Optimize Skill need to run?

Going by SKILL.md and its folder, Optimize Skill needs the command-line tools its instructions call (curl, jq and gh).

Does Optimize Skill access the network?

SKILL.md names 1 domain. In commands or code: api.github.com; the agent is likely to contact it when it follows the instructions. This is read from the text; nothing was executed.

Is Optimize Skill safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Optimize Skill use?

Optimize Skill is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Optimize Skill use?

About 2.3k tokens (SKILL.md is roughly 9.3k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Optimize Skill?

Skills that share tags, products or a category with Optimize Skill: Guidelines (akash-network/node, 1.1k stars), Component Refactoring (langflow-ai/langflow, 156k stars), Migrate Core Code to Submodules (tinyhumansai/openhuman, 41k stars) and ast-grep Structural Search (code-yeongyu/oh-my-openagent, 70k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Optimize Skill?

meain (a GitHub user) maintains it in meain/dotfiles, which has 285 GitHub stars. The repository holds 36 skills in this directory. The repository was last updated on September 5, 2026.

Source: meain/dotfiles on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.