swift-hexagonal-spm
Skill8 starsChanged 6 days agoApache-2.0View on GitHub
Hexagonal Swift 6 SPM module law for rv. Use when editing Package.swift, adding a module or test target, adding product or executableTarget rv/rvd, ArgumentParser, main.swift / @main in a library, @_exported, or a T2∥T3 Package.swift merge. Also /swift-hexagonal-spm.
In this repository18 other files it gives its agents.
- codebase-designSkill
- principle-type-system-disciplineSkill
- swift-64-concurrencySkill
- swift-adversarial-pr-reviewSkill
- swift-api-design-guidelinesSkill
- swift-concurrencySkill
- swift-evaluate-paritySkill
- swift-functional-architectureSkill
- swift-functional-coreSkill
- swift-hook-xpcSkill
- swift-pr-orchestrationSkill
- swift-protocol-boundariesSkill
- swift-pr-reviewSkill
- swift-systems-safetySkill
- swift-testing-proSkill
- swift-thermo-nuclear-reviewSkill
- swift-type-system-architectureSkill
- swift-value-semanticsSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 2 are distinctive, and 6 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.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 30
Do not invent a module. Do not restyle the graph from memory.
- Very specific: line 42
If that wrapper fails (missing toolchain), stop and say so.
- Very specific: line 45
Do not wipe .build or run swift package clean to prove a compile.
- Very specific: line 58
Read that row in MODULES.md (Owns / Must not) and its Dependency graph table.
- Very specific: line 62
Put the proof in the matching Tests/<Module>Tests target.
- Very specific: line 64
Run tools/gate.sh for the touched target(s).
- Very specific: line 75
Do not add @_exported import.
- Distinctive: line 81
Do not add more. Do not delete it in a ticket that does not own those files.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 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
swift-hexagonal-spm
Internal. Module law for this package. Not a public-API sculptor.
Law lives in AGENTS.md, docs/architecture/MODULES.md, docs/dev/SWIFT.md.
This skill is the preflight those files do not run. Ticket ownership of
Package.swift is in references/package-ownership.md.
Evaluate contract → swift-evaluate-parity. Hook / XPC / hostDenyText →
swift-hook-xpc.
Load first
AGENTS.mddocs/architecture/MODULES.mddocs/dev/SWIFT.mdPackage.swiftas it is now
Do not invent a module. Do not restyle the graph from memory.
Toolchain
Pin is .swift-version (6.3.3). Language mode 6. Platforms: macOS 26 Apple Silicon, Linux aarch64/x86_64.
/usr/bin/swift on this machine may be Xcode 6.2. Before any compile claim:
tools/swift-6.3.3 --version # expect Apple Swift version 6.3.3If that wrapper fails (missing toolchain), stop and say so. Do not use
swiftly run 6.3.3 unless you have just proven that binary.
Do not wipe .build or run swift package clean to prove a compile. Clean
swift build ~12s is Foundation overlay rebuild in .build/.../ModuleCache
(6.3.3 has no prebuilt SDK modules), not rv type-check. Incremental Engine
edits are <1s. Numbers: docs/dev/SWIFT.md.
Gate: tools/gate.sh <Target>Tests for the module you touched (preflight +
filtered test via tools/swift-6.3.3), against a warm .build.
RVCorpusTests is the only multi-module test target (Domain + Engine + Packs).
Steps
- Name the module that owns the change. If two modules would both need the
type, it belongs in the lower one (
RVDomainor the existing protocol). - Read that row in
MODULES.md(Owns / Must not) and its Dependency graph table. A new import that is not on that row is a graph edit — stop and write a merge plan, or load the package-ownership reference. - Implement with
AGENTS.md+SWIFT.md. Do not restyle from this file. - Put the proof in the matching
Tests/<Module>Teststarget. The only exception isRVCorpusTests. - Run
tools/gate.shfor the touched target(s).
Graph and tests
The graph is the Dependency graph table in MODULES.md. Do not implement from
a remembered ban-list.
A test that needs a TTY to prove a decision is in the wrong module.
Decisions are proven in RVEngineTests / RVCorpusTests. TTY tests prove
pretty / browse / allow-once entry, not allow vs deny.
Do not add @_exported import. Callers that need Decision import RVDomain.
*Tests list only their module in Package.swift. Importing RVDomain from
an Engine test source file is not a graph edit. Only RVCorpusTests may
list more than one module.
Existing @_exported import RVDomain in RVEngine / RVPacks is T1 debt.
Do not add more. Do not delete it in a ticket that does not own those files.
Anti-patterns
| If you are about to | Do this instead |
Add class in Domain/Engine/Packs/Presentation | struct / enum / actor (stores). class declarations only at RVService / XPC NSObject. |
Put main.swift or @main in RVCLI / RVService | Separate executableTarget (Sources/rv, Sources/rvd). See package-ownership. |
Import RVPacks from RVEngine | Pass [PackSnapshot] + CompiledPacks in |
| Prove deny in a TUI/CLI test | Assert evaluate in Engine/Corpus |
Give *Tests a second Package.swift dependency | Only RVCorpusTests may list three |
Add ArgumentParser and rvd in one ticket | package-ownership.md |
Use PackID(rawValue:)! | Non-failable init(rawValue:) |
Revert product rv to restore “no executables” | That snapshot is pre-T2. Do not delete a legal rv. |
Preflight (run on the diff before claiming done)
Run tools/gate.sh for the touched target(s). It runs tools/preflight.sh
then filtered tests on 6.3.3. Then re-read the remaining list for anything the
script can't catch (semantic judgments).
Re-read this list against the staged/unstaged Swift + Package.swift diff:
- Every new import is on the
MODULES.mdgraph for that target. - No
classdeclarations outsideRVService/ XPCNSObject. - No
isDenied, notry!, no IUO on production paths. - No new
@_exported import. Noimport XCTest. Noimport RVPacksin Engine. - Decision tests do not open a TTY.
- No
main.swift/@maininside a library target (RVCLI,RVService, …). Package.swiftexecutable / ArgumentParser edits match one ticket’s ownership row — or a written merge plan exists.tools/swift-6.3.3 --versionis 6.3.3 andtools/gate.shfor the touched target is green.
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.

