agentleFS
auralshinauralshin/coding-skills/skills/connascence/SKILL.md

connascence

Skill0 starsChanged 3 months agoMITView on GitHub

This skill should be used when the user asks "why is this so tightly coupled", "how do I decouple these", "is this coupling acceptable across a module boundary", or when reviewing positional arguments, magic values, required call ordering, shared mutable state, or duplicated algorithms. Provides a taxonomy that names and ranks kinds of coupling precisely.

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Algorithm to Name: When a client and a server each implement the same signing scheme, one change breaks the other at runtime.

    line 77
  2. Distinctive:

    No linter computes a connascence score, and attempts to build one are not worth the effort.

    line 110
  3. Very specific:

    Use cyclomatic-complexity to judge whether a function is hard to test.

    line 112

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Connascence

Two pieces of code are connascent when changing one forces a change to the other to keep the program correct. Named by Meilir Page-Jones, 1992.

"Coupling" is a binary word, which makes it useless in review since everything is coupled to something. Connascence supplies a taxonomy and a ranking, converting "this feels tightly coupled" into "this is connascence of position across a package boundary", which names the fix.

Three axes

Judge every instance on all three:

  • Strength: how hard it is to refactor. See the ladder below.
  • Degree: how many places are involved.
  • Locality: how far apart they sit. Same function, same class, same module, same repo, different service.

The rule that ties them together:

The further apart two things are, the weaker their connascence must be.

Strong connascence inside one small function is ordinary code. The same connascence spanning two services is an incident waiting to happen.

The ladder

Static forms, visible by reading the code:

#FormBoth sides must agree onFix
1Namea nameUnavoidable and fine
2Typea typeFine, this is what type systems do
3Meaningwhat a value means (0 = success, -1 = missing)Named constants, enums, sum types
4Positionorder (positional args, tuple returns, CSV columns)Named parameters, objects
5Algorithmthat both compute identically (checksums, hashing, cursors)One shared implementation

Dynamic forms, visible only at runtime and considerably worse:

#FormBoth sides must agree onFix
6Execution orderthat a() runs before b()Make the order impossible to get wrong
7Timingthat something happens within a windowLocks, barriers, explicit waits
8Valuesthat several values change togetherOne object, or one transaction
9Identitythat two references point at the same instancePass the reference explicitly

Dynamic connascence is worse because the compiler cannot see it, grep cannot find it, and violations surface as production bugs rather than build failures.

Three rules for applying it

Jim Weirich's formulation:

  1. Minimize overall connascence by splitting the system into encapsulated units.
  2. Minimize connascence that crosses encapsulation boundaries.
  3. Maximize connascence within an encapsulation boundary.

Rule 3 is the one most often missed. Concentrating strong connascence inside one module is the goal, not a failure. That is what encapsulation is for.

Refactoring down the ladder

Each fix converts a stronger form into a weaker one.

Meaning to Name

def find(xs, target): ...              # returns index or -1: every caller must know
def find(xs, target) -> int | None: ...  # the type says it

Position to Name

create_user("ada", "lovelace", True, False, True)
create_user(first="ada", last="lovelace", admin=True, suspended=False, verified=True)

Algorithm to Name. When a client and a server each implement the same signing scheme, one change breaks the other at runtime. Publish a single shared implementation, or move the operation behind an endpoint.

Execution order to nothing

const c = new Client(); c.connect(); c.send(msg);   // order matters
const c = await Client.connect(); c.send(msg);      // order is now impossible to get wrong

Timing to Name

await sleep(200);                    // flaky, and slow when it passes
await waitFor(() => q.isEmpty());    // explicit condition

Applying it in review

Replace a vague objection with this template:

This is connascence of <form>, degree <n>, across <boundary>. Weaken it to <form> by <fix>.

Flag these specifically:

  • A magic number or string appearing in more than one file: meaning, high degree
  • Four or more positional parameters, or a tuple return read by many callers: position
  • Two services that must deploy together: strong connascence across the strongest boundary present, fix this first
  • "Call init() first" in a docstring: execution order
  • sleep() in a test: timing
  • Two rows that must update together outside a transaction: values

Limits

No linter computes a connascence score, and attempts to build one are not worth the effort. This is a review and design vocabulary. Its value is making coupling arguments concrete enough to settle quickly.

Use cyclomatic-complexity to judge whether a function is hard to test. Use connascence to judge why a change is hard to make.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.