Skip to main content
rule CX Codex

0-shared-modules — Claude Code rule: what it does, how to install

The 0-shared-modules rule sets a bar for moving code into shared/: callers must come from two application areas. Use it when reviewing modules under src/contexts/.

MIT ★ 571 updated 2026-10-29

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/rules/0-shared-modules.md
Open on GitHub

What 0-shared-modules does

Before creating shared/ or moving a module there, count the areas that call it with grep -rl <module> src. The earned-sharing.arch.test.ts test counts as a caller too. A single area means the module belongs closer to that code. runtime/wiring/ does not count as an application area.

Files nested inside a shared module are treated as its private steps. A promoted module follows 0-hexagonal.md; crossing a context boundary means declaring it public according to 0-contexts.md. Move code into kernel/ only after it stops being business logic. The rule targets src/contexts/**/*.ts, so check that this path matches your project layout.

What it helps with

  • check whether a module has callers in enough areas to move into shared/
  • keep a single-area module close to its caller
  • exclude runtime/wiring/ when counting application areas
  • identify when a module crossing contexts needs a public declaration
  • decide whether code still belongs to business logic before moving it into kernel/

Example prompts for the agent

  • Check whether this module can move into shared/ and count its caller areas.
  • Review src/contexts/ and tell me where a module with one caller should live.
  • Check this cross-context move and list the changes it requires.

How to install 0-shared-modules

Manually: put the files in place

.claude/rules/0-shared-modules.md

The paths frontmatter field limits the files

Step by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use

Questions about 0-shared-modules

How do I install 0-shared-modules in Claude Code?

Add the rule file at .claude/rules/0-shared-modules.md.

What does 0-shared-modules do?

It sets conditions for moving code into shared/: a module needs callers from two areas. It also covers context boundaries and moves into kernel/.

How does the rule define an application area?

An area is application/<subdirectory>/ or the application root. runtime/wiring/ is excluded.

Source text

0-shared-modules.md · MIT
---
description: Apply before creating or moving into a shared/ directory; sharing is earned by two calling areas.
paths:
  - "src/contexts/**/*.ts"
---

# Shared Modules

- `shared/` needs callers in two areas.
- One caller: move it down.
- Never share for a caller not yet written.
- An area is `application/<subdirectory>/` or the application root.
- `runtime/wiring/` is never an area.
- Count first: `grep -rl <module> src`; `earned-sharing.arch.test.ts` counts the same.
- A file nested under a shared module is its private step.
- A promoted module follows `0-hexagonal.md`.
- Crossing a context: declare the module public (`0-contexts.md`).
- Move to `kernel/` only once it stops being business logic.

© ai-driven-dev · MIT · ai-driven-dev/framework

Similar IDE rules

All IDE rules for Code review and refactoring →
principle-separate-before-serializing-shared-state backnotprop principle-separate-before-serializing-shared-state is a Claude Code skill for concurrent writes. It guides agents to separate files or keys per actor instead of serializing a shared state file. CX Codex +1 10,100installs update-avm-modules-in-bicep official github update-avm-modules-in-bicep updates Azure Verified Module versions in Bicep files and checks the result with lint and build. Useful when reviewing infrastructure changes. CX Codex +1 8,600installs converting-css-modules-to-tailwind spencerpauly converting-css-modules-to-tailwind moves one component off CSS Modules and onto Tailwind utility classes, then removes the module file and its import. CX Codex +1 430installs cmux-shared-behavior manaflow-ai cmux-shared-behavior is a Claude Code skill that sets one shared action path across cmux entrypoints and a single mutation path. It addresses bugs isolated to one surface. CX Codex +1 4,900installs nginx-c-modules pproenca nginx-c-modules — a skill that feeds your agent 49 rules for nginx C module work: pool memory, request lifecycle, config merging. Useful when you write or refactor a handler, filter or upstream. CX Codex +1 379installs vueuse-shared-skilld skilld-dev vueuse-shared-skilld — a skill that brings @vueuse/shared v15.0.0 API reference into Claude Code, Cursor, and other editors. Covers reactive utilities: debounce, throttle, watch variants, state sharing, and ref synchronization for Vue 3. CX Codex +1 137installs

From the same set80

The whole set →

Project sponsors

Companies that keep this analytics open