package-architecture
Skill0 starsChanged 48 days agoApache-2.0View on GitHub
Add or restructure workspace packages, wire the TypeScript project graph and keep the dependency DAG acyclic with the runtime free of concrete provider adapters.
In this repository11 other files it gives its agents.
- AGENTS.mdAGENTS.md
- changesets-releaseSkill
- local-ci-paritySkill
- npm-releaseSkill
- package-artifact-validationSkill
- pnpm-supply-chainSkill
- provider-adapter-developmentSkill
- public-api-evolutionSkill
- runtime-contract-evolutionSkill
- runtime-lifecycle-coordinationSkill
- workspace-lifecycleSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 2 are distinctive, and 0 are 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.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 13
Use this skill when a change touches any of:
- Distinctive: line 23
Do not use this skill when:
≈ “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.
Files
Package architecture
Trigger
Use this skill when a change touches any of:
- adding, removing, renaming or merging a package under
packages/ - a
dependencies/devDependenciesedge between workspace packages tsconfig.base.json,tsconfig.build.jsonor a packagetsconfig.jsonpnpm-workspace.yamlpackage globstools/repo/check-dag.ts
Counter-trigger
Do not use this skill when:
- you are adding a third-party dependency — use
pnpm-supply-chain - you are changing what a package exports — use
public-api-evolution - you are changing the built output or
exportsmap mechanics — usepackage-artifact-validation
Owns
tools/repo/check-dag.ts— mechanical layering gatetools/repo/check-static.ts— foundation scope and no-live-adapter boundarytsconfig.base.json— shared compiler optionstsconfig.json— the workspace typecheck project and itspathsmappnpm-workspace.yaml#packages— workspace globsdocs/adr/ADR-0010-package-dag-and-layering.md— the layering decision record
Does not own
packages/*/package.json#exports— owned bypackage-artifact-validationpnpm-workspace.yaml#catalog— owned bypnpm-supply-chainpackages/protocol/src— owned byruntime-contract-evolutionpackages/provider/src— owned byprovider-adapter-developmentpackages/workspace/src— owned byworkspace-lifecyclepackages/runtime/src— owned byruntime-lifecycle-coordination
Relationships
boundary-with→pnpm-supply-chain— this skill governs workspace edges; that skill governs third-party edges. Both writepackage.json; neither writes the other's dependency class.boundary-with→package-artifact-validation— this skill decides that a package exists and what it may depend on; that skill decides how it is built and packed.boundary-with→provider-adapter-development— that skill owns the SPI contract; this skill owns which packages may import it.boundary-with→runtime-lifecycle-coordination— this skill owns dependency direction; that skill owns runtime behavior inside the package.delegates-to→public-api-evolution— a new package entry point is a public surface.
Procedure
Place the package in the declared layer. The only legal edges are:
L0 agent-protocol (no workspace deps) L1 agent-executor → protocol agent-provider → protocol agent-workspace → protocol L2 agent-provider-codex → protocol, provider agent-provider-claude → protocol, provider agent-workspace-git → protocol, workspace L3 agent-runtime → protocol, executor, provider, workspaceagent-runtimemust never depend on a concrete provider adapter. Concrete adapters depend onprotocol+provider; composition happens in the consumer's application, or throughregisterProvider()at runtime.- Declare every cross-package import. An import of
@relvo-labs/agent-xrequires a"@relvo-labs/agent-x": "workspace:^"entry in that package'sdependencies. AdevDependencyedge is allowed only for test-only imports and is checked separately. - Never deep-import.
import { X } from '@relvo-labs/agent-protocol'— not.../dist/foo.js, not.../src/foo.ts.check-dag.tsrejects any specifier with more path segments than a declared subpath export. Register the package in three resolvers, or it will half-work. There are no TypeScript project references here — typecheck resolves workspace packages to source through a
pathsmap, so a check never depends on build ordering. Add the new package to all three:tsconfig.json→compilerOptions.pathsvitest.config.ts→resolve.aliastools/repo/check-dag.ts→ theLAYERStable
Miss the first and the typecheck falls back to a stale
dist. Miss the third and the package is exempt from layering enforcement — the failure mode that matters most.- New package checklist (all required before commit):
packages/<name>/package.jsonwith"type": "module",exports,files,engines,publishConfig.access,sideEffects: falsepackages/<name>/tsdown.config.ts- at least one real test under
packages/<name>/test/ - the three resolver registrations from step 4
- a
README.mdstating the package's single responsibility
- Run the gate before assuming the graph is right. Cycles frequently appear only after a test-only import is added.
Verification
pnpm dag:check # layering, cycles, undeclared edges, deep imports
pnpm typecheck # whole-workspace tsc pass over source
pnpm build
pnpm gatepnpm dag:check prints the resolved graph on failure. A cycle is never resolved by
adding an import type — extract the shared type into agent-protocol instead.
Provenance
- Source: independent — authored for this repository against the pnpm workspace documentation and the TypeScript "Project References" handbook chapter.
- Incorporated:
module-federation/core@5727cf3298ca9b3d04306a4a6065265a131965b7(MIT) — the layered-boundary check framing (explicit layer table + mechanical enforcement rather than review convention) was adapted from its internal package-boundary guidance.
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
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.

