use-defaultdict-groups

use-defaultdict-groups is a skill for Claude Code from jimmc414/claude-code-plugin-marketplace. It costs 32 tokens per session (699 once invoked), scanned A, original, MIT.

A Python dictionary type that creates a default value automatically when a missing key is accessed.

In plain words
What is it for?
Use it for grouping values, building graph adjacency lists, collecting unique items, counting, and creating nested structures.
Why use it?
It removes repeated checks for whether a key exists before adding grouped, nested, or counted data. A regular dictionary is better when missing keys should cause an error.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the norvig-patterns plugin — 54 skills shipped together

Good fit Use it for grouping values, building graph adjacency lists, collecting unique items, counting, and creating nested structures.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/jimmc414/claude-code-plugin-marketplace/use-defaultdict-groups
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 jimmc414/claude-code-plugin-marketplace --skill use-defaultdict-groups
Clone the repo
git clone --depth 1 https://github.com/jimmc414/claude-code-plugin-marketplace

Made for: Claude Code.

Or install norvig-patterns, the plugin that ships this one along with the rest of its 54 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 use-defaultdict-groups

README.md
[![agentmods](https://agentmods.dev/badge/skills/jimmc414/claude-code-plugin-marketplace/use-defaultdict-groups/github.svg)](https://agentmods.dev/skills/jimmc414/claude-code-plugin-marketplace/use-defaultdict-groups)
Your own site
<a href="https://agentmods.dev/skills/jimmc414/claude-code-plugin-marketplace/use-defaultdict-groups"><img src="https://agentmods.dev/badge/skills/jimmc414/claude-code-plugin-marketplace/use-defaultdict-groups/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 use-defaultdict-groups

Your own site · 80×15
<a href="https://agentmods.dev/skills/jimmc414/claude-code-plugin-marketplace/use-defaultdict-groups"><img src="https://agentmods.dev/badge/skills/jimmc414/claude-code-plugin-marketplace/use-defaultdict-groups.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 32 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 699 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.00032 $0.00699
Opus 5.5 $0.00013 $0.00280
Sonnet 5.5 $0.00006 $0.00140
Haiku 4.5 $0.00003 $0.00070

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

Security

Grade A, and why

use-defaultdict-groups 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 3mo 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.

plugins/norvig-patterns/skills/use-defaultdict-groups/SKILL.md · 93 lines

How it starts

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

use-defaultdict-groups

When to Use

  • Building adjacency lists for graphs
  • Grouping items by some key
  • Multi-maps (key -> list of values)
  • Nested dict structures
  • Avoiding if key not in dict checks
  • Counting (though Counter is often better)

When NOT to Use

  • Simple key-value mapping (use regular dict)
  • When missing key should raise error
  • When default value is complex/expensive

The Pattern

Use defaultdict to auto-initialize missing keys.

from collections import defaultdict

# List default - for grouping
groups = defaultdict(list)
groups['a'].append(1)  # No KeyError, creates empty list first
groups['a'].append(2)
# {'a': [1, 2]}

# Set default - for unique grouping
unique_groups = defaultdict(set)
unique_groups['a'].add(1)
unique_groups['a'].add(1)  # Deduped
# {'a': {1}}

# Int default - for counting
counts = defaultdict(int)
counts['a'] += 1  # No KeyError, starts at 0
# {'a': 1}

# Nested defaultdict
tree = lambda: defaultdict(tree)
d = tree()
d['a']['b']['c'] = 1  # Auto-creates nested structure

Example (from pytudes)

from collections import defaultdict

# Adjacency list for graphs (AdventUtils.ipynb)
class multimap(defaultdict):
    """A mapping of {key: [val1, val2, ...]}."""
    def __init__(self, pairs=(), symmetric=False):
        self.default_factory = list
        for key, val in pairs:
            self[key].append(val)
            if symmetric:
                self[val].append(key)

# Usage
edges = [('a', 'b'), ('a', 'c'), ('b', 'd')]
graph = multimap(edges, symmetric=True)
# graph['a'] = ['b', 'c']
# graph['b'] = ['a', 'd']

# Grouping by attribute
students = [('Alice', 'Math'), ('Bob', 'CS'), ('Carol', 'Math')]
by_major = defaultdict(list)
for name, major in students:
    by_major[major].append(name)
# {'Math': ['Alice', 'Carol'], 'CS': ['Bob']}

# Precomputing relationships (Sudoku.ipynb concept)
units = defaultdict(list)
for unit in all_units:
    for square in unit:
        units[square].append(unit)
# units['A1'] = [row_unit, col_unit, box_unit]

Read the full file on GitHub · 93 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. 3mo ago First seen · 93 lines · 32 tokens per session scan A b2ce9c2be427

Subscribe to this mod's changes

use-defaultdict-groups is a skill published in the GitHub repository jimmc414/claude-code-plugin-marketplace (4 stars, last pushed today), licensed MIT. It adds 32 tokens to every session and 699 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-09-04.

Related

use-defaultdict-groups compared with skills from other repositories

use-defaultdict-groups next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
use-defaultdict-groupsjimmc414/claude-code-plugin-marketplaceSkill4todayMITA32Claude Code
clean-codeSagargupta16/claude-skillsSkill53d agoMITA66Claude Code
csharp-source-generatorAndyElessar/skillsSkill23d agononeA112Claude Code
rust-coding-standardssystempromptio/systemprompt-marketplaceSkill21mo agononeA26Claude Code
extension-buildingsystempromptio/systemprompt-marketplaceSkill21mo agononeA27Claude Code
rust-dev-guidesystempromptio/systemprompt-marketplaceSkill21mo agononeA20Claude Code
agents-cli-claudegoogle/agents-cliSkill6.5k2d agoApache-2.0A77Claude Code