/thebous-os:architecture-first-developmentfrom thebous-os
Guides architecture-first implementation and refactoring: trace flows, parse-don't-validate, keep handlers thin, enforce LOC/complexity gates, and isolate effects with Result types.
Ships in thebous-os. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Treat architecture as a delivery constraint, not a cleanup phase. Trace the flow, make boundaries explicit, keep domain decisions cohesive, and isolate effects so changes stay understandable and testable. Use the project’s own language, framework, and test runner.
<=30 LOC and only parse, invoke, and serialize. Move decisions, I/O, and domain work behind the boundary.else blocks.Result<T, E> or a discriminated union. Define errors away with neutral/idempotent edge semantics: exact replays return stored outcomes, fingerprint mismatches conflict, and ambiguous provider calls become unknown-outcome for reconciliation, never blind retry.>200 LOC split gate. Split before implementation, or stop and report a blocker if a compliant split is impossible. Keep cognitive complexity at 15 or less, cyclomatic complexity at 10 or less, and routine arity at three or less.<=30 LOC and limited to parse, invoke, and serialize; they are not a second domain layer.>=2:1 without inventing methods to hit a ratio. Prefer composition over inheritance; inheritance depth is at most one.throw, empty catches, or generic catch-all masking.conflict; an ambiguous external charge returns unknown-outcome for reconciliation, never a blind retry. A process-local map or unscoped key is not a guarantee.Rationalizations
| Excuse | Reality |
|---|---|
| “It is only a one-file fix.” | Trace the flow; a small patch can deepen a bad boundary. |
| “The lead requires a one-file urgent minimal-diff hotfix.” | A one-file, urgent, legacy, minimal-diff, or authority instruction cannot waive the >200 LOC split gate: split before implementation or stop and report a blocker if a compliant split is impossible. |
| “Legacy or urgency makes this exempt.” | Name a bounded exception, risk, and follow-up; it is not a blanket waiver. |
| “A flaky test can become a smoke test.” | Stabilize or scope the check deliberately; never silently skip tests. |
| “Catch everything so the endpoint cannot fail.” | Map known errors at the boundary; masking hides defects and broken invariants. |
| “The metric tool is unavailable, so it passes.” | Record the inspection limitation; missing measurement is not compliance. |
| Concern | Gate |
|---|---|
| Boundary | Parse once; map external data; expose domain types inward. |
| Module | Deep/cohesive; 150 LOC preferred; split every file over 200 LOC. |
| Handler | <=30 LOC; parse, invoke, serialize only. |
| Control flow | Guard clauses; decision nesting ≤ 2; routine arity ≤ 3. |
| Complexity | Cognitive ≤ 15; cyclomatic ≤ 10, or record the limitation. |
| Effects | Functional core/imperative shell; ports/adapters; CQS. |
| Outcome | Result<T, E>/union for expected errors; exceptions only for infrastructure or invariants. |
| Idempotency | Durable atomic store; scoped key + fingerprint; replay, conflict, or reconciled unknown-outcome. |
| Finish | Tests, full checks, evidence, and Boy Scout cleanup. |
Save as example.ts and run it with the project’s TypeScript runner (for example, tsx example.ts). The injected port is a deterministic demo only; it provides no production once-only guarantee. A real adapter must use the durable contract above. Money is created only by its private smart constructor, and the demo fingerprint is normalized data, not a production hash.
type Result<T, E> = { ok: true; value: T } | { ok: false; error: E };
class Money {
private constructor(private readonly centsValue: number) {}
static parse(value: unknown): Result<Money, "invalid-money"> {
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0) return { ok: false, error: "invalid-money" };
return { ok: true, value: new Money(value) };
}
get cents(): number { return this.centsValue; }
add(amount: number): Result<Money, "overflow"> {
if (!Number.isSafeInteger(amount) || amount < 0 || this.centsValue > Number.MAX_SAFE_INTEGER - amount) return { ok: false, error: "overflow" };
return { ok: true, value: new Money(this.centsValue + amount) };
}
}
type Order = { userId: string; total: Money };
type Payment = { receipt: string };
type ChargeRequest = { scope: string; key: string; fingerprint: string; order: Order };
type ChargeError = "declined" | "conflict" | { kind: "unknown-outcome"; scope: string; key: string };
type Errors = "invalid-order" | "invalid-money" | "overflow" | ChargeError;
// A production adapter atomically stores (scope, key, fingerprint, outcome).
type Payments = {
chargeOnce: (request: ChargeRequest) => Promise<Result<Payment, ChargeError>>;
reconcile: (scope: string, key: string) => Promise<Result<Payment, "not-found">>;
};
function parseOrder(input: unknown): Result<Order, "invalid-order" | "invalid-money"> {
if (typeof input !== "object" || input === null) return { ok: false, error: "invalid-order" };
const raw = input as Record<string, unknown>;
const userId = raw.userId;
if (typeof userId !== "string" || userId.length === 0) return { ok: false, error: "invalid-order" };
const total = Money.parse(raw.amountCents);
if (!total.ok) return { ok: false, error: total.error };
return { ok: true, value: { userId, total: total.value } };
}
const FEE_CENTS = 25;
const price = (order: Order): Result<Order, "overflow"> => {
const total = order.total.add(FEE_CENTS);
if (!total.ok) return { ok: false, error: total.error };
return { ok: true, value: { ...order, total: total.value } };
};
async function submit(input: unknown, key: string, payments: Payments): Promise<Result<Payment, Errors>> {
const parsed = parseOrder(input);
if (!parsed.ok) return { ok: false, error: parsed.error };
const priced = price(parsed.value);
if (!priced.ok) return { ok: false, error: priced.error };
return payments.chargeOnce({
scope: `user:${priced.value.userId}`,
key,
fingerprint: JSON.stringify({ userId: priced.value.userId, cents: priced.value.total.cents }),
order: priced.value,
});
}
const payments: Payments = {
chargeOnce: async ({ order }) => ({ ok: true, value: { receipt: `paid:${order.total.cents}` } }),
reconcile: async () => ({ ok: false, error: "not-found" }),
};
async function main(): Promise<void> {
const input = { userId: "u1", amountCents: 420 };
console.log(await submit(input, "request-1", payments));
}
void main();
Expected output: { ok: true, value: { receipt: 'paid:445' } }. Only the durable adapter can provide once-only replay guarantees.
500 or success for every caught error → map known errors and preserve unrecoverable failures.Stop and revisit the workflow when you hear: “I will make the smallest diff and skip the architecture check”; “the lead/authority requires a one-file urgent minimal-diff hotfix, so a >200 LOC file may stay intact”; “legacy, urgency, or sunk cost makes this an exception automatically”; “the flaky test can be skipped for a manual smoke test”; “a catch-all handler is safer than explicit errors”; “four parameters are fine for this one routine”; “we should share this helper just in case”; or “the tool is missing, so the complexity gate passes.”
Name the boundary, contract, error semantics, evidence, and follow-up. A >200 LOC file must be split before implementation; if scope makes a compliant split impossible, stop and report a blocker.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
13 skills in this plugin
/address-reviewAssess code review comments against code evidence, fix confirmed issues on your PR after user approval, reply to every comment on GitHub, and update documentation for a linked Jira or Notion task/create-jira-taskCreate a Jira task from a user request using the repository's fixed description format with the sections "Descrizione" and "Acceptance Criteria". Use when the user asks to create, open, or draft a new Jira task./create-prUse when the user asks to create or open a pull request, or to merge a branch, after development is completenpx claudepluginhub thebous/thebous-os --plugin thebous-osOther plugins' skills for the same job