skills/mim-architecture/SKILL.md
Define module boundaries, structure infrastructure layers, implement dependency inversion, and create sociable unit tests using MIM (Module-Infrastructure-Module) architecture and modular design principles. Use this skill when the user mentions "MIM", "Module-Infrastructure-Module", "Screaming Architecture", or asks for advice on modular design, high cohesion, low coupling, or sociable unit testing.
npx skillsauth add jpc0/skills mim-architectureInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
MIM organizes code around business processes rather than technical layers, splitting logic into Business and Infrastructure modules.
For complex logic, a module is split into two parts:
IRepository, IExternalService).MIM favors Sociable Unit Tests over solitary tests with heavy mocking.
InMemoryRepository) instead of mocking frameworks. Fakes are more reliable, easier to maintain, and lead to less brittle tests.jest.fn().mockRejectedValue(). Instead, add a shouldFail flag or a specific error response to your fake class.class FakeIoTGateway implements IIoTGateway {
public shouldFail = false;
async send(version: string, deviceId: string) {
if (this.shouldFail) throw new Error("Connection failed");
// ... success logic
}
}
test("should handle gateway failure", async () => {
const gateway = new FakeIoTGateway();
gateway.shouldFail = true; // Configure fake to fail
const service = new FirmwareDispatcher(new FakeFirmwareRepo(), gateway);
await expect(service.dispatch("v1", "d1")).rejects.toThrow("Connection failed");
});
FirmwareDispatcher).dependency-cruiser or manual inspection of import statements to confirm the unidirectional dependency.// FirmwareDispatcher/BM/FirmwareDispatcher.spec.ts
import { FirmwareDispatcher } from "./FirmwareDispatcher";
import { FakeFirmwareRepo } from "./fakes/FakeFirmwareRepo";
import { FakeIoTGateway } from "./fakes/FakeIoTGateway";
test("should dispatch firmware update correctly", async () => {
const repo = new FakeFirmwareRepo();
const gateway = new FakeIoTGateway();
const service = new FirmwareDispatcher(repo, gateway);
await service.dispatch("v1.2.3", "device-456");
const dispatched = await gateway.getDispatchedForDevice("device-456");
expect(dispatched).toBe("v1.2.3");
});
// BM (Business-Module)
export interface IAlarms {
raise(details: AlarmDetails): Promise<void>;
}
// IM (Infrastructure-Module)
export class PagerDutyAlarms implements IAlarms {
async raise(details: AlarmDetails) {
// Technical implementation for PagerDuty...
}
}
development
Apply formal verification methods (Hoare Logic, wp calculus, Design-by-Contract) to ensure software correctness. Use this skill whenever writing new functions, implementing algorithms, modifying existing logic, or performing code reviews. Trigger when asked to "prove correctness", "verify code", "check invariants", "mathematical proof of code", or "ensure the algorithm is correct".
development
Use this skill to refactor, design, or review application architecture. Trigger it when discussing clean architecture, separating business logic from UI, or cross-platform/WASM development. This skill enforces the 'Headless Core & Passive View' pattern, it proactively refactors logic out of the UI, creates platform-agnostic Core interfaces, and ensures the View is a 'Humble Object' that only reflects state.
testing
Create, edit, improve, or audit AgentSkills. Use when creating a new skill from scratch or when asked to improve, review, audit, tidy up, or clean up an existing skill or SKILL.md file. Also use when editing or restructuring a skill directory (moving files to references/ or scripts/, removing stale content, validating against the AgentSkills spec). Triggers on phrases like "create a skill", "author a skill", "tidy up a skill", "improve this skill", "review the skill", "clean up the skill", "audit the skill".
testing
Host security hardening and risk-tolerance configuration for OpenClaw deployments. Use when a user asks for security audits, firewall/SSH/update hardening, risk posture, exposure review, OpenClaw cron scheduling for periodic checks, or version status checks on a machine running OpenClaw (laptop, workstation, Pi, VPS).