Check Encapsulation logo

Check Encapsulation

Community
dykyi-roman
check-encapsulation

Analyzes PHP code for encapsulation violations. Detects public mutable state, exposed internals, Tell Don't Ask violations, getter/setter abuse, and information hiding breaches.

Overview

Publisherdykyi-roman
Repositoryawesome-claude-code
Skill namecheck-encapsulation
Stars
98
Forks
25
Bundled files
1
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 1 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by dykyi-roman on GitHub. Read the source before you install it.

Installation

Install the Check Encapsulation AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/dykyi-roman/awesome-claude-code.git /tmp/awesome-claude-code
mkdir -p .claude/skills
cp -r /tmp/awesome-claude-code/skills/check-encapsulation .claude/skills/check-encapsulation
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Check Encapsulation in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Check Encapsulation on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Check Encapsulation is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Encapsulation Analyzer

Overview

This skill analyzes PHP codebases for encapsulation violations — situations where internal state is exposed, getters/setters replace behavior, or the "Tell, Don't Ask" principle is violated.

When to Use

  • Reviewing Domain layer entities and aggregates
  • Detecting anemic domain models
  • Checking for Law of Demeter violations
  • Auditing collection exposure patterns
  • Evaluating getter/behavior ratio in entities

Encapsulation Principles

PrincipleDescriptionViolation Indicator
Information HidingInternal state not exposedPublic properties, many getters
Tell Don't AskObjects perform actions, not expose dataGetter chains, external decisions
Behavioral RichnessObjects have behavior, not just dataAnemic domain model
Invariant ProtectionState changes validate constraintsPublic setters without validation

Analysis Approach

  1. Phase 1 — Public Mutable State: Scan Domain entities for non-readonly public properties
  2. Phase 2 — Getter/Setter Abuse: Count getters vs behavior methods, flag anemic entities
  3. Phase 3 — Tell Don't Ask: Detect getter chains and external conditionals on object state
  4. Phase 4 — Collection Exposure: Find methods returning internal arrays/collections directly
  5. Phase 5 — Exposed Internals: Check for reflection usage, debug methods, mutable object returns
  6. Phase 6 — Constructor Issues: Flag too many dependencies, complex construction without factories

Detection Rules

IDPatternGrep Target
ENC-01Public mutable propspublic string|public int|public array in Domain (exclude readonly)
ENC-02Setter methodspublic function set[A-Z] in Entity/Aggregate
ENC-03Getter chains->get[A-Z].*->get[A-Z].*->get[A-Z]
ENC-04External conditionalsif \(\$.*->get[A-Z].*===
ENC-05Switch on stateswitch \(\$.*->get[A-Z]|match \(\$.*->get[A-Z]
ENC-06Collection returnpublic function get.*\(\): array in Entity
ENC-07Doctrine exposurepublic function get.*\(\): Collection in Domain
ENC-08Reflection accessReflectionClass|ReflectionProperty|setAccessible
ENC-09Debug exposurepublic function toArray\(\)|dump\(\)|debug\(\) in Domain
ENC-10Complex constructionnew [A-Z].*Entity\(|new [A-Z].*Aggregate\( in Application

Severity Classification

IssueSeverity
Public mutable state in EntityCritical
Collection mutated externallyCritical
Anemic entity (ratio > 5.0)Critical
Tell Don't Ask violationMajor
Getter chain (3+ levels)Major
Internal array returnedMajor
Setter in AggregateMinor
Reflection in non-test codeMinor

Report Format

markdown
# Encapsulation Analysis Report

## Summary

| Issue Type | Critical | Warning | Info |
|------------|----------|---------|------|
| Public Mutable State | N | N | - |
| Getter/Setter Abuse | N | N | N |
| Tell Don't Ask | N | N | - |
| Collection Exposure | N | N | - |
| Exposed Internals | N | N | N |

**Encapsulation Score: X%**

## Findings

### [ID]: [Title]
- **File:** `path:line`
- **Issue:** [Description]
- **Code:** [Problematic snippet]
- **Expected:** [Correct pattern]
- **Skills:** [Related generator skills]

## Getter/Behavior Ratio

| Entity | Getters | Setters | Behavior | Ratio | Status |
|--------|---------|---------|----------|-------|--------|

**Target:** Ratio < 2.0

## Refactoring Recommendations

### Immediate
1. Make all entity properties private
2. Replace setters with behavior methods
3. Return collection copies, not references

### Short-term
4. Extract Value Objects for validated data
5. Add factory methods for complex construction
6. Remove getter chains (add shortcut methods)

### Long-term
7. Review anemic entities for missing behavior
8. Consider CQRS to separate read/write models

Integration

Works with:

  • detect-code-smells — Feature Envy, Anemic Model
  • structural-auditor — DDD compliance
  • create-entity — Generate rich entities
  • create-value-object — Encapsulated value types

References

  • references/patterns.md — detailed detection patterns with code examples, report format samples, metrics examples, and rich entity template
  • "Tell, Don't Ask" — Martin Fowler
  • "Anemic Domain Model" — Martin Fowler
  • "Object-Oriented Software Construction" (Bertrand Meyer)
  • "Elegant Objects" (Yegor Bugayenko)

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Check Encapsulation AI skill do?

Analyzes PHP code for encapsulation violations. Detects public mutable state, exposed internals, Tell Don't Ask violations, getter/setter abuse, and information hiding breaches.

Why use Check Encapsulation on TypingMind?

Because you install it once and use it with any model. Check Encapsulation is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Check Encapsulation in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/dykyi-roman/awesome-claude-code/tree/master/skills/check-encapsulation. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Check Encapsulation?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Check Encapsulation?

As many as you like. As long as a model supports skills, you can use Check Encapsulation with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Check Encapsulation AI skill free?

Yes. It is published on GitHub by dykyi-roman under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇