Agent skill
numpy-core
Install this agent skill to your Project
npx add-skill https://github.com/cuba6112/skillfactory/tree/main/skills/numpy-core
SKILL.md
Overview
NumPy Core focuses on the foundational architecture of the ndarray. This includes how data types (dtypes) interpret raw memory, how shapes are manipulated without copying data through "views," and how memory alignment impacts hardware-level performance.
When to Use
- Creating efficient multidimensional arrays from raw data.
- Manipulating array shapes for algorithm compatibility.
- Optimizing memory-intensive operations by ensuring hardware alignment.
- Handling large-scale numerical data where precision and memory overhead are critical.
Decision Tree
- Do you need to change array shape?
- Use
.reshape(). (Check.baseto see if it's a view).
- Use
- Are you performing truth-value testing (e.g.,
if arr:) on multi-element arrays?- No: Use
.any()or.all()to avoid ambiguity errors.
- No: Use
- Is performance suboptimal on modern hardware?
- Check
arr.flags['ALIGNED']. If False, usenp.requirewith ALIGNED.
- Check
Workflows
-
Optimizing Performance via Alignment
- Check the ALIGNED flag of the array via
arr.flags. - Use
np.requirewithrequirements=['ALIGNED']to ensure proper memory offsets. - Perform calculations on the aligned array to leverage hardware SIMD optimizations.
- Check the ALIGNED flag of the array via
-
Safe Shape Manipulation
- Use
arr.reshapeto create a view with a new shape without copying data. - Verify the result's
.baseattribute to confirm it is a view of the original. - Use
.copy()if the new shape requires a contiguous layout that the view cannot provide.
- Use
-
Precision-Aware Reduction
- Select a reduction method like
.sum()or.prod(). - Pass a larger dtype (e.g.,
float64for afloat32array) to thedtypeparameter. - Execute the operation to prevent numerical overflow during accumulation.
- Select a reduction method like
Non-Obvious Insights
- Shared Buffers: Different ndarrays can share the same data; modifications in a "view" are immediately visible in the base array.
- Ambiguity Prevention: NumPy raises errors for boolean testing of multi-element arrays because the truth value is ambiguous; explicit
.any()or.all()is required. - Dtype Interpretation: A
dtypeis not just a label but an instruction on how to interpret fixed-size blocks of memory corresponding to array items.
Evidence
- "Different ndarrays can share the same data, so that changes made in one ndarray may be visible in another." Source
- "An array is considered aligned if the memory offsets for all elements and the base offset itself is a multiple of self.itemsize." Source
Scripts
scripts/numpy-core_tool.py: Provides utilities for checking alignment and creating precision-safe reductions.scripts/numpy-core_tool.js: Simulated logic for shape validation and alignment checks.
Dependencies
numpy(Python)
References
- references/README.md
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
prompt-engineering
Comprehensive prompt engineering techniques for Claude models. Use this skill when crafting, optimizing, or debugging prompts for Claude API, Claude Code, or any Claude-powered application. Covers system prompts, role prompting, multishot examples, chain of thought, XML structuring, long context handling, extended thinking, prompt chaining, Claude 4.x-specific best practices, and agentic orchestration including subagents, agent loops, skills, MCP integration, and multi-agent workflows.
adk-rag-agent
Build RAG (Retrieval-Augmented Generation) agents with Google ADK and Vertex AI RAG Engine. Use when implementing document Q&A, knowledge base search, or citation-backed responses. Covers VertexAiRagRetrieval tool, corpus setup, and citation formatting.
headless-cli-agents
Build agentic systems using Claude CLI in headless mode or the Claude Agent SDK. Use when building automation pipelines, CI/CD integrations, multi-agent orchestration, or programmatic Claude interactions. Covers CLI flags (-p, --output-format), session management (--resume, --continue), Python SDK (claude-agent-sdk), custom tools, and agent loop patterns.
notion-knowledge-capture
Capture conversations and decisions into structured Notion pages; use when turning chats/notes into wiki entries, how-tos, decisions, or FAQs with proper linking.
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).
gh-fix-ci
Inspect GitHub PR checks with gh, pull failing GitHub Actions logs, summarize failure context, then create a fix plan and implement after user approval. Use when a user asks to debug or fix failing PR CI/CD checks on GitHub Actions and wants a plan + code changes; for external checks (e.g., Buildkite), only report the details URL and mark them out of scope.
Didn't find tool you were looking for?