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.
npx agentmods add skills/jimmc414/claude-code-plugin-marketplace/refactor-decompose-functionnpx skills add jimmc414/claude-code-plugin-marketplace --skill refactor-decompose-functiongit clone --depth 1 https://github.com/jimmc414/claude-code-plugin-marketplaceWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/jimmc414/claude-code-plugin-marketplace/refactor-decompose-function)<a href="https://agentmods.dev/skills/jimmc414/claude-code-plugin-marketplace/refactor-decompose-function"><img src="https://agentmods.dev/badge/skills/jimmc414/claude-code-plugin-marketplace/refactor-decompose-function.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00028 | $0.00802 |
| Opus 5 | $0.00014 | $0.00401 |
| Sonnet 5 | $0.00006 | $0.00160 |
| Haiku 4.5 | $0.00003 | $0.00080 |
Grade A, and why
refactor-decompose-function scanned grade A with 0 findings 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 4d 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.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 103 lines — stays where its author put it; the contents beside it link to each section on GitHub.
refactor-decompose-function
When to Use
- Function is longer than 10-15 lines
- Multiple levels of nesting
- Hard to understand at a glance
- Difficult to test parts independently
- Code has natural "chunks" with different purposes
When NOT to Use
- Function is already simple and clear
- Decomposition would obscure the algorithm
- Helpers would only be used once with no clarity gain
The Pattern
Extract cohesive chunks into named helper functions. Each function should do one thing.
# BEFORE: Long, hard to test
def process_data(data):
# Validate
if not data:
raise ValueError("Empty data")
if not all(isinstance(x, int) for x in data):
raise TypeError("Non-integer data")
# Transform
result = []
for x in data:
if x > 0:
result.append(x * 2)
else:
result.append(0)
# Summarize
total = sum(result)
avg = total / len(result)
return {'data': result, 'total': total, 'average': avg}
# AFTER: Decomposed, each part testable
def process_data(data):
validate(data)
transformed = transform(data)
return summarize(transformed)
def validate(data):
if not data:
raise ValueError("Empty data")
if not all(isinstance(x, int) for x in data):
raise TypeError("Non-integer data")
def transform(data):
return [x * 2 if x > 0 else 0 for x in data]
def summarize(data):
total = sum(data)
return {'data': data, 'total': total, 'average': total / len(data)}
Example (from pytudes)
# Spelling correction (spell.py) - beautifully decomposed
def correction(word):
"""Most probable spelling correction for word."""
return max(candidates(word), key=P)
def candidates(word):
"""Generate possible spelling corrections for word."""
return known([word]) or known(edits1(word)) or known(edits2(word)) or [word]
def known(words):
"""The subset of words that appear in the dictionary."""
return set(w for w in words if w in WORDS)
def edits1(word):
"""All edits one edit away from word."""
letters = 'abcdefghijklmnopqrstuvwxyz'
splits = [(word[:i], word[i:]) for i in range(len(word) + 1)]
deletes = [L + R[1:] for L, R in splits if R]
transposes = [L + R[1] + R[0] + R[2:] for L, R in splits if len(R) > 1]
replaces = [L + c + R[1:] for L, R in splits if R for c in letters]
inserts = [L + c + R for L, R in splits for c in letters]
return set(deletes + transposes + replaces + inserts)
def edits2(word):
"""All edits two edits away from word."""
return (e2 for e1 in edits1(word) for e2 in edits1(e1))
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.
- 4d ago First seen · 103 lines · 28 tokens per session scan A 2727b365e575
refactor-decompose-function is a skill published in the GitHub repository jimmc414/claude-code-plugin-marketplace (4 stars, last pushed today), licensed MIT. It adds 28 tokens to every session and 802 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other skills, from other repositories
phpunit-migration-test-reviewing
Internal sub-skill. Do not auto-activate. Use only when explicitly invoked by name by another skill or agent.
phpunit-unit-test-reviewing
Internal sub-skill. Do not auto-activate. Use only when explicitly invoked by name by another skill or agent.
structuring-documentation
Use when writing, editing, auditing, splitting, or measuring Markdown documentation surfaces — README.md, AGENTS.md, CLAUDE.md, and docs/ siblings. Triggers include "is this doc too long", "split this README", "measure the docs", "where does this documentation belong", "audit the documentation", and any request to…
phpunit-integration-test-generation
Use this skill when the user asks to generate, write, or create integration tests for a Shopware 6 source class whose contract requires wired-up code — phrases like "generate integration tests for X", "write an integration test for this controller", "test this indexer", "create an integration test for the message…
phpunit-unit-test-generation
Internal sub-skill. Do not auto-activate. Use only when explicitly invoked by name by another skill or agent.
phpunit-unit-test-writing
Use this skill when the user asks to write, generate, create, or add PHPUnit unit tests for a Shopware 6 source class — phrases like "write unit tests for X", "generate tests for ClassName", "create PHPUnit tests", "add test coverage", "test this class", "cover this with tests", "I need tests for", "unit test this"…