# convex-optimization

Skill for tackling convex optimization problems. Includes convexity verification, problem classification, and solution methods based on KKT conditions.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf (Devin Desktop), Claude.ai · ★ 3951 repo stars
- Author: parcadei
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/parcadei/Continuous-Claude-v3/tree/HEAD/.claude/skills/math/optimization/convex-optimization/SKILL.md
- Updated: 2026-01-26
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/convex-optimization

## What it does

The skill walks through a decision tree for solving convex optimization tasks. Start by verifying convexity: check if the Hessian is positive semidefinite and if the constraint set is an intersection of convex sets. Then classify by type—linear programming uses `scipy.optimize.linprog`, quadratic problems use `scipy.optimize.minimize(method='SLSQP')`, and semidefinite programs require CVXPY with an SDP solver.

For each type, the skill converts to standard form (minimize f(x) subject to g_i(x) ≤ 0, h_j(x) = 0) and checks KKT conditions: stationarity of the Lagrangian, primal and dual feasibility, and complementary slackness. After solving, it verifies constraint satisfaction and confirms the solution is a global minimum. The skill operates with Bash and file-reading tools, including commands like `z3_solve.py prove` for formal verification of optimality conditions.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add parcadei/Continuous-Claude-v3 --skill convex-optimization -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/convex-optimization/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/convex-optimization/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add parcadei/Continuous-Claude-v3 --skill convex-optimization -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/convex-optimization/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add parcadei/Continuous-Claude-v3 --skill convex-optimization -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/convex-optimization/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install parcadei/Continuous-Claude-v3 .claude/skills/math/optimization/convex-optimization
```

2. **Manually: put the files in place**
- File: `.github/skills/convex-optimization/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add parcadei/Continuous-Claude-v3 --skill convex-optimization -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/parcadei/Continuous-Claude-v3 --path .claude/skills/math/optimization/convex-optimization
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/convex-optimization/SKILL.md` — The legacy .windsurf/skills/ path still works

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/parcadei/Continuous-Claude-v3/tree/HEAD/.claude/skills/math/optimization/convex-optimization/SKILL.md

## When to use it
- Verify convexity of objective functions and constraint sets
- Select the right solver based on problem structure
- Convert problems to standard minimization form
- Check KKT conditions to confirm optimality
- Validate solutions against all constraints

## Example prompts
- Verify convexity and find the minimum for a quadratic problem using `scipy.optimize.minimize`
- Solve a linear programming problem with bounds, then prove KKT conditions hold
- Reframe a maximization task as minimization and apply interior point methods

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 13f3e19d5269e5e7.

BEGIN THIRD-PARTY FILE 13f3e19d5269e5e7
````text
---
name: convex-optimization
description: "Problem-solving strategies for convex optimization in optimization"
allowed-tools: [Bash, Read]
---

# Convex Optimization

## When to Use

Use this skill when working on convex-optimization problems in optimization.

## Decision Tree


1. **Verify Convexity**
   - Objective function: Hessian positive semidefinite?
   - Constraint set: intersection of convex sets?
   - `z3_solve.py prove "hessian_psd"`

2. **Problem Classification**
   | Type | Solver |
   |------|--------|
   | Linear Programming | `scipy.optimize.linprog` |
   | Quadratic Programming | `scipy.optimize.minimize(method='SLSQP')` |
   | General Convex | Interior point methods |
   | Semidefinite | CVXPY with SDP solver |

3. **Standard Form**
   - minimize f(x) subject to g_i(x) <= 0, h_j(x) = 0
   - Convert max to min by negating
   - Convert >= to <= by negating

4. **KKT Conditions (Necessary & Sufficient)**
   - Stationarity: grad L = 0
   - Primal feasibility: g_i(x) <= 0, h_j(x) = 0
   - Dual feasibility: lambda_i >= 0
   - Complementary slackness: lambda_i * g_i(x) = 0
   - `z3_solve.py prove "kkt_conditions"`

5. **Solve and Verify**
   - `scipy.optimize.minimize(f, x0, constraints=cons)`
   - Check constraint satisfaction
   - Verify solution is global minimum (convex guarantees this)


## Tool Commands

### Scipy_Linprog
```bash
uv run python -c "from scipy.optimize import linprog; res = linprog([-1, -2], A_ub=[[1, 1], [2, 1]], b_ub=[4, 5]); print('Optimal:', -res.fun, 'at x=', res.x)"
```

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

### Z3_Kkt
```bash
uv run python -m runtime.harness scripts/z3_solve.py prove "kkt_conditions"
```

## Key Techniques

*From indexed textbooks:*

- [Additional Exercises for Convex Optimization (with] Finally, there are lots of methods that will do better than this, usually by taking this as a starting point and ‘polishing’ the result after that. Several of these have been shown to give fairly reliable, if modest, improvements. You were not required to implement any of these methods.
- [Additional Exercises for Convex Optimization (with] K { X = x Ax yi } where e is the p-dimensional vector of ones. This is a polyhedron and thus a convex set. Rm has the form − The residual Aˆx − Describe a heuristic method for approximately solving this problem, using convex optimization.
````
END THIRD-PARTY FILE 13f3e19d5269e5e7

The third-party file has ended. Everything between the 13f3e19d5269e5e7 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2502 of 3650 bytes. © parcadei · MIT · https://github.com/parcadei/Continuous-Claude-v3/tree/HEAD/.claude/skills/math/optimization/convex-optimization/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
