coupling-cohesion

coupling-cohesion is a cursor rule for Cursor from YuDefine/nuxt-supabase-starter. It costs 0 tokens per session (3,324 once invoked), scanned A, original, MIT.

A code-structure guide based on keeping related behavior together and dependencies flowing in clear directions. It covers import cycles, oversized shared files, server boundaries, and repeated decision logic.

In plain words
What is it for?
It guides TypeScript architecture reviews, lint rules, coupling audits, and decisions about function responsibilities and third-party SDK boundaries.
Why use it?
It makes code easier to change and review by reducing tangled dependencies and changes that must be repeated across many files.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/. Also seen: mentions Codex.

Good fit It guides TypeScript architecture reviews, lint rules, coupling audits, and decisions about function responsibilities and third-party SDK boundaries.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/yudefine/nuxt-supabase-starter/coupling-cohesion
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.

Clone the repo
git clone --depth 1 https://github.com/YuDefine/nuxt-supabase-starter

Made for: Cursor.

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 coupling-cohesion

README.md
[![agentmods](https://agentmods.dev/badge/rules/yudefine/nuxt-supabase-starter/coupling-cohesion/github.svg)](https://agentmods.dev/rules/yudefine/nuxt-supabase-starter/coupling-cohesion)
Your own site
<a href="https://agentmods.dev/rules/yudefine/nuxt-supabase-starter/coupling-cohesion"><img src="https://agentmods.dev/badge/rules/yudefine/nuxt-supabase-starter/coupling-cohesion/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 coupling-cohesion

Your own site · 80×15
<a href="https://agentmods.dev/rules/yudefine/nuxt-supabase-starter/coupling-cohesion"><img src="https://agentmods.dev/badge/rules/yudefine/nuxt-supabase-starter/coupling-cohesion.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 3,324 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.00000 $0.03324
Opus 5 $0.00000 $0.01662
Sonnet 5 $0.00000 $0.00665
Haiku 4.5 $0.00000 $0.00332

Measured yesterday against content hash 32104a80392e, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

coupling-cohesion 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 yesterday.

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.

template/.cursor/rules/coupling-cohesion.mdc · 185 lines

How it starts

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

Coupling & Cohesion

SOLID 在 functional TS 語境的可測子集。這裡只收 S(內聚)、O(shotgun surgery)、D(依賴方向)—— L 與 I 在 composable-based 專案幾乎是空集合(沒有繼承層級就沒有 LSP 可違反;structural typing 下 ISP 自動成立大半),為它們寫 checklist 只會產出無法判定的條目。

三層分工

誰執行 管什麼
Gate vp lint(pre-commit vp-staged / CI) import/no-cycleoxc/no-barrel-file —— 機械可判定、無爭議
Signal node scripts/audit-coupling-cohesion.ts change coupling、跨檔 discriminant switch —— 報告不擋 commit
Review /code-review checklist 職責語意判斷 —— 機械測不到的部分

Signal 層的輸出 NEVER 當 gate 用:跨檔規則在 staged-only 情境算不準,把它接進 pre-commit 只會 產出「改一行擋十次」的體驗,然後大家學會加 disable comment。

Review 層 checklist

本節純 review 層,無機械訊號。消費端是 code-review agent 的程式碼品質 checklist。規模門檻 (max-params / max-lines / complexity)不在本節、也不在 gate——理由見下方 § 為什麼 gate 只有兩條規則。

與 § Shotgun surgery 的關係:本節管「一個函式做了幾件語意上不同的事」;Shotgun surgery 管 「同一個 discriminant 散落 ≥3 個檔」。兩層互補,不重複判準。

一個函式只做命令或只做查詢

一個函式 MUST 只做命令(改狀態)或只做查詢(回答案),NEVER 兩者兼具。

NEVER 讓 query / check 型函式藏副作用checkPassword NEVER 順手初始化 session。名字說得出來 的操作 MUST 是它做的全部。

NEVER 用 boolean flag 參數切換行為

createUser(data, isAdmin) 把「這個函式做兩件事」藏進 call site。MUST 拆成兩個具名函式 (createAdminUser / createMemberUser)。

這條管的是切換行為的 flag,不是「選項物件裡的 boolean 欄位」。{ dryRun: true } 這種不改 呼叫哪條路徑的選項,不是本條的對象。

函式內分段註解 = extract-method 警報

函式體內出現 // Validation / // Calculation / // Persist 這類分段標籤時,每個被標籤的區塊 MUST 抽成具名函式,讓上層函式讀起來是一份目錄而不是實作。區塊順序 MUST 讓呼叫端由上往下讀就能 跟上故事——先做什麼、再做什麼,不要先跳進細節。

參數順序有歧義時包成參數物件

fn(user, true, 3) 這種位置參數,caller 對不到第 2、第 3 個是什麼時,MUST 改成參數物件。 NEVER 把參數個數寫成 0–2 的硬門檻——§ 為什麼 gate 只有兩條規則 已用對照專案否決 max-params

Gate 判讀

import/no-cycle 炸了代表兩個模組互相依賴對方的具體實作。兩條標準拆法:

  • 抽共用 type / 常數到第三個模組,雙方都 import 它(最常見,cycle 多半由共享的 type 或 registry 常數造成)
  • 依賴反轉:把低層模組對高層的回呼改成參數注入,由高層在組裝時傳入

Read the full file on GitHub · 185 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. yesterday Changed · +1 lines 32104a80392e
  2. 5d ago First seen · 184 lines · 0 tokens per session scan A da4d58f8b5fd

Subscribe to this mod's changes

coupling-cohesion is a cursor rule published in the GitHub repository YuDefine/nuxt-supabase-starter (45 stars, last pushed today), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 3,324 tokens. 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-09-03.