Skip to main content
skill CX Codex

gradient-methods — Claude Code skill for optimization

gradient-methods is a Claude Code skill that helps choose gradient-based optimization methods and step sizes, and diagnose convergence in minimization problems.

MIT ★ 3,951 updated 2026-01-26

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add parcadei/Continuous-Claude-v3 --skill gradient-methods -a claude-code
Open on GitHub

What gradient-methods does

The skill covers gradient descent, step-size selection, accelerated methods, and Newton’s method. It compares fixed steps with backtracking and exact line search, and points to conjugate gradients for quadratic functions. BFGS appears as a quasi-Newton option.

Runnable examples call scipy.optimize.minimize with BFGS and CG; another command calculates a gradient with sympy_compute.py. The skill permits Bash and Read. The optimization examples need SciPy installed, so those commands will fail without that library.

For convergence checks, it suggests tracking gradient norm and function values, while watching for oscillation. An oversized step can cause oscillation, so step selection is a practical part of using the method, not just a formula to copy.

What it helps with

  • choose a step-size rule for gradient descent
  • compare BFGS with conjugate gradients
  • calculate a function gradient with SymPy
  • check convergence using gradients and function values

Example prompts for the agent

  • Help me choose a step size for gradient descent on this optimization problem.
  • Compare BFGS and conjugate gradients for my function.
  • Calculate the function's gradient and show me how to check convergence.

How to install gradient-methods

1Skills CLI (Vercel)

npx skills add parcadei/Continuous-Claude-v3 --skill gradient-methods -a claude-code

2Manually: put the files in place

~/.claude/skills/gradient-methods/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/gradient-methods/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about gradient-methods

How do I install gradient-methods in Claude Code?

Run npx skills add parcadei/Continuous-Claude-v3 --skill gradient-methods -a claude-code. The skill file is at ~/.claude/skills/gradient-methods/SKILL.md.

What does gradient-methods do?

It guides method selection, step-size choices, and convergence checks for optimization. Its coverage includes gradient descent, accelerated methods, and Newton’s method.

What do the gradient-methods examples require?

The skill uses Bash and Read. Its optimization commands call scipy.optimize.minimize, while the gradient example uses sympy_compute.py.

Source text

SKILL.md · MIT
---
name: gradient-methods
description: "Problem-solving strategies for gradient methods in optimization"
allowed-tools: [Bash, Read]
---

# Gradient Methods

## When to Use

Use this skill when working on gradient-methods problems in optimization.

## Decision Tree


1. **Basic Gradient Descent**
   - Update: x_{k+1} = x_k - alpha * grad f(x_k)
   - Step size alpha: fixed, diminishing, or line search
   - Convergence: O(1/k) for convex, linear for strongly convex

2. **Step Size Selection**
   | Method | Approach |
   |--------|----------|
   | Fixed | alpha constant (requires tuning) |
   | Backtracking | Armijo condition: f(x - alpha*grad) <= f(x) - c*alpha*||grad||^2 |
   | Exact line search | minimize f(x - alpha*grad) over alpha |
   | Adaptive | Adam, RMSprop (ML applications) |

3. **Accelerated Methods**
   - Momentum: add velocity term
   - Nesterov: look-ahead gradient
   - Conjugate gradient: for quadratic functions
   - `scipy.optimize.minimize(f, x0, method='CG')` - conjugate gradient

4. **Newton's Method**
   - Update: x_{k+1} = x_k - H^{-1} * grad f
   - Requires Hessian (expensive but quadratic convergence)
   - Quasi-Newton (BFGS): approximate Hessian
   - `scipy.optimize.minimize(f, x0, method='BFGS')`

5. **Convergence Diagnostics**
   - Monitor ||grad f|| < tolerance
   - Check function value decrease
   - Watch for oscillation (step size too large)
   - `sympy_compute.py diff "f" --var x` for gradient


## Tool Commands

### Scipy_Bfgs
```bash
uv run python -c "from scipy.optimize import minimize; res = minimize(lambda x: (x[0]-1)**2 + 100*(x[1]-x[0]**2)**2, [0, 0], method='BFGS'); print('Rosenbrock min at', res.x)"
```

### Scipy_Cg
```bash
uv run python -c "from scipy.optimize import minimize; res = minimize(lambda x: x[0]**2 + x[1]**2, [1, 1], method='CG'); print('Min at', res.x)"
```

### Sympy_Gradient
```bash
uv run python -m runtime.harness scripts/sympy_compute.py diff "x**2 + y**2" --var "[x, y]"
```

## Key Techniques

*From indexed textbooks:*

- [nonlinear programming_tif] Gradient Methods** - These methods use gradient information to iteratively approach the optimum. Convergence** - Addressing convergence properties. Descent Directions and Stepsize Rules:** Focuses on how to choose descent directions and appropriate step sizes.
- [nonlinear programming_tif] The application of gradient methods to unconstrained optimal control prob- lems is straightforward in principle. For example the steepest descent method takes the form W = b oMV H, (kb ph,y), i=0,. Pl = Thus, given u¥, one computes zF by forward propagation of the system equation, and then p*¥ by backward propagation of the adjoint equation.
- [nonlinear programming_tif] Footer or Trailing Row**: - There is an empty concluding element indicated by a single ". Overall, this table serves as an index for chapters or sections within a document, with particular emphasis on optimization methods and related mathematical strategies, as evidenced by the listed methods like Gradient, Newton, and other derivative techniques. The scattered letters and empty slots may denote a form of stylistic or formatting choice rather than meaningful content in this context.
- [nonlinear programming_tif] Zoutendijk’s method uses tw ) oscalatse)Oand'ye 0,1), a i ! P, where ¢ — Y™k € and my is the firs onnegative k ok 28 %, ) it T #(z*,7"e) < -y (a) Show that (b) Prove that {d*} is gradient relat ishi i i Tt pones A related, thus establishing stationarity of the 2. Min-H Method for Optimal Control) Consider the problem of findin g sequences u = (z1,22,.
- [nonlinear programming_tif] Mustration of the function f of Exercise 1. Stability) (www) We are often interested in whether optimal solutions change radically when the problem data are slightly perturbed. This issue is addressed by stability analysis, to be contrasted with sensitivity analysis, which deals with how much optimal solutions change when problem data change.

## Cognitive Tools Reference

See `.claude/skills/math-mode/SKILL.md` for full tool documentation.

© parcadei · MIT · parcadei/Continuous-Claude-v3

Similar skills

All skills for AI and ML →

From the same set161

The whole set →
residues A Claude Code skill for solving residue problems in complex analysis. Computes residues at poles, identifies pole order, and applies the residue theorem through SymPy and Z3. CX Codex +1 ★ 3,951repo stars hilbert-spaces Solves functional analysis problems involving Hilbert spaces. Use it for orthogonal decomposition, projection theorems, Riesz representation, and computations on orthonormal bases. CX Codex +1 ★ 3,951repo stars debug-agent debug-agent — a subagent that investigates root causes by exploring the codebase, analyzing logs, finding patterns, and writing a detailed report with fix recommendations. CX Codex ★ 3,951repo stars interpolation Guides Claude Code through selecting and running numerical interpolation workflows, from Lagrange polynomials to SciPy splines. CX Codex +1 ★ 3,951repo stars aegis aegis is a Claude Code subagent that finds code vulnerabilities and assesses security risks. It checks a supplied threat model and writes its findings to a project file. CX Codex ★ 3,951repo stars oracle oracle — a subagent for Claude Code that searches the web, queries APIs, and gathers information from external sources. Frames research systematically and synthesizes findings through optional LLM analysis. CX Codex ★ 3,951repo stars onboard onboard — a subagent for Claude Code that analyzes existing code and creates a continuity ledger. Runs when entering a brownfield project with code already in place. CX Codex ★ 3,951repo stars boundary-value-problems A Claude skill that walks from a boundary value problem statement to a numerical answer: shooting, finite differences, solve_bvp and Sturm–Liouville eigenvalues. CX Codex +1 ★ 3,951repo stars

Project sponsors

Companies that keep this analytics open