pass-function-as-arg

pass-function-as-arg is a skill for Claude Code from jimmc414/claude-code-plugin-marketplace. It costs 27 tokens per session (629 once invoked), scanned A, original, MIT.

A coding pattern where a function is passed into another function to decide part of its behavior. This lets one general algorithm use different rules for filtering, sorting, searching, or handling events.

In plain words
What is it for?
Implementing strategy patterns, callbacks, custom sorting or filtering, and higher-order operations such as `map`, `filter`, and `reduce`.
Why use it?
Without this pattern, similar algorithms often need separate copies for each rule. Passing the rule as a function keeps the main algorithm reusable.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the norvig-patterns plugin — 54 skills shipped together

Good fit Implementing strategy patterns, callbacks, custom sorting or filtering, and higher-order operations such as map, filter, and reduce.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/jimmc414/claude-code-plugin-marketplace/pass-function-as-arg
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.

Any agent
npx skills add jimmc414/claude-code-plugin-marketplace --skill pass-function-as-arg
Clone the repo
git clone --depth 1 https://github.com/jimmc414/claude-code-plugin-marketplace

Made for: Claude Code.

Or install norvig-patterns, the plugin that ships this one along with the rest of its 54 skills.

Wrote 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.

agentmods badge for pass-function-as-arg

README.md
[![agentmods](https://agentmods.dev/badge/skills/jimmc414/claude-code-plugin-marketplace/pass-function-as-arg.svg)](https://agentmods.dev/skills/jimmc414/claude-code-plugin-marketplace/pass-function-as-arg)
Your own site
<a href="https://agentmods.dev/skills/jimmc414/claude-code-plugin-marketplace/pass-function-as-arg"><img src="https://agentmods.dev/badge/skills/jimmc414/claude-code-plugin-marketplace/pass-function-as-arg.svg" alt="Measured on agentmods" height="20"></a>
Per session 27 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 629 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00027 $0.00629
Opus 5 $0.00014 $0.00315
Sonnet 5 $0.00005 $0.00126
Haiku 4.5 $0.00003 $0.00063

Measured 7d ago against content hash a01f5c6f8e30, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

pass-function-as-arg 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 7d 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.

plugins/norvig-patterns/skills/pass-function-as-arg/SKILL.md · 85 lines

How it starts

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

pass-function-as-arg

When to Use

  • Algorithm should work with different implementations
  • Strategy pattern: same algorithm, different strategies
  • Callbacks for event handling
  • Sorting/filtering with custom criteria
  • Higher-order functions (map, filter, reduce)

When NOT to Use

  • Only one implementation needed
  • Function parameter adds complexity without benefit
  • Object-oriented approach is clearer

The Pattern

Accept a function as a parameter to customize behavior.

def generic_algorithm(data, key=lambda x: x, filter_fn=lambda x: True):
    """Process data with customizable key and filter."""
    filtered = [x for x in data if filter_fn(x)]
    return sorted(filtered, key=key)

# Use with different strategies
result1 = generic_algorithm(items, key=lambda x: x.priority)
result2 = generic_algorithm(items, key=lambda x: -x.size, filter_fn=lambda x: x.active)

Example (from pytudes)

# Hill climbing with configurable objective (ngrams.py)
def hillclimb(x, objective_fn, neighbors_fn, steps=10000):
    """Search for x that maximizes objective_fn, using neighbors_fn to explore."""
    best = x
    best_score = objective_fn(x)

    for _ in range(steps):
        for neighbor in neighbors_fn(best):
            score = neighbor_score = objective_fn(neighbor)
            if score > best_score:
                best, best_score = neighbor, score
                break

    return best

# Use with specific objective and neighbor functions
decoded = hillclimb(initial_guess,
                   objective_fn=log_probability,
                   neighbors_fn=swap_adjacent_chars)

# Priority queue with custom key (AdventUtils.ipynb)
class PriorityQueue:
    def __init__(self, items=(), key=lambda x: x):
        self.key = key
        self.items = []
        for item in items:
            self.add(item)

    def add(self, item):
        heapq.heappush(self.items, (self.key(item), item))

# A* search with custom heuristic
frontier = PriorityQueue(initial_nodes, key=lambda n: n.cost + h(n))

# Tree generation with configurable pop strategy (Maze.ipynb)
def random_tree(nodes, neighbors, pop=deque.pop):
    """Pop strategy determines tree shape."""
    ...
    current = pop(frontier)  # DFS, BFS, or random based on pop function

Read the full file on GitHub · 85 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. 7d ago First seen · 85 lines · 27 tokens per session scan A a01f5c6f8e30

Subscribe to this mod's changes

pass-function-as-arg is a skill published in the GitHub repository jimmc414/claude-code-plugin-marketplace (4 stars, last pushed yesterday), licensed MIT. It adds 27 tokens to every session and 629 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.

Related

Other skills, from other repositories

ai-ml-development

AI and machine learning development with PyTorch, TensorFlow, and LLM integration. Use when building ML models, training pipelines, fine-tuning LLMs, or implementing AI features.

travisjneuman/.claude · 43 tokens

codexer

Python research assistant with Context7 MCP. Use for Python library research, evaluating packages, enforcing strict Python coding standards, or fetching up-to-date library docs via Context7.

PracticalSwan/agent-skills · 38 tokens

fastapi

Skill "fastapi" from ashish7802/awesome-api-skills, covering fastapi skill, ecosystem graph, quick start, production patterns and dependency injection.

ashish7802/awesome-api-skills · 0 tokens

python-packaging

Configure Python package metadata, setup.py, and pyproject.toml for distribution using UV or setuptools. Use when setting up Python packages, configuring build systems, or preparing projects for PyPI publication.

armanzeroeight/fastagent-plugins · 43 tokens

clean-code

Use when the user writes new Python, or asks for review, refactor, or cleanup of Python code, names, comments/docstrings, functions, or tests. Applies Robert Martin's complete Clean Code catalog -- naming, functions, comments, DRY, boundary conditions, and tests -- to the code being changed.

Sagargupta16/claude-skills · 66 tokens

analyzing-windows-prefetch-with-python

Parse Windows Prefetch files using the windowsprefetch Python library to reconstruct application execution history, detect renamed or masquerading binaries, and identify suspicious program execution patterns.

pinkpixel-dev/skills-collection-1 · 43 tokens