dp-patterns

dp-patterns is a skill for Claude Code from sequenzia/agent-alchemy. It costs 31 tokens per session (5,396 once invoked), scanned A, original, MIT.

A reference guide to dynamic programming, a way to solve problems by breaking them into smaller repeated parts and reusing their answers. It covers eight common patterns, Python templates, edge cases, and mistakes.

In plain words
What is it for?
Use it for optimization, counting, and subsequence problems with repeated subproblems, including tasks involving capacities, indexes, or visited items.
Why use it?
It helps you recognize when dynamic programming fits and avoid incorrect states, formulas, starting cases, or calculation order.

Skill for Claude Code

Written for Claude Code: disable-model-invocation in frontmatter.

Part of the agent-alchemy-cs-tools plugin — 8 skills, 2 agents shipped together

Good fit Use it for optimization, counting, and subsequence problems with repeated subproblems, including tasks involving capacities, indexes, or visited items.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/sequenzia/agent-alchemy/dp-patterns
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add sequenzia/agent-alchemy --skill dp-patterns
Clone the repo
git clone --depth 1 https://github.com/sequenzia/agent-alchemy

Made for: Claude Code.

Or install agent-alchemy-cs-tools, the plugin that ships this one along with the rest of its 8 skills, 2 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for dp-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/sequenzia/agent-alchemy/dp-patterns/github.svg)](https://agentmods.dev/skills/sequenzia/agent-alchemy/dp-patterns)
Your own site
<a href="https://agentmods.dev/skills/sequenzia/agent-alchemy/dp-patterns"><img src="https://agentmods.dev/badge/skills/sequenzia/agent-alchemy/dp-patterns/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for dp-patterns

Your own site · 80×15
<a href="https://agentmods.dev/skills/sequenzia/agent-alchemy/dp-patterns"><img src="https://agentmods.dev/badge/skills/sequenzia/agent-alchemy/dp-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 31 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 5,396 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00031 $0.05396
Opus 5.5 $0.00012 $0.02158
Sonnet 5.5 $0.00006 $0.01079
Haiku 4.5 $0.00003 $0.00540

Measured 1mo ago against content hash e5de460a128f, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

dp-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

claude/cs-tools/skills/dp-patterns/SKILL.md · 429 lines

How it starts

The opening of the file, as written. The whole thing — 429 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Dynamic Programming Patterns

This reference covers eight foundational dynamic programming patterns commonly encountered in algorithmic problem solving. Each pattern includes recognition signals to identify when a problem maps to the technique, a working Python template, and specific edge cases and mistakes to watch for. Load this skill when solving optimization, counting, or subsequence problems that exhibit optimal substructure and overlapping subproblems.

General DP Approach

Before selecting a specific pattern, apply this checklist:

  1. Identify the state: What information do you need to uniquely describe a subproblem? (index, remaining capacity, bitmask of visited nodes)
  2. Define the recurrence: How does the answer for the current state relate to answers for smaller states?
  3. Establish base cases: What are the trivial subproblems with known answers?
  4. Determine iteration order: Ensure every state is computed before it is needed (bottom-up) or use memoization (top-down)
  5. Optimize space: If dp[i] depends only on dp[i-1] (or a small window), use rolling arrays instead of the full table

Pattern Recognition Table

Trigger Signals Technique Typical Complexity
"count the number of ways", "how many distinct paths" Fibonacci / Climbing Stairs O(N) time, O(1) space
"maximize value with weight limit", "partition into two equal subsets" 0/1 Knapsack O(N * W) time, O(W) space
"longest common subsequence", "minimum edit operations" LCS / Edit Distance O(N * M) time, O(min(N, M)) space
"longest increasing subsequence", "minimum number of envelopes" LIS O(N log N) time, O(N) space
"unique paths in grid", "minimum cost to reach bottom-right" Grid DP O(R * C) time, O(C) space
"maximum subarray sum", "best contiguous segment" Kadane's Algorithm O(N) time, O(1) space
"fewest coins to make amount", "ways to combine denominations" Coin Change / Unbounded Knapsack O(N * amount) time, O(amount) space
"visit all nodes exactly once", "assign N items optimally", N <= 20 Bitmask DP O(2^N * N) time, O(2^N) space

Read the full file on GitHub · 429 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 429 lines · 31 tokens per session scan A e5de460a128f

Subscribe to this mod's changes

dp-patterns is a skill published in the GitHub repository sequenzia/agent-alchemy (45 stars, last pushed 4mo ago), licensed MIT. It adds 31 tokens to every session and 5,396 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

ccc-research

Research before you build: cited multi-source research, spec interviews, cross-model review, literature reviews, competitive and trend analysis, and large-document or large-codebase ingestion. Use when the user wants options compared, prior art found, a spec defined, or something too big summarized.

KevinZai/commander · 60 tokens

add-didactic-comments

Comment tagged files so the user learns the APIs they are studying, with a doc link in every comment.

MK27MK/no-bs-skills · 27 tokens

gan-zhong-xue

A learning workflow that makes an AI explain code changes through questions, evidence, and underlying principles. It is designed to help developers understand work they asked an AI to do, rather than merely accept the result.

ly8427/gan-zhong-xue · 288 tokens

bro

Use when the user says an explanation was unclear, too technical, or full of jargon, or asks for plain language.

reidemeister94/development-skills · 26 tokens

formal-methods-guide

A reference guide to formal methods, which use mathematics to describe and check how software should behave, with a focus on the VDM-SL specification language. It explains VDM-SL types, conditions, invariants, and proof obligations in developer-friendly terms.

kotaroyamame/formal-agent-contracts · 104 tokens

quiz-me

Use right after writing or editing code or files for the user — before ending your turn — to quiz them on what was just built and confirm they actually understand it. Also triggers on "quiz me", "test my understanding", "check what I learned", "comprehension check", or recovering the understanding that vaporizes when…

Ciucky/no-numb · 81 tokens