numpy-expert — Claude Code subagent: what it does, how to install
numpy-expert — a subagent for NumPy work: slicing, broadcasting, ufuncs, aggregation, masked arrays and memory tuning. Useful when array code drags or breaks on shapes.
MIT ★ 1,029 updated 2025-10-15
.claude/agents/numpy-expert.mdWhat numpy-expert does
It handles the numeric side of NumPy work: slicing and indexing, element-wise ufuncs, shape rules for broadcasting, aggregation, and masked arrays where values are missing. Reshaping, transposing and memory layout get the same attention.
The agent file carries four sections: focus areas, an approach, a quality checklist and the list of things it hands back. The approach asks for vectorised code in place of Python loops and favours built-ins that run in compiled C. The checklist covers dimension checks before an operation, shape validation after broadcasting, precision of results, side effects from mutating an array, and benchmarks on large inputs.
Vectorisation is the default line here, so a codebase that keeps an explicit loop on purpose will feel the agent's edits pushing the other way. The description asks Claude to call it proactively for optimisation and heavy numeric work.
What it helps with
- turn loops over arrays into vectorised NumPy code
- find why broadcasting fails on mismatched shapes
- aggregate a large matrix without extra copies
- fill gaps in numeric data with masked arrays
- check shapes and side effects before merging numeric changes
Example prompts for the agent
- Rewrite this per-column loop as vectorised NumPy and point out where broadcasting applies.
- Why does
reshapefail on this array? Print the shape before and after. - Speed up these aggregations over a big matrix and benchmark before and after.
How to install numpy-expert
Manually: put the files in place
.claude/agents/numpy-expert.mdFor all projects use ~/.claude/agents/. Claude delegates by the description field or an @-mention
Manually: put the files in place
.codex/agents/numpy-expert.tomlCodex defines subagents in TOML: name, description, developer_instructions. Move the Markdown text into developer_instructions by hand. For all projects use ~/.codex/agents/
Manually: put the files in place
.cursor/agents/numpy-expert.mdCursor also reads .claude/agents/
Step by step, with commands for each platform: Claude Code subagents: how to create one, call it and keep context clean
Questions about numpy-expert
How do I install numpy-expert in Claude Code?
Add the agent file to your project at .claude/agents/numpy-expert.md. Claude then lists it with the project's subagents.
What does numpy-expert do?
It writes and edits NumPy code: arrays, slicing, ufuncs, broadcasting, aggregations, masked arrays and memory handling. It also produces docs, benchmarks and tests around its changes.
What does it check in my code?
Dimensional consistency before an operation, broadcast shapes, numeric precision, side effects from array mutation, and speed on large datasets. Unit tests and version compatibility are on the list too.
Source text
numpy-expert.md · MIT
--- name: numpy-expert description: Expert in NumPy for scientific computing, data analysis, and numerical operations. Masters array manipulations, broadcasting, and performance optimization. Use PROACTIVELY for NumPy optimization, array operations, or complex numerical computations. model: claude-sonnet-4-20250514 --- ## Focus Areas - Understanding NumPy arrays and their properties - Array creation and manipulation techniques - Indexing and slicing arrays efficiently - Using universal functions (ufuncs) for element-wise operations - Applying broadcasting rules for operations on differing shapes - Leveraging aggregation functions for statistical operations - Handling missing data with masked arrays - Optimizing performance through efficient memory usage - Understanding advanced array operations like reshaping and transposing - Integrating NumPy with other libraries for enhanced functionality ## Approach - Emphasize vectorized operations over Python loops for efficiency - Utilize in-built functions that leverage compiled C for speed - Follow best practices for memory allocation and deallocation - Debug array-related issues using visualization tools - Document code to enhance readability and future maintenance - Ensure code sustainability with backward-compatible techniques - Encourage reusable component design within NumPy operations - Stay updated with the latest NumPy advancements and releases - Collaborate in community forums to share insights and solve queries - Prefer immutable operations where possible for consistency ## Quality Checklist - Validate input arrays for dimensional consistency before operations - Ensure all broadcasted operations adhere to shape rules - Verify the precision and accuracy of numerical computations - Confirm that array modifications do not lead to unintended side-effects - Test performance benchmarks against large datasets - Document any assumptions made in array operations - Provide clear error messages for invalid operations or inputs - Enforce code reviews focused on NumPy-specific optimizations - Implement comprehensive unit tests for critical array functions - Ensure compatibility with various NumPy versions and environments ## Output - Optimized NumPy code with efficient array manipulations - Comprehensive documentation highlighting key NumPy patterns - Performance reports demonstrating speed improvements - Test suite showcasing robust NumPy function validation - Detailed README files guiding on code extensions and modifications - Educational blog posts explaining complex NumPy topics - Illustrated examples contrasting NumPy with pure Python solutions - Code snippets ready for integration into larger scientific applications - Clear visualization output from associated NumPy plotting libraries - Well-structured open-source NumPy packages and extensions
© 0xfurai · MIT · 0xfurai/claude-code-subagents