Logo di Finding Seams

Finding Seams

Community
citypaul
finding-seams

Usalo quando il codice esistente ha dipendenze non sostituibili che impediscono di scrivere test: costruzione diretta di collaboratori, chiamate a funzioni statiche o globali, forte accoppiamento con sistemi esterni o accesso tramite singleton. Serve nello specifico a individuare punti di sostituzione (seam) che rendano testabile codice legacy o fortemente accoppiato senza modificare il punto di chiamata. NON usarlo per TDD in un progetto nuovo (vedi tdd), per pattern generali di scrittura dei test (vedi testing) o per rifattorizzare codice già testato (vedi refactoring).

Add to TypingMind

Panoramica

Pubblicato dacitypaul
Repository.dotfiles
Nome della skillfinding-seams
Stelle
740
Fork
96
File inclusi
3
Link
  • Istruzioni in Markdown

    Un file SKILL.md che il modello carica quando serve, consumando token solo quando una richiesta è effettivamente pertinente.

  • Funziona con qualsiasi LLM

    Le skill IA sono in semplice Markdown, non in codice specifico di un fornitore, quindi funzionano con GPT, Claude, Gemini, Grok o un modello locale.

  • File inclusi: 3

    Script, template e riferimenti che il modello può leggere mentre lavora. I file sono di sola lettura e non vengono mai eseguiti.

  • Open source

    Pubblicata da citypaul su GitHub. Leggi i sorgenti prima di installarla.

Installazione

Installa la skill IA Finding Seams in TypingMind per usarla con qualsiasi LLM, oppure copiala in un altro agente in grado di leggere SKILL.md.

1

Installa in TypingMind

TypingMind installa una skill direttamente dalla sua cartella GitHub: legge SKILL.md, raccoglie i file delle risorse e salva il risultato in locale.

  1. Apri l'app e vai su Plugin → Skill.
  2. Scegli "Installa da GitHub".
  3. Incolla l'URL della cartella della skill riportato qui sotto e conferma.
    https://github.com/citypaul/.dotfiles/tree/main/claude/.claude/skills/finding-seams
  4. Attiva la skill in ogni chat in cui vuoi averla a disposizione.
Plugin → Skill → Aggiungi skill → Da URL GitHub, poi incolla l'URL della cartella e premi Continua.
2

Installa in un altro agente

Qualsiasi agente che legge il formato Agent Skills può usare questa skill: copia la cartella della skill nella directory delle skill di quell'agente.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/citypaul/.dotfiles.git /tmp/.dotfiles
mkdir -p .claude/skills
cp -r /tmp/.dotfiles/claude/.claude/skills/finding-seams .claude/skills/finding-seams
Dopo la copia, riavvia Claude Code per caricare la nuova skill.

Usala in TypingMind

Attiva Finding Seams in qualsiasi chat di TypingMind e al resto pensa il modello. Il nome e la descrizione della skill sono nel prompt di sistema e, non appena arriva una richiesta pertinente, il modello carica da solo le istruzioni complete: non devi mai richiamarla manualmente e non consuma token finché non viene effettivamente usata.

Il modello carica automaticamente Finding Seams non appena riceve una richiesta pertinente.

Funziona con qualsiasi modello IA

Le skill IA sono semplici istruzioni in Markdown, non codice specifico di un fornitore, quindi Finding Seams non è vincolata al modello per cui è stata scritta. Installala una sola volta in TypingMind e usala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modello locale che esegui tu, sempre con le tue chiavi API.

  • Caricata solo quando serve

    Il prompt di sistema contiene solo il nome e la descrizione. Le istruzioni vengono recuperate alla prima richiesta pertinente, quindi una skill inutilizzata non costa nulla.

  • Cambia modello durante la chat

    Poiché la skill è composta da istruzioni e non da codice, continua a funzionare anche se cambi modello: il nuovo modello legge lo stesso file SKILL.md.

Istruzioni della skill

Questo è il contenuto di SKILL.md che il modello carica. Leggilo prima dell'installazione: una skill è un insieme di istruzioni che il tuo modello seguirà.

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:

ResourceLoad when...
seam-types.mdNeed detailed FP-first examples of each seam type in TypeScript
creating-seams.mdNeed to introduce a seam where none exists, with before/after examples
oop-patterns.mdEncountering 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 TypeMechanismEnabling PointPrefer When
Function ParameterPass dependency as argumentThe argument listDefault choice. Functional code, pure functions, explicit contracts
ConfigurationReceive config/env values as argumentsThe argument list of the function that receives themInfrastructure-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
Modulevi.mock() / jest.mock() replaces importsTest file mock configurationLast 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
ObjectSubclass and override, or DI via constructorWhere the object is createdLegacy class-based code (see resources/oop-patterns.md)

Putting Existing Code Under Test

Work through this before writing a single test:

  1. 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.
  2. Move each one to the argument list with a production default that reproduces today's behaviour exactly -- the new and 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.
  3. 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 needs vi.mock(), vi.stubEnv() or fake timers to run, a dependency is still hidden: go back to step 2 instead of reaching for them.
  4. 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 type you introduced and where its enabling point is (file and line of the parameter default, the ?? fallback, or the factory call), and confirm the existing call sites are unchanged.

How to Find Seams

Look for these in the code you need to test:

  1. Function parameters -- any parameter that could accept a different implementation
  2. Default parameter values -- (resolve = fetchFromApi) is already a seam
  3. Module imports -- anything imported can potentially be mocked (but prefer parameter injection)
  4. Configuration -- env vars, config files, feature flags
  5. React props and context -- components receive dependencies as props; context providers can be swapped in tests
  6. Hard-coded new or direct calls -- every direct dependency is a place where a seam could exist but doesn't yet

The Progression

Ordered from preferred to last-resort. Start with the most explicit option that works:

  1. Function parameter injection -- pass dependencies as arguments with production defaults (explicit, type-safe, no framework needed)
  2. Higher-order functions -- return a configured function from a factory (FP composition)
  3. Configuration injection -- pass config/env as parameter instead of reading globally
  4. Module mocking -- vi.mock() to replace imports (scaffolding only -- migrate away as you gain coverage)
  5. Subclass and override -- for legacy class-based code only (see resources/oop-patterns.md)

Steps 1-3 are candidates for a durable design only when the lasting contract earns them. Otherwise keep them private or remove them after characterisation. Steps 4-5 are normally temporary scaffolding.

Quick Example

Before you can characterise scheduleDelivery, you need a seam for its hidden dependency:

typescript
// BEFORE -- no seam, can't test without hitting real API
const scheduleDelivery = (delivery: Delivery): DeliveryPlan => {
  const transitDays = fetchTransitDays(delivery.region);
  return { ...delivery, totalDays: delivery.preparationDays + transitDays };
};

// AFTER -- function parameter seam with production default
type TransitDaysResolver = (region: string) => number;

const scheduleDelivery = (
  delivery: Delivery,
  resolveTransitDays: TransitDaysResolver = fetchTransitDays,
): DeliveryPlan => {
  const transitDays = resolveTransitDays(delivery.region);
  return { ...delivery, totalDays: delivery.preparationDays + transitDays };
};

// Test -- swap in a fake at the enabling point (the argument list)
const result = scheduleDelivery(testDelivery, () => 2);

Production code is unchanged at every call site (the default kicks in). Tests pass a fake. The seam is the parameter; the enabling point is the argument list.

Code Smell → Technique

You see this in the codeTechniqueExample
new Foo() inside a functionParameterize functionPass the dependency as a parameter with a default
process.env.X read directlyWrap global call(getEnv = () => process.env.X)
import { thing } from './heavy-lib' used directlyExtract type + parameterizeDefine a narrow type, pass as parameter
Multiple hard-coded deps in one functionHigher-order function factorycreateFn(deps) => (args) => result
SingletonClass.getInstance()Wrap global call(getSingleton = () => SingletonClass.getInstance())
Date.now() / Math.random()Wrap global call(now = Date.now) as parameter
Class constructs its own collaboratorsParameterize constructor (OOP)Accept via constructor, see oop-patterns.md
Can't change function signature yetModule indirection (scaffolding)Thin wrapper module + vi.mock(), migrate later

Common Mistakes

MistakeFix
Using vi.mock() as permanent architectureModule mocks bypass type safety and create implicit coupling. Migrate to parameter injection as soon as you have tests.
Leading with class-based patterns (subclass, DI containers)In TypeScript FP, function parameters provide natural seams. Classes and DI containers are rarely needed.
Mocking everything instead of finding real seamsMock only at the seam boundary; test real logic
Creating seams that leak implementation detailsSeam interfaces should describe what, not how
Forgetting the enabling pointEvery seam needs a place to choose behavior; if there's no enabling point, it's not a seam
Breaking too many dependencies at onceBreak one dependency at a time; get a test passing; then break the next

File inclusi

Il modello legge questi file quando servono, mentre la skill è caricata. Sono accessibili in sola lettura e non vengono mai eseguiti.

Domande frequenti

Cosa fa la skill IA Finding Seams?

Usalo quando il codice esistente ha dipendenze non sostituibili che impediscono di scrivere test: costruzione diretta di collaboratori, chiamate a funzioni statiche o globali, forte accoppiamento con sistemi esterni o accesso tramite singleton. Serve nello specifico a individuare punti di sostituzione (seam) che rendano testabile codice legacy o fortemente accoppiato senza modificare il punto di chiamata. NON usarlo per TDD in un progetto nuovo (vedi tdd), per pattern generali di scrittura dei test (vedi testing) o per rifattorizzare codice già testato (vedi refactoring).

Perché usare Finding Seams su TypingMind?

Perché la installi una volta e la usi con qualsiasi modello. Finding Seams è scritta in semplice Markdown anziché in codice specifico di un fornitore, quindi la stessa skill funziona con GPT-5, Claude, Gemini, Grok o un modello locale, e puoi cambiare modello durante la chat senza che la skill smetta di funzionare. TypingMind usa le tue chiavi API, quindi paghi direttamente i fornitori anziché un abbonamento per posto utente, e le tue skill e chat restano nel tuo spazio di archiviazione.

Come installo Finding Seams in TypingMind?

Apri Plugin → Skill → Installa da GitHub in TypingMind e incolla https://github.com/citypaul/.dotfiles/tree/main/claude/.claude/skills/finding-seams. TypingMind legge il file SKILL.md, include i file associati e installa la skill, che puoi abilitare per ogni singola chat.

Quali modelli IA possono usare Finding Seams?

Qualsiasi modello che colleghi a TypingMind. Le skill IA sono semplici istruzioni in Markdown anziché codice specifico di un fornitore, quindi GPT, Claude, Gemini, Grok e i modelli locali possono tutti caricare questa skill quando una richiesta corrisponde al suo scopo.

Quanti modelli IA posso usare con Finding Seams?

Quanti ne vuoi. Se un modello supporta le skill, puoi usarlo con Finding Seams: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e molti altri, tutti su TypingMind con le tue chiavi API.

La skill IA Finding Seams è gratuita?

È pubblicata su GitHub da citypaul. Consulta il repository per i termini di licenza. Paghi solo il tuo fornitore IA per i token che usi.

Cosa sono le skill IA?

Una skill IA è un pacchetto di istruzioni riutilizzabili che insegna a un modello IA come svolgere un'attività specifica. Segue il formato aperto Agent Skills: un file SKILL.md con un nome e una descrizione, più eventuali script, template o file di riferimento di cui il modello potrebbe aver bisogno. Il modello legge le istruzioni solo quando la tua richiesta corrisponde alla skill, quindi una skill installata non comporta costi finché non viene usata.

In cosa si differenziano le skill IA dai plugin o dai server MCP?

Un plugin o un server MCP fornisce a un modello nuovi strumenti da richiamare: codice che viene eseguito da qualche parte e restituisce un risultato. Una skill IA, invece, fornisce al modello conoscenze e procedure: come affrontare un'attività, quali passaggi seguire e quali caratteristiche deve avere un buon output. Le skill sono semplici istruzioni in Markdown, quindi non richiedono server, chiavi API né ambienti di esecuzione e funzionano con qualsiasi modello.

Elenco completo

Crea subito il tuo spazio di lavoro AI

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇