traveling-salesman-problem

traveling-salesman-problem is a skill for Claude Code from hajibabaie/combinatorial-optimization-skills. It costs 152 tokens per session (11,148 once invoked), scanned A, original, MIT.

A guide to the traveling salesman problem, where a route must visit each location once and return to its start at low cost. It covers exact models, construction methods, and route-improvement moves.

In plain words
What is it for?
Use it to model, solve, improve, and independently validate tours, including methods such as nearest neighbor, 2-opt, and mixed-integer programming.
Why use it?
It helps choose a suitable solving method based on problem size and verifies that a reported route is complete and correctly measured.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: positional $N argument.

Part of the combinatorial-optimization plugin — 76 skills shipped together

Good fit Use it to model, solve, improve, and independently validate tours, including methods such as nearest neighbor, 2-opt, and mixed-integer programming.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/hajibabaie/combinatorial-optimization-skills/traveling-salesman-problem
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 hajibabaie/combinatorial-optimization-skills --skill traveling-salesman-problem
Clone the repo
git clone --depth 1 https://github.com/hajibabaie/combinatorial-optimization-skills

Made for: Claude Code.

Or install combinatorial-optimization, the plugin that ships this one along with the rest of its 76 skills.

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 traveling-salesman-problem

README.md
[![agentmods](https://agentmods.dev/badge/skills/hajibabaie/combinatorial-optimization-skills/traveling-salesman-problem/github.svg)](https://agentmods.dev/skills/hajibabaie/combinatorial-optimization-skills/traveling-salesman-problem)
Your own site
<a href="https://agentmods.dev/skills/hajibabaie/combinatorial-optimization-skills/traveling-salesman-problem"><img src="https://agentmods.dev/badge/skills/hajibabaie/combinatorial-optimization-skills/traveling-salesman-problem/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 traveling-salesman-problem

Your own site · 80×15
<a href="https://agentmods.dev/skills/hajibabaie/combinatorial-optimization-skills/traveling-salesman-problem"><img src="https://agentmods.dev/badge/skills/hajibabaie/combinatorial-optimization-skills/traveling-salesman-problem.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 152 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 11,148 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.00152 $0.11148
Opus 5 $0.00076 $0.05574
Sonnet 5 $0.00030 $0.02230
Haiku 4.5 $0.00015 $0.01115

Measured 8d ago against content hash de9a7655674e, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

traveling-salesman-problem 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 8d 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.

skills/traveling-salesman-problem/SKILL.md · 900 lines

How it starts

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

Traveling Salesman Problem

You are an expert in the traveling salesman problem. This skill covers exact MIP formulations (MTZ vs DFJ with lazy subtour cuts in Gurobi), construction heuristics (nearest neighbor, greedy edge, Christofides), 2-opt/3-opt/Or-opt local search, the Lin-Kernighan idea, TSPLIB conventions, instance generation, and independent solution validation. Use the framework below to pick the method that fits the instance size and quality target, and to deliver tours verified by code independent of their producer.

Initial Assessment

Establish these facts before formulating or writing any code:

  • Instance size. n ≤ 20: Held-Karp DP is exact and trivial (see dynamic-programming). n ≤ ~100: MTZ is acceptable, DFJ is better. n ≤ ~5,000: DFJ with lazy cuts (or Concorde) solves most Euclidean instances to optimality. Beyond that: heuristics with Held-Karp bound for the gap report, or LKH.
  • Symmetric or asymmetric? c_ij = c_ji or not? This changes the formulation (edge vs arc variables), the valid local-search moves (2-opt deltas are wrong under asymmetry because segment reversal changes arc directions), and the available codes.
  • Metric or not? Christofides' 3/2 guarantee needs the triangle inequality. Distances from road networks usually satisfy it; penalized or forbidden arcs may not.
  • Distance convention. TSPLIB EUC_2D rounds each distance to the nearest integer. Comparing a float-distance tour length against published optima is the single most common TSP reporting error. Fix the convention before benchmarking.
  • Data format. Coordinates (compute distances on the fly or once) vs explicit matrix. A float64 matrix needs 8n² bytes: 800 MB at n = 10,000. Above a few thousand cities, plan k-nearest-neighbor candidate lists instead of full matrices.
  • Exact or heuristic? What gap is acceptable, and must it be proven? A proven 0% gap requires the MIP/Concorde route; "within ~1-2% almost surely" is cheap with 2-opt + Or-opt inside a metaheuristic.
  • Time budget. Seconds, minutes, hours? DFJ with lazy cuts may need minutes at n = 1,000; a 2-opt descent takes milliseconds.
  • Solver availability. Gurobi license present? If not, plan OR-Tools or HiGHS-based fallbacks (the formulations below transfer directly).
  • Is it really a TSP? Multiple vehicles, capacities, time windows, or depots make it a VRP (see vehicle-routing-problem). An open path (no return), fixed endpoints, or precedence constraints change the model; see the transformations under Advanced Techniques.
  • Reproducibility. Seed every random construction and perturbation (np.random.default_rng(seed)) and record solver parameter settings with results.

Read the full file on GitHub · 900 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. 8d ago First seen · 900 lines · 152 tokens per session scan A de9a7655674e

Subscribe to this mod's changes

traveling-salesman-problem is a skill published in the GitHub repository hajibabaie/combinatorial-optimization-skills (7 stars, last pushed 3mo ago), licensed MIT. It adds 152 tokens to every session and 11,148 once invoked, about $0.0008 per session on Opus 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-09-03.

Related

Other skills, from other repositories

phx-deps-audit

Audit Hex deps for supply-chain security risk — bidi chars, compile-time exec, maintainer changes, typosquats, CVEs. Use after mix deps.update, when checking if a package upgrade is safe, or reviewing mix.lock PR diffs.

oliver-kriska/claude-elixir-phoenix · 58 tokens

release

CONTRIBUTOR TOOL - Cut a plugin release: bump plugin.json version, finalize CHANGELOG, update README if needed, gate on make ci, commit, tag vX.Y.Z, and create the GitHub release. Use when shipping a new plugin version. NOT distributed.

oliver-kriska/claude-elixir-phoenix · 60 tokens

session-deep-dive

Deep qualitative analysis of high-signal sessions. Spawns subagents with v2 template, synthesizes patterns, compares against known findings. Use after /session-scan.

oliver-kriska/claude-elixir-phoenix · 40 tokens

catchup

Summarize and review what changed while you were away. Use after a weekend, vacation, or flight to check missed PRs, git commits, Linear tickets, and meetings — one prioritized brief, not a firehose.

oliver-kriska/claude-elixir-phoenix · 48 tokens

brainstorm

Brainstorm Elixir/Phoenix features — explore ideas, compare approaches, gather requirements. Use when vague idea, not sure how to approach, or want to discuss before plan.

oliver-kriska/claude-elixir-phoenix · 39 tokens

learn-from-fix

Capture Elixir/Ecto/LiveView lessons and Hex API rules. Use after corrections or when asked to document learning, record a lesson, prevent a fixed mistake, or remember package guidance with --library.

oliver-kriska/claude-elixir-phoenix · 46 tokens