performant-code

performant-code is a skill for Claude Code, Codex from vstorm-co/pydantic-deepagents. It costs 14 tokens per session (632 once invoked), scanned A, original, MIT.

Guidance for writing code that remains responsive when processing large amounts of data or working under strict time limits. It covers memory use, input and output handling, and algorithm choice.

In plain words
What is it for?
Use it to choose between loading, streaming, or memory-mapping files; reduce repeated work; and replace slow nested searches with more suitable approaches.
Why use it?
It helps avoid timeouts, excessive memory use, and slow code caused by unsuitable data-processing methods.

Skill for Claude CodeCodex

About the project

Pydantic Deep Agents is a self-hosted terminal AI assistant and Python framework for building coding, research, and other AI agents. It gives agents tools such as file access, shell commands, planning, memory, sub-agents, sandboxed execution, and MCP connections, and supports different models.

vstorm-co/pydantic-deepagents · 1,053 stars · on GitHub

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 skills/vstorm-co/pydantic-deepagents/performant-code
Any agent
npx skills add vstorm-co/pydantic-deepagents --skill performant-code
Clone the repo
git clone --depth 1 https://github.com/vstorm-co/pydantic-deepagents

Made for: Claude Code, Codex.

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 performant-code

README.md
[![agentmods](https://agentmods.dev/badge/skills/vstorm-co/pydantic-deepagents/performant-code.svg)](https://agentmods.dev/skills/vstorm-co/pydantic-deepagents/performant-code)
Your own site
<a href="https://agentmods.dev/skills/vstorm-co/pydantic-deepagents/performant-code"><img src="https://agentmods.dev/badge/skills/vstorm-co/pydantic-deepagents/performant-code.svg" alt="Measured on agentmods" height="20"></a>
Per session 14 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 632 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 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.00014 $0.00632
Opus 5 $0.00007 $0.00316
Sonnet 5 $0.00003 $0.00126
Haiku 4.5 $0.00001 $0.00063

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

Security

Grade A, and why

performant-code scanned grade A 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 5d 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.

Runs shell commandslowCapability

Expected in a hook, worth knowing in a rule or an instructions file.

- `subprocess.run()` > `os.system()`
apps/cli/skills/performant-code/SKILL.md · 71 lines

How it starts

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

Performant Code

How to write code that won't timeout on large inputs.

Think About Scale First

Before writing code, ask: how big is the data?

Data size Approach
< 1 MB Load into memory, any approach works
1-100 MB Load into memory, but use efficient algorithms
100 MB - 1 GB Stream/mmap, avoid loading entirely into memory
> 1 GB Streaming only, chunk-based processing

I/O Optimization

Large files

  • mmap (C: mmap(), Python: mmap.mmap()) — map file into memory, OS handles paging
  • Buffered binary readsfread() in C, open(f, 'rb').read(chunk) in Python
  • NEVER read a 500MB file line-by-line with fgets() when you need random access

Writing output

  • Buffer writes — don't call write() for every byte
  • Use fwrite() or sys.stdout.buffer.write() for binary output
  • Flush only when needed

Algorithm Complexity

  • O(n) beats O(n log n) beats O(n²) — always
  • Nested loops on large data = timeout. Restructure to single pass + hash map
  • Sorting is O(n log n) — only sort if you need to
  • Use hash maps/sets for lookup instead of linear search
  • Pre-compute what you can outside loops

Language-Specific Tips

C

  • Use mmap() for large file access
  • -O2 or -O3 for compiler optimizations
  • Avoid malloc()/free() in tight loops — pre-allocate
  • Use memcpy() instead of byte-by-byte copying
  • Integer arithmetic > floating point when possible

Python

  • Use numpy for numerical work (100x faster than pure Python loops)
  • collections.Counter, defaultdict — avoid manual counting
  • List comprehensions > explicit loops
  • struct.unpack() for binary parsing
  • subprocess.run() > os.system()
  • For heavy computation: consider writing a small C program instead

General

  • Profile before optimizing — find the actual bottleneck
  • If a program hangs, it's likely: infinite loop, deadlock, or I/O bound on huge data
  • If a program is slow, check: algorithm complexity, I/O pattern, memory allocation

Read the full file on GitHub · 71 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. 5d ago First seen · 71 lines · 14 tokens per session scan A e6b38be0640b

Subscribe to this mod's changes

performant-code is a skill published in the GitHub repository vstorm-co/pydantic-deepagents (1,053 stars, last pushed 13d ago), licensed MIT. It adds 14 tokens to every session and 632 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 1 finding (runs shell commands). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

performance-analysis

Comprehensive performance analysis, bottleneck detection, and optimization recommendations for Claude Flow swarms.

Soulcynics404/AgentForge · 20 tokens

add-new-model

Add support for a newly-released LLM model in pydantic-ai (e.g. openai:gpt-5.6, anthropic:claude-sonnet-5). Use when a provider ships a new model id and you need to wire literals, profile flags, and tests to recognize it. Handles SDK-lag, gateway list conventions, and capability probing.

pydantic/pydantic-ai · 80 tokens

building-pydantic-ai-agents

Build AI agents with Pydantic AI — tools, capabilities (including on-demand loading), structured output, streaming, testing, and multi-agent patterns. Use when the user mentions Pydantic AI, imports pydanticai, or asks to build an AI agent, add tools/capabilities, defer capability loading, stream output, define agents…

pydantic/pydantic-ai · 85 tokens

complete-partial-pr

Evaluate and complete an issue or PR where the submitted patch fixes only a narrow symptom of the reported pain point. Use when a contribution may miss adjacent integration surfaces, provider/spec semantics, roundtrip behavior, tests, docs, or historical maintainer decisions.

pydantic/pydantic-ai · 55 tokens

testing-skill

Record, rewrite, and debug VCR cassettes for HTTP recordings. Use when running tests with --record-mode, verifying cassette playback, or inspecting request/response bodies in YAML cassettes.

pydantic/pydantic-ai · 44 tokens

pre-push-review

Run a high-judgment local review of the current branch before pushing, both before a PR exists and between PR iterations.

pydantic/pydantic-ai · 24 tokens