choose-data-structure
Skill7 starsChanged 15 days agoMITView on GitHub
Use when a collection's access pattern is wrong — linear scan, missing index, re-sort, set-versus-list — and you must pick the structure with the right complexity.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- VelimirMueller/claude-skillsword for word, first seen Nov 1, 2026
Other versions1 project uses a version of this.
Word for word · 1
- VelimirMueller/claude-skills★ 7100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository156 other files it gives its agents.
- skills/swift/swiftui-design-principles/AGENTS.mdAGENTS.md
- skills/swift/ios-code-audit/CLAUDE.mdCLAUDE.md
- skills/swift/swift-focusengine-pro/llms.txtllms.txt
- build-llm-seamSkill
- build-mcp-serverSkill
- build-rag-pipelineSkill
- secure-llm-featuresSkill
- set-up-llm-evalsSkill
- build-nextjs-backendSkill
- build-supabase-edge-functionSkill
- configure-backend-testsSkill
- design-http-apiSkill
- harden-backendSkill
- scaffold-fastapi-serviceSkill
- scaffold-go-serviceSkill
- scaffold-hono-serviceSkill
- secure-supabase-rlsSkill
- set-up-backend-authSkill
- set-up-background-jobsSkill
- set-up-databaseSkill
- set-up-nextjs-supabase-authSkill
- set-up-observabilitySkill
- set-up-supabaseSkill
- build-cliSkill
- release-cliSkill
- set-up-dev-toolchainSkill
- audit-securitySkill
- audit-toolchainSkill
- extend-skillsetSkill
- promote-releaseSkill
- set-up-stack-profileSkill
- write-commit-messagesSkill
- write-pull-requestsSkill
- analyze-complexitySkill
- apply-algorithmsSkill
- apply-design-patternsSkill
- apply-design-principlesSkill
- apply-solidSkill
- debug-systematicallySkill
- enforce-dependency-ruleSkill
- refactor-safelySkill
- slice-and-estimateSkill
- write-clean-testsSkill
- write-readable-codeSkill
- clean-frontend-scaffoldingSkill
- configure-accessibilitySkill
- configure-analyticsSkill
- configure-ciSkill
- configure-error-trackingSkill
- configure-lintingSkill
- configure-test-stackSkill
- configure-typescriptSkill
- create-moduleSkill
- optimize-performanceSkill
- scaffold-frontend-projectSkill
- set-up-authSkill
- set-up-design-systemSkill
- set-up-document-headSkill
- set-up-error-boundariesSkill
- set-up-feature-flagsSkill
- The first 60 shown.
The file
Files
Choose Data Structure
Picks the collection whose access pattern matches how the code actually uses it (CLRS). Pairs with analyze-complexity — this is the structure half of the same decision.
The table
| Access pattern | Structure | Cost |
| Indexed access by position | Array / slice / vector | O(1) |
| Keyed lookup, no order needed | Hash table / map / dict | O(1) average |
| Ordered or range queries, min/max | Balanced BST / sorted tree | O(log n) |
| Peek min or max, push and pop | Heap / priority queue | O(1) peek, O(log n) push/pop |
| Insert/delete at a known position | Linked list | O(1) after the node, O(n) to find it |
| Membership with ordering | Sorted array + binary search | O(log n) search, O(n) insert |
| Set of unique keys | Set | O(1) membership |
1. Audit (change nothing)
cat .claude/stack-profile.md 2>/dev/null | head -20
grep -rn "\.find(\|\.includes(\|\.indexOf(\|\.sort(\|\.filter(" --include="*.ts" --include="*.rs" --include="*.go" --include="*.py" . 2>/dev/null | head -30Name the actual access: is the code searching for one element repeatedly (→ map/set, not array), does it need the smallest repeatedly (→ heap), does it re-sort the same list (→ keep it sorted), does it test membership on a list (→ set)? Each mismatch is a change, not a rewrite.
2. Match structure to use
- Repeated
find/includeson an array → build a map or set once, look up inO(1). - Repeated min/max over an unsorted list → a heap.
- "Does this value exist?" on a list → a set.
- Ordered iteration over a changing sorted list → a balanced tree or a sorted structure that stays sorted.
- A fixed-size lookup table keyed by a small enum → a plain array indexed by the enum.
3. State the trade-off
A hash map buys O(1) lookup and gives up order; a tree buys order and gives up the constant factor; an
array buys cache locality and gives up keyed lookup. Name which property the code needs and which it
gives up, and keep the simpler structure when both work.
Verify
The repeated linear scan is gone (one O(1) lookup replaces it), the re-sort is gone (the structure stays
sorted), and the chosen structure's complexity matches the named access pattern. State the before/after in
the note.
When to deviate
- Bounded collections (a handful of items): the constant factor of a map may cost more than a linear scan.
- The structure is the framework's own (a query cache, a store) — use it, do not hand-build a replacement.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

