scipy-best-practices — Claude Code skill: SciPy rules for your agent
A skill that gives your coding agent rules for SciPy work: optimization, linear algebra, stats, signal processing. Useful when the Python code does math, not UI.
npx skills add Mindrally/skills --skill scipy-best-practices -a claude-codeWhat scipy-best-practices does
The skill is a set of instructions the agent picks up when you work on Python code that uses SciPy. It breaks the guidance into sections: which optimization method fits which problem, how to solve linear systems, how to design filters, how to run statistics. The agent gets a decision map instead of guessing each time.
For optimization it points to scipy.optimize.minimize() and splits methods by conditions: 'BFGS' for smooth unconstrained problems, 'L-BFGS-B' when bounds exist, 'SLSQP' for constraints, 'Nelder-Mead' for non-differentiable functions. Linear algebra goes through scipy.linalg.solve() rather than a matrix inverse, and large sparse systems use solvers from scipy.sparse.linalg. Separate sections cover interpolation, integration, solve_ivp() for differential equations, and signal work with filtfilt() and find_peaks().
There are also sections on performance and validation: checking convergence, testing against analytical solutions, np.testing.assert_allclose() for numeric comparison. The skill assumes SciPy and NumPy are present — its examples will not run without them. Worth installing if you write numerical code and want the agent to stop inventing a method where the SciPy docs already have one.
What it helps with
- pick an optimization method for a constrained problem
- solve a linear system without inverting the matrix
- design a filter and apply it without phase shift
- run a hypothesis test and summarize the statistics
- test numerical code against an analytical solution
Example prompts for the agent
- write an optimization function using scipy.optimize.minimize with SLSQP
- rewrite this loop with vectorized SciPy operations
- add tests with np.testing.assert_allclose for this function
How to install scipy-best-practices
1Skills CLI (Vercel)
npx skills add Mindrally/skills --skill scipy-best-practices -a claude-code2Manually: put the files in place
~/.claude/skills/scipy-best-practices/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/scipy-best-practices/
1Skills CLI (Vercel)
npx skills add Mindrally/skills --skill scipy-best-practices -a codex2Manually: put the files in place
.agents/skills/scipy-best-practices/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add Mindrally/skills --skill scipy-best-practices -a cursor2Manually: put the files in place
.cursor/skills/scipy-best-practices/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install Mindrally/skills scipy-best-practices2Manually: put the files in place
.github/skills/scipy-best-practices/SKILL.md1Skills CLI (Vercel)
npx skills add Mindrally/skills --skill scipy-best-practices -a gemini-cli2Platform CLI
gemini skills install https://github.com/Mindrally/skills --path scipy-best-practicesManually: put the files in place
.devin/skills/scipy-best-practices/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add Mindrally/skills --skill scipy-best-practices -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about scipy-best-practices
How do I install scipy-best-practices in Claude?
Run npx skills add Mindrally/skills --skill scipy-best-practices -a claude-code. The skill file lands at ~/.claude/skills/scipy-best-practices/SKILL.md.
What does scipy-best-practices do?
It gives the agent rules for SciPy development: choosing optimization methods, handling linear algebra, statistics, interpolation, integration and signals. It also covers performance tips and testing of numerical code.
Which platforms does the skill support?
Claude, Codex, Cursor, GitHub Copilot, Gemini CLI and OpenCode. Each platform has its own install command and its own skills directory.
Source text
SKILL.md · Apache-2.0
--- name: scipy-best-practices description: Best practices for SciPy scientific computing, optimization, signal processing, and statistical analysis in Python metadata: maintainer: Mindrally source: https://github.com/Mindrally/skills --- # SciPy Best Practices Expert guidelines for SciPy development, focusing on scientific computing, optimization, signal processing, and statistical analysis. ## Code Style and Structure - Write concise, technical Python code with accurate SciPy examples - Prioritize numerical accuracy and computational efficiency - Use functional programming patterns for mathematical operations - Prefer vectorized operations over explicit loops - Use descriptive variable names reflecting scientific context - Follow PEP 8 style guidelines ## scipy.optimize - Optimization - Use `scipy.optimize.minimize()` for general-purpose optimization - Choose appropriate method based on problem characteristics: - `'BFGS'` for smooth, unconstrained problems - `'L-BFGS-B'` for bounded problems - `'SLSQP'` for constrained optimization - `'Nelder-Mead'` for non-differentiable functions - Provide gradients when available for faster convergence - Use `scipy.optimize.curve_fit()` for nonlinear least squares fitting - Use `scipy.optimize.root()` for finding roots of equations ## scipy.linalg - Linear Algebra - Prefer `scipy.linalg` over `numpy.linalg` for additional functionality - Use `scipy.linalg.solve()` instead of computing matrix inverse - Leverage specialized solvers for structured matrices (banded, triangular) - Use `scipy.linalg.lu_factor()` and `lu_solve()` for multiple right-hand sides - Use sparse matrix solvers from `scipy.sparse.linalg` for large sparse systems ## scipy.stats - Statistics - Use distribution objects for probability calculations - Leverage `scipy.stats.describe()` for summary statistics - Use hypothesis testing functions: `ttest_ind()`, `chi2_contingency()`, `mannwhitneyu()` - Generate random samples with `.rvs()` method on distributions - Use `.fit()` for parameter estimation from data ## scipy.interpolate - Interpolation - Use `scipy.interpolate.interp1d()` for 1D interpolation - Use `scipy.interpolate.griddata()` for scattered data interpolation - Choose appropriate interpolation method: 'linear', 'cubic', 'nearest' - Use spline functions for smooth interpolation: `UnivariateSpline`, `BSpline` - Consider `RegularGridInterpolator` for regular grid data ## scipy.integrate - Integration - Use `scipy.integrate.quad()` for single integrals - Use `scipy.integrate.dblquad()`, `tplquad()` for multiple integrals - Use `scipy.integrate.solve_ivp()` for ordinary differential equations - Choose appropriate ODE method: 'RK45', 'BDF', 'LSODA' - Provide Jacobian for stiff systems to improve performance ## scipy.signal - Signal Processing - Use `scipy.signal.butter()`, `cheby1()`, `ellip()` for filter design - Apply filters with `scipy.signal.filtfilt()` for zero-phase filtering - Use `scipy.signal.welch()` for power spectral density estimation - Use `scipy.signal.find_peaks()` for peak detection - Leverage `scipy.signal.convolve()` and `correlate()` for convolution ## scipy.sparse - Sparse Matrices - Use appropriate sparse format for your use case: - `csr_matrix` for efficient row slicing and matrix-vector products - `csc_matrix` for efficient column slicing - `coo_matrix` for constructing sparse matrices - `lil_matrix` for incremental construction - Convert to optimal format before operations - Use `scipy.sparse.linalg` solvers for sparse linear systems ## Performance Optimization - Use appropriate data types (`float64` for precision, `float32` for memory) - Leverage BLAS/LAPACK through SciPy for optimized linear algebra - Pre-allocate arrays when possible - Use in-place operations when available ## Error Handling and Validation - Check convergence status of optimization routines - Validate numerical results for reasonableness - Handle ill-conditioned problems gracefully - Use appropriate tolerances for convergence criteria ## Testing Scientific Code - Test against known analytical solutions - Use `np.testing.assert_allclose()` for numerical comparisons - Test edge cases and boundary conditions - Verify conservation laws and invariants ## Key Conventions - Import specific submodules: `from scipy import optimize, stats, linalg` - Use `snake_case` for variables and functions - Document algorithm choices and parameters - Include convergence diagnostics in output
© Mindrally · Apache-2.0 · Mindrally/skills