Guide · Agent skill
How to use the Python Performance Optimization agent skill
Updated · written with AI from the project's own documentation and checked against our catalogue data
The python-performance-optimization skill is a set of instructions that teaches an AI agent how to find and fix slow or memory-hungry Python code. It is written for Python developers who want help diagnosing bottlenecks in scripts, data pipelines or web services. After this guide you will know what the skill changes about the agent's behaviour, how to install it, and how to ask for help in a way that triggers it.
Quick start
- 1Download the ZIP. Get the skill ZIP from this page and unzip it on your computer.
- 2Place the folder. Move the python-performance-optimization folder into ~/.claude/skills/ for personal use, or into a project's .claude/skills/ folder.
- 3Or upload in the Claude apps. In the Claude apps, open Settings → Capabilities → Skills and upload the skill.
- 4Describe the slow code. Ask the agent in plain words about the slowness, sharing the code and any profiler output.
- 5Measure first. Let the agent run or guide you through cProfile or a memory profiler before changing code.
- 6Apply and re-measure. Make one change at a time and repeat the same timing to confirm it helped.
What is an agent skill and what does this one do?
An agent skill is a folder of instructions and examples that an AI agent reads when a task matches the skill's description. This skill is mainly guidance the agent follows while helping you; it does not change your code on its own.
When it is active, the agent measures before it changes anything. It is guided to use profiling tools such as cProfile and memory profilers, and then to suggest fixes such as better data structures, caching, batching I/O or NumPy.
- CPU profiling to find time-consuming functions
- Memory profiling to track allocation and leaks
- Line-by-line profiling and call graphs
- Checklist of common Python performance pitfalls
Install the skill from the ZIP or the Claude apps
Download the ZIP from this page and unzip it. For a personal setup, place the skill folder in ~/.claude/skills/. For a single project, place it in that project's .claude/skills/ folder.
If you use the Claude apps, you can instead upload the skill under Settings → Capabilities → Skills.
- Personal install: ~/.claude/skills/
- Project install: .claude/skills/ inside your project
- Claude apps: Settings → Capabilities → Skills
What files does the skill include?
The skill folder contains SKILL.md, which holds the main guide and quick start, plus two reference files. references/details.md has worked profiling patterns, including a cProfile example. references/advanced-patterns.md covers NumPy vectorization, caching, memory management, parallelization, async I/O, database optimization and benchmarking tools.
- SKILL.md: overview, core concepts, quick start, best practices and pitfalls
- references/details.md: detailed profiling patterns and examples
- references/advanced-patterns.md: advanced optimization techniques
Trigger the skill with a natural request
The skill is meant to be used when you are debugging slow Python code, optimizing bottlenecks or improving application performance. Describe the symptom and the code in plain words. You do not need to name the skill.
Give the agent your script or function, what feels slow, and any profiler output you already have. The more concrete the symptom, the more useful the guidance.
- My Python script takes 40 seconds. Help me find out why it is slow.
- This web service's memory grows every hour. Profile it and suggest fixes.
- Here is my cProfile output. Which functions should I optimize first?
- Can this data processing loop be sped up with NumPy or caching?
Example: profile a slow function with cProfile
The reference file shows how to wrap code in cProfile, sort the results by cumulative time and print the top functions. You can also save the output to a file for later analysis.
The skill also includes a timeit example for comparing two approaches. Here is the basic timing pattern from the quick start:
import timeit
execution_time = timeit.timeit(
"sum(range(1000000))",
number=100
)
print(f"Average time: {execution_time/100:.6f} seconds")Safety notes and what the skill needs
The skill needs Python installed for the cProfile and timeit examples. Some guidance mentions optional third-party tools such as memory profilers and py-spy. The skill itself does not run scripts and does not use the network.
Be careful with production systems. Profiling live code can add overhead, and the skill's advice to profile production code with py-spy should be done deliberately, not as a reflex.
- Requires Python for the examples
- Optional tools such as memory profilers and py-spy
- Runs scripts: no
- Uses network: no
Tips for getting better results
Ask for measurements before fixes. The skill's first rule is to profile before optimizing, so if you already have numbers, share them. Keep the goal clear: lower latency, lower peak memory, or faster batch runs need different investigations.
- Share the function or script and the input size you care about
- Paste profiler output rather than a summary
- Ask for clarity first if the code is not yet slow in a measurable way
- Re-run the same timing after each change to confirm the gain
What people use it for
- Finding which function dominates a slow data processing script with cProfile
- Investigating memory growth in a long-running Python web service
- Comparing a pure Python loop against a NumPy vectorized version using timeit
- Reviewing code for common pitfalls such as unnecessary copies or missing connection pooling
- Deciding where to add lru_cache to repeated expensive calls
Frequently asked questions
How do I install the python performance optimization skill?
Download the ZIP from this page and unzip it. Place the folder in ~/.claude/skills/ for personal use or in a project's .claude/skills/ folder. In the Claude apps, you can upload it under Settings → Capabilities → Skills.
What do I need to use this skill?
You need Python installed, since the examples use cProfile and timeit. Some guidance refers to optional third-party tools such as memory profilers and py-spy. The skill does not run scripts and does not use the network.
Is this skill free?
The skill is published under the MIT licence, as stated on this page. Check the licence file in the source repository for the full terms.
Does the skill change my code automatically?
No. It is mainly a set of instructions and examples the agent follows while helping you. Any changes to your code are proposed and made through your normal agent interaction.
Is this skill only for Python?
Yes. The guidance is Python-specific, so it will not help with performance problems in other languages.
Is it safe to profile a production system with this skill?
Profiling live code can add overhead, so be deliberate. The skill suggests tools such as py-spy for production, and you should decide when and how to use them rather than profiling live systems by default.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
This skill suits Python developers debugging slow scripts or services, and teams who want a checklist of common Python performance pitfalls. It is not suitable for non-programmers, for other languages, or for careless profiling of live production systems. If you need a tool that automatically rewrites code or runs benchmarks for you, pick something else.
Download the skill