finding-seams
БесплатноБез исполняемых скриптовНе проверенUse when existing code has untestable dependencies that prevent writing tests -- direct construction of collaborators, static or global function calls, tight…
от citypaul★ 764 звезды на GitHubОб этом скилле
Finding Seams
For writing tests that document existing behavior once you have seams, load the characterisation-tests skill. For test-driving new behavior, load the tdd skill. For general test patterns, load the testing skill. For refactoring after tests are in place, load the refactoring skill. Use codebase-design when deciding a module's lasting responsibility and caller-facing contract; this skill introduces the minimum enabling point needed to place existing behavior under test.
Deep-dive resources are in the resources/ directory. Load them on demand:
| Resource | Load when... |
|---|---|
seam-types.md |
Need detailed FP-first examples of each seam type in TypeScript |
creating-seams.md |
Need to introduce a seam where none exists, with before/after examples |
oop-patterns.md |
Encountering legacy class-based code -- object seams, subclass and override, constructor injection |
Core Concept
A seam is a place where you can alter behavior in your program without editing in that place.
Every seam has an enabling point -- the place where you choose which behavior to activate. The source code at the seam stays identical in production and test; only the enabling point differs.
A seam is not automatically a public module interface, port, or permanent abstraction. Introduce the narrowest safe substitution point first; once behavior is characterized, let codebase-design decide whether that point belongs in the durable contract or should remain private scaffolding.
-- Michael Feathers, Working Effectively with Legacy Code (2004)
Connection to hexagonal architecture: Ports are designed-in seams. A port defines a contract (the seam), and the composition root chooses which adapter to wire in (the enabling point). If your code already uses hex arch, you have seams everywhere -- this skill is for code that lacks them. See the hexagonal-architecture skill.
When to Use
- Cannot call a function in a test harness because it reaches for external systems directly
- A function hard-codes a dependency instead of accepting it as a parameter
- Global or static dependencies make isolation impossible
- Singleton access patterns couple code to shared mutable state
- React components fetch data internally instead of receiving it via props/context
Quick Reference: Seam Types for TypeScript/JS
| Seam Type | Mechanism | Enabling Point | Prefer When |
|---|---|---|---|
| Function Parameter | Pass dependency as argument | The argument list | Default choice. Functional code, pure functions, explicit contracts |
| Configuration | Receive config/env values as arguments | The argument list of the function that receives them | Infrastructure-level concerns. A process.env read left inside the function under test is a hidden dependency, not a Configuration seam -- move it out and let the default do the reading |
| Module | vi.mock() / jest.mock() replaces imports |
Test file mock configuration | Last resort. Quick scaffolding only -- bypasses type safety, implicit, requires cleanup. Do not write a new one when you can change the signature, and do not copy one from a neighbouring test: an existing module mock is scaffolding to migrate away from, not the house pattern |
| Object | Subclass and override, or DI via constructor | Where the object is created | Legacy class-based code (see resources/oop-patterns.md) |
Putting Existing Code Under Test
Work through this before writing a single test:
- List every hidden dependency the function reaches for -- collaborators it constructs,
Date.now()/new Date(),process.env, singletons. All of them, not just the one that annoys you most. - Move each one to the argument list with a production default that reproduces today's behaviour exactly -- the
newand the env read now live in the default, so production is unchanged. When you are done the function under test constructs nothing and reads no global. - Write the test by passing fakes in as arguments. A fake is a stand-in you hand-write in the test and fully control: a literal like
() => 1_700_000_000_000, or a small object implementing only the methods the seam's narrow type names. Never pass the real collaborator through the seam -- not the production client, driver or service object, however cheap, local or in-memory its implementation happens to be, and whatever its own comments claim. A test built on the real collaborator still breaks when that collaborator's shape changes, which is the coupling the seam exists to cut. If the test needsvi.mock(),vi.stubEnv()or fake timers to run, a dependency is still hidden: go back to step 2 instead of reaching for them. - Remove any module mock of that dependency the existing tests carry -- the seam replaces it, and leaving both means the old test still cannot see what the mock hides.
When you hand the work back, name the seam t
Установить finding-seams в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл finding-seams?
Use when existing code has untestable dependencies that prevent writing tests -- direct construction of collaborators, static or global function calls, tight coupling to external systems, or singleton access patterns. Specifically for identifying substitution points (seams) that make legacy or tightly-coupled code testable without editing at the call site. Do NOT use for greenfield TDD (see tdd), general test writing patterns (see testing), or refactoring already-tested code (see refactoring).
Как установить скилл finding-seams?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл finding-seams запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic