encapsulate-collection

encapsulate-collection is a skill for Claude Code from msbaek/msbaek-claude-plugins. It costs 110 tokens per session (2,210 once invoked), scanned A, original, MIT.

A collection-encapsulation helper keeps a class's internal list or set from being changed directly by callers. It returns a read-only view and provides methods for adding and removing items.

In plain words
What is it for?
Use it when a class exposes a collection through a getter and you want callers to use controlled add and remove operations instead.
Why use it?
Direct access to internal collections can let other code change state without the class checking the change. This keeps those updates under the class's control.

Skill for Claude Code

Written for Claude Code: argument-hint in frontmatter.

Part of the msbaek-tdd plugin — 28 skills, 10 agents, 2 hooks shipped together

Good fit Use it when a class exposes a collection through a getter and you want callers to use controlled add and remove operations instead.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/msbaek/msbaek-claude-plugins/encapsulate-collection
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 msbaek/msbaek-claude-plugins --skill encapsulate-collection
Clone the repo
git clone --depth 1 https://github.com/msbaek/msbaek-claude-plugins

Made for: Claude Code.

Or install msbaek-tdd, the plugin that ships this one along with the rest of its 28 skills, 10 agents, 2 hooks.

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 encapsulate-collection

README.md
[![agentmods](https://agentmods.dev/badge/skills/msbaek/msbaek-claude-plugins/encapsulate-collection/github.svg)](https://agentmods.dev/skills/msbaek/msbaek-claude-plugins/encapsulate-collection)
Your own site
<a href="https://agentmods.dev/skills/msbaek/msbaek-claude-plugins/encapsulate-collection"><img src="https://agentmods.dev/badge/skills/msbaek/msbaek-claude-plugins/encapsulate-collection/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 encapsulate-collection

Your own site · 80×15
<a href="https://agentmods.dev/skills/msbaek/msbaek-claude-plugins/encapsulate-collection"><img src="https://agentmods.dev/badge/skills/msbaek/msbaek-claude-plugins/encapsulate-collection.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 110 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,210 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.00110 $0.02210
Opus 5.5 $0.00044 $0.00884
Sonnet 5.5 $0.00022 $0.00442
Haiku 4.5 $0.00011 $0.00221

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

Security

Grade A, and why

encapsulate-collection 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 2mo 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.

msbaek-tdd/skills/encapsulate-collection/SKILL.md · 263 lines

How it starts

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

Encapsulate Collection

GOAL

컬렉션을 반환하는 getter가 내부 상태를 직접 노출하는 것을 방지하여:

  • 불변성(Immutability) 보장
  • 캡슐화 원칙 준수
  • 의도하지 않은 외부 수정 방지
  • First Class Collection의 첫 단계

CONSTRAINTS

  • 계열: System-wide — 후보 제시 후 승인 받고 적용 (../../references/refactoring-procedure.md §0·§3-B)
  • 동작 변경 금지: 구조 개선만 수행 (기능 변경 없음)
  • 테스트 수정 금지: 구조 변경이 테스트를 실패시키면 되돌리기
  • 사용자 확인 필수: 자동 적용 금지
  • 명시적 git add: git add -A 금지, 변경된 파일만 명시

적용 패턴

Before: 내부 컬렉션 직접 노출

class Course {
    private List<Student> students = new ArrayList<>();
    
    public List<Student> getStudents() {
        return students;  // 위험: 외부에서 수정 가능
    }
}

// 호출부: 캡슐화 위반
course.getStudents().add(student);  // 직접 수정
course.getStudents().clear();       // 위험한 조작

After: Unmodifiable 반환 + 명시적 메서드

class Course {
    private List<Student> students = new ArrayList<>();
    
    public List<Student> getStudents() {
        return Collections.unmodifiableList(students);
    }
    
    public void addStudent(Student student) {
        students.add(student);
    }
    
    public void removeStudent(Student student) {
        students.remove(student);
    }
}

// 호출부: 명시적 메서드 사용
course.addStudent(student);
course.removeStudent(student);

추가 예시: Set 컬렉션

class Team {
    private Set<Member> members = new HashSet<>();
    
    public Set<Member> getMembers() {
        return Collections.unmodifiableSet(members);
    }
    
    public void addMember(Member member) {
        members.add(member);
    }
    
    public void removeMember(Member member) {
        members.remove(member);
    }
    
    public boolean hasMember(Member member) {
        return members.contains(member);
    }
}

추가 예시: 복사본 반환 (방어적 복사)

class Order {
    private List<OrderItem> items = new ArrayList<>();
    
    // Option 1: Unmodifiable (읽기 전용)
    public List<OrderItem> getItems() {
        return Collections.unmodifiableList(items);
    }
    
    // Option 2: 방어적 복사 (완전 격리)
    public List<OrderItem> getItemsCopy() {
        return new ArrayList<>(items);
    }
}

Read the full file on GitHub · 263 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. 2mo ago Changed · +68 tokens per session 2a0250dc0fa3
  2. 2mo ago Changed · -2 lines efa3c169d6ea
  3. 3mo ago First seen · 265 lines · 42 tokens per session scan A 951c981b2c31

Subscribe to this mod's changes

encapsulate-collection is a skill published in the GitHub repository msbaek/msbaek-claude-plugins (8 stars, last pushed 1mo ago), licensed MIT. It adds 110 tokens to every session and 2,210 once invoked, about $0.0004 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-31.

Related

encapsulate-collection compared with skills from other repositories

encapsulate-collection next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
encapsulate-collectionmsbaek/msbaek-claude-pluginsSkill81mo agoMITA110Claude Code
local-ai-agentsmicrosoft/ai-agents-for-beginnersSkill82ktodayMITA200Claude Code, Codex
imagegenopenai/codexSkill137ktodayApache-2.0A113Codex
playwright-climicrosoft/playwrightSkill102ktodayApache-2.0A19Claude Code
browser-automationopenclaw/openclawSkill396ktodayMITA36Claude Code
free-llm-apismnfst/awesome-free-llm-apisSkill15ktodayCC0-1.0A113Claude Code, Codex
systematic-debuggingobra/superpowersSkill333k7d agoMITA21Claude Code