@mrciphersmith/keryx 0.4.28 → 0.4.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/cli.js +2710 -2488
  2. package/dist/core.js +5 -5
  3. package/dist/keryx-general-worker-entry.js +335 -219
  4. package/package.json +1 -1
  5. package/src/gdskills/bundled/install-manifest.json +1 -0
  6. package/src/gdskills/bundled/rules/core/clean-architecture.mdc +25 -153
  7. package/src/gdskills/bundled/rules/core/code-style-patterns.mdc +1 -0
  8. package/src/gdskills/bundled/rules/core/error-handling.mdc +57 -108
  9. package/src/gdskills/bundled/rules/core/skill-authoring.mdc +190 -0
  10. package/src/gdskills/bundled/rules/core/skills-storage-workflow.mdc +5 -0
  11. package/src/gdskills/bundled/rules/core/solid-principles.mdc +48 -123
  12. package/src/gdskills/bundled/skills/orchestration/task-implementer/SKILL.md +2 -2
  13. package/src/gdskills/bundled/skills/quality/tests-creator/SKILL.md +1 -1
  14. package/src/gdskills/bundled/skills/review/review-architecture/SKILL.md +1 -1
  15. package/src/gdskills/bundled/skills/review/review-backend/SKILL.md +3 -5
  16. package/src/gdskills/bundled/skills/review/review-clean-code/SKILL.md +100 -421
  17. package/src/gdskills/bundled/skills/review/review-core-boundaries/SKILL.md +2 -2
  18. package/src/gdskills/bundled/skills/review/review-degradation/SKILL.md +1 -1
  19. package/src/gdskills/bundled/skills/review/review-flow-graph/SKILL.md +1 -1
  20. package/src/gdskills/bundled/skills/review/review-frontend/SKILL.md +4 -5
  21. package/src/gdskills/bundled/skills/review/review-frontend-conventions/SKILL.md +1 -1
  22. package/src/gdskills/bundled/skills/review/review-highload/SKILL.md +1 -1
  23. package/src/gdskills/bundled/skills/review/review-logic/SKILL.md +2 -3
  24. package/src/gdskills/bundled/skills/review/review-performance/SKILL.md +1 -1
  25. package/src/gdskills/bundled/skills/review/review-premise/SKILL.md +1 -1
  26. package/src/gdskills/bundled/skills/review/review-regression/SKILL.md +1 -1
  27. package/src/gdskills/bundled/skills/review/review-security-code/SKILL.md +1 -1
  28. package/src/gdskills/bundled/skills/review/review-style/SKILL.md +32 -36
  29. package/src/gdskills/bundled/skills/review/review-testing-practices/SKILL.md +1 -1
  30. package/src/gdskills/bundled/stacks/csharp-dotnet/rules/patterns.mdc +4 -3
  31. package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/coding-style.mdc +3 -3
  32. package/src/gdskills/bundled/stacks/ruby-rails/rules/coding-style.mdc +4 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrciphersmith/keryx",
3
- "version": "0.4.28",
3
+ "version": "0.4.29",
4
4
  "description": "Version-controlled project context for AI coding agents: code graph, architecture wiki, project memory, relevant tests, quality signals, and task flows.",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -389,6 +389,7 @@
389
389
  "src/gdskills/bundled/rules/core/security-baseline.mdc",
390
390
  "src/gdskills/bundled/rules/core/session-plan-bridge.mdc",
391
391
  "src/gdskills/bundled/rules/core/shared-definitions.mdc",
392
+ "src/gdskills/bundled/rules/core/skill-authoring.mdc",
392
393
  "src/gdskills/bundled/rules/core/skills-storage-workflow.mdc",
393
394
  "src/gdskills/bundled/rules/core/solid-principles.mdc",
394
395
  "src/gdskills/bundled/rules/core/storybook-guidelines.mdc",
@@ -6,158 +6,30 @@ alwaysApply: false
6
6
  # Clean Architecture
7
7
 
8
8
  ## Purpose
9
- Enforce correct dependency direction across architectural layers. Business logic must not depend on frameworks, databases, or UI. Changes to infrastructure must not require changes to domain logic.
9
+ Backend layering follows Clean Architecture (Robert C. Martin): presentation, application,
10
+ domain and infrastructure, with dependencies pointing inward and a domain that imports no
11
+ framework, ORM or external SDK. This rule holds only what that name leaves open.
10
12
 
11
13
  ## When To Apply
12
- Apply when creating new modules, services, or features; when deciding where to place a new class or function; when wiring up dependencies between layers.
13
-
14
- ---
15
-
16
- ## Layer Model
17
-
18
- ```
19
- ┌─────────────────────────────────────┐
20
- │ Presentation Layer │ Controllers, API handlers, CLI commands
21
- ├─────────────────────────────────────┤
22
- │ Application Layer │ Use cases, orchestration, DTOs
23
- ├─────────────────────────────────────┤
24
- │ Domain Layer │ Entities, value objects, domain services
25
- ├─────────────────────────────────────┤
26
- │ Infrastructure Layer │ DB, HTTP clients, queues, filesystem
27
- └─────────────────────────────────────┘
28
- ```
29
-
30
- **The Dependency Rule:** Dependencies point INWARD only.
31
- - Infrastructure → Domain (ok)
32
- - Application → Domain (ok)
33
- - Presentation → Application (ok)
34
- - Domain → Infrastructure (FORBIDDEN)
35
- - Domain → Framework (FORBIDDEN)
36
-
37
- ---
38
-
39
- ## Rules
40
-
41
- ### Rule 1: Domain Layer Has No Framework Imports
42
- The domain layer must import nothing from:
43
- - ORM packages (`prisma`, `typeorm`, `mongoose`)
44
- - HTTP frameworks (`express`, `fastapi`, `nestjs`)
45
- - External SDKs (AWS SDK, Stripe, etc.)
46
-
47
- ```typescript
48
- // BAD — domain entity knows about Prisma
49
- import { Prisma } from '@prisma/client';
50
- class Order {
51
- static fromPrisma(row: Prisma.OrderGetPayload<{}>): Order {}
52
- }
53
-
54
- // GOOD — domain is pure TypeScript
55
- class Order {
56
- constructor(
57
- readonly id: OrderId,
58
- readonly status: OrderStatus,
59
- readonly lines: OrderLine[],
60
- ) {}
61
- }
62
- ```
63
-
64
- ### Rule 2: Repositories Are Interfaces in Domain, Implementations in Infrastructure
65
-
66
- ```typescript
67
- // Domain layer — interface only
68
- export interface OrderRepository {
69
- findById(id: OrderId): Promise<Order | null>;
70
- save(order: Order): Promise<void>;
71
- }
72
-
73
- // Infrastructure layer — concrete implementation
74
- export class PrismaOrderRepository implements OrderRepository {
75
- constructor(private readonly prisma: PrismaClient) {}
76
- async findById(id: OrderId) { /* ... */ }
77
- async save(order: Order) { /* ... */ }
78
- }
79
- ```
80
-
81
- ### Rule 3: DTOs Live at Layer Boundaries
82
- - **Request DTOs** (validation) → Presentation layer
83
- - **Application DTOs** (use-case input/output) → Application layer
84
- - **Domain objects** → Domain layer
85
- - **Persistence models** → Infrastructure layer
86
-
87
- Never pass a Prisma row directly to a controller, or a request DTO directly into a domain entity.
88
-
89
- ### Rule 4: Use Cases Orchestrate, Domain Encapsulates Logic
90
- - Use cases (Application layer): coordinate repositories and domain services, handle transactions
91
- - Domain entities: contain business rules, invariants, validations
92
- - Controllers: parse input, call use case, format output — nothing else
93
-
94
- ```typescript
95
- // BAD — business logic leaking into controller
96
- app.post('/orders', async (req, res) => {
97
- if (req.body.items.length === 0) { /* domain rule in controller */ }
98
- const discounted = req.body.total * 0.9; /* domain logic */
99
- await db.orders.create({ data: req.body }); /* infrastructure in controller */
100
- });
101
-
102
- // GOOD — controller delegates everything
103
- app.post('/orders', async (req, res) => {
104
- const dto = parseCreateOrderDto(req.body);
105
- const result = await createOrderUseCase.execute(dto);
106
- res.status(201).json(formatOrderResponse(result));
107
- });
108
- ```
109
-
110
- ### Rule 5: No God Services
111
- A service that touches more than 2 domain aggregates is doing too much. Split it.
112
-
113
- ### Rule 6: Module Boundaries Are Enforced by Imports
114
- If module A imports from module B's internal files (`b/internal/...`), that is a boundary violation. Public APIs of modules are their index exports only.
115
-
116
- ---
117
-
118
- ## Directory Structure Pattern
119
-
120
- ```
121
- src/
122
- ├── domain/
123
- │ ├── order/
124
- │ │ ├── Order.ts # entity
125
- │ │ ├── OrderRepository.ts # interface
126
- │ │ └── OrderService.ts # domain service
127
- ├── application/
128
- │ ├── order/
129
- │ │ ├── CreateOrderUseCase.ts
130
- │ │ └── dto/
131
- │ │ ├── CreateOrderDto.ts
132
- │ │ └── OrderResponseDto.ts
133
- ├── infrastructure/
134
- │ ├── persistence/
135
- │ │ └── PrismaOrderRepository.ts
136
- │ └── http/
137
- │ └── StripePaymentGateway.ts
138
- └── presentation/
139
- └── http/
140
- └── OrderController.ts
141
- ```
142
-
143
- ---
144
-
145
- ## Iron Laws
146
-
147
- **IRON LAW 1: The domain layer has zero framework imports. If it imports Prisma, Express, or any SDK — fix it.**
148
- **IRON LAW 2: Business rules live in the domain layer, not in controllers or use cases.**
149
- **IRON LAW 3: A controller that queries the database directly violates the architecture unconditionally.**
150
-
151
- ---
152
-
153
- ## Red Flags — Stop and re-read this rule if you are thinking:
154
-
155
- | Rationalization | Why it's wrong |
156
- |---|---|
157
- | "It's a small project, layers are overkill" | Layerless code becomes unmaintainable the moment it needs testing or a second database |
158
- | "I'll just pass the Prisma object through, it's easier" | The domain now depends on Prisma — every Prisma version upgrade potentially breaks business logic |
159
- | "The use case is thin, I'll put the logic in the controller" | Controllers are discarded when the transport changes (HTTP → gRPC, REST → GraphQL) |
160
- | "I'll clean up the layers after the feature ships" | Features shipped with wrong architecture become the foundation for future features |
161
- | "The repository interface is just ceremony" | The interface enables testing without a database — eliminating it eliminates testability |
162
-
163
- **IRON LAW: IF CHANGING THE DATABASE REQUIRES CHANGING BUSINESS LOGIC, THE ARCHITECTURE IS WRONG.**
14
+ Apply to backend code when creating new modules, services, or features; when deciding where to place a new class or function; when wiring up dependencies between layers. Frontend layering (service → store → component, business logic in the store) is `code-style-patterns.mdc`, not this rule.
15
+
16
+ ## Mandatory Behavior
17
+
18
+ - **Business rules live in domain entities and domain services**, not in use cases. A use
19
+ case coordinates repositories and domain services and owns the transaction; a controller
20
+ parses input, calls one use case and formats the output.
21
+ - **A controller that queries the database is a violation whatever its size**: there is no
22
+ thin-controller exception.
23
+ - **A repository is the I/O boundary that gets an interface** (`solid-principles.mdc`,
24
+ D): the interface is declared in the domain, the implementation lives in infrastructure.
25
+ - **Each boundary maps its own types.** A persistence row never reaches a controller, and a
26
+ request DTO never enters a domain entity. Request DTOs belong to presentation, use-case
27
+ input and output to application, persistence models to infrastructure.
28
+ - **A service that touches more than 2 domain aggregates is split.**
29
+ - **A module's public API is its index exports.** Importing another module's internal files
30
+ (`b/internal/...`) crosses its boundary.
31
+ - **Project size is not an exemption**: the layers apply to a small service too.
32
+ - **Layout:** follow the project's existing layout. With none, use
33
+ `src/{domain,application,infrastructure,presentation}/<module>/`.
34
+
35
+ The check for a change: replacing the database or the transport changes no domain file.
@@ -40,6 +40,7 @@ Key principles (see canonical source for full detail with examples):
40
40
  - Avoid heavy logic in render.
41
41
 
42
42
  ## Architecture
43
+ Frontend only; backend layering, with a domain layer, is `clean-architecture.mdc`.
43
44
  - Service layer: IO/API only.
44
45
  - Store layer: business logic and state transitions.
45
46
  - Component layer: view rendering.
@@ -1,153 +1,102 @@
1
1
  ---
2
- description: "Error handling standards: Result pattern, explicit typed errors, no silent failures, no throw-everywhere anti-pattern. Use when implementing functions that can fail, calling external APIs, or handling async operations."
2
+ description: "Error handling standard shared by code writers and reviewers, with the severities reviewers use: failure is observable, carries context, keeps its cause, and is never signalled by a value a caller can mistake for success. Use when implementing functions that can fail, calling external APIs, handling async operations, or reviewing that code."
3
3
  alwaysApply: false
4
4
  ---
5
5
 
6
6
  # Error Handling
7
7
 
8
8
  ## Purpose
9
- Prevent silent failures, unhandled promise rejections, and throw-everywhere anti-patterns. Enforce the Result pattern for recoverable errors and explicit error types for domain failures.
9
+ One standard for writing and reviewing failure paths. It describes how this codebase already handles errors (typed and contextual throws, `cause` chains, no silent catches), so a writer following it and a reviewer checking it reach the same answer.
10
10
 
11
11
  ## When To Apply
12
- Apply whenever writing code that interacts with external systems, parses user input, performs I/O, or executes operations that can fail.
12
+ Apply whenever code interacts with external systems, parses input, performs I/O, or runs an operation that can fail, and when reviewing such code.
13
13
 
14
14
  ---
15
15
 
16
- ## Core Principle: Errors Are Values
17
-
18
- Recoverable errors are data, not exceptions. Use the **Result pattern** to make failure explicit in the type signature:
19
-
20
- ```typescript
21
- type Result<T, E = Error> =
22
- | { ok: true; value: T }
23
- | { ok: false; error: E };
24
-
25
- function ok<T>(value: T): Result<T, never> {
26
- return { ok: true, value };
27
- }
28
- function err<E>(error: E): Result<never, E> {
29
- return { ok: false, error };
30
- }
31
- ```
16
+ ## Rules
32
17
 
33
- ---
18
+ ### Rule 1: Signal failure explicitly
19
+ A function that can fail signals the failure in a form the caller cannot mistake for success:
20
+ - **Throw** an error. This is the default in this codebase.
21
+ - **Return a discriminated result** (`{ ok: true, value } | { ok: false, error }` or a tagged union) when callers are expected to branch on an anticipated failure, such as a parse or a lookup. This is allowed, not required.
34
22
 
35
- ## Rules
23
+ Never signal failure with `null`, `undefined`, `false`, `-1` or an empty collection when a caller could read that value as a valid result.
36
24
 
37
- ### Rule 1: Result Pattern for Recoverable Errors
38
- Any function that performs I/O, calls an external API, or parses external data MUST return `Result<T, E>` instead of throwing.
25
+ A language whose norm differs (Rust's `Result`, Go's `(T, error)`) follows its norm; its stack rule states it and overrides this rule for that language.
39
26
 
40
27
  ```typescript
41
- // BAD — caller has no idea this can fail from the type alone
42
- async function fetchUser(id: string): Promise<User> {
43
- const res = await http.get(`/users/${id}`);
44
- return res.data; // throws if 404
28
+ // BAD — "not found" and "empty" are the same value to the caller
29
+ function readEntries(path: string): Entry[] {
30
+ try { return parse(readFileSync(path, "utf8")); } catch { return []; }
45
31
  }
46
32
 
47
- // GOOD — failure is part of the contract
48
- async function fetchUser(id: string): Promise<Result<User, NotFoundError | NetworkError>> {
49
- const res = await http.get(`/users/${id}`).catch(e => null);
50
- if (!res) return err(new NetworkError('fetch failed'));
51
- if (res.status === 404) return err(new NotFoundError(id));
52
- return ok(res.data);
33
+ // GOOD — the failure is visible and says what failed
34
+ function readEntries(path: string): Entry[] {
35
+ try { return parse(readFileSync(path, "utf8")); }
36
+ catch (error) { throw new Error(`cannot read entries from ${path}`, { cause: error }); }
53
37
  }
54
38
  ```
55
39
 
56
- ### Rule 2: Typed Domain Errors
57
- Do not throw or return generic `Error`. Create typed error classes per domain:
40
+ ### Rule 2: The message names what failed and for which input
41
+ An error message identifies the operation and the input it failed on: `cannot read entries from ${path}`, not `something went wrong`.
58
42
 
59
- ```typescript
60
- // BAD
61
- throw new Error('user not found');
43
+ Use a typed error class (`class XError extends Error`) when a caller needs to tell this failure apart from others, or when it crosses a module boundary that handles it. A plain `Error` with a contextual message is fine inside a module.
62
44
 
63
- // GOOD
64
- export class NotFoundError extends Error {
65
- readonly code = 'NOT_FOUND';
66
- constructor(public readonly resource: string, public readonly id: string) {
67
- super(`${resource} with id "${id}" not found`);
68
- }
69
- }
70
- ```
71
-
72
- Common typed errors to define per domain:
73
- - `NotFoundError(resource, id)`
74
- - `ValidationError(field, message)`
75
- - `UnauthorizedError(action)`
76
- - `ConflictError(resource, detail)`
77
- - `ExternalServiceError(service, cause)`
45
+ ### Rule 3: No silent failures
46
+ Every `catch` either:
47
+ - rethrows, or returns the failure per Rule 1;
48
+ - takes a fallback that is correct for the caller, and says why in a comment;
49
+ - marks the result as degraded where the caller can see it.
78
50
 
79
- ### Rule 3: No Silent Failures
80
- Never swallow errors without action. Every `catch` block must either:
81
- - Re-throw (or return `err(...)`)
82
- - Log with full context AND take fallback action
83
- - Explicitly mark the result as degraded
51
+ An empty `catch`, or one that only logs, is a defect when the caller then proceeds as if the operation succeeded.
84
52
 
85
53
  ```typescript
86
- // BAD — silent failure
87
- try {
88
- await sendNotification(user);
89
- } catch (_) {}
90
-
91
- // GOOD — explicit, logged, handled
92
- try {
93
- await sendNotification(user);
94
- } catch (e) {
95
- logger.warn('notification failed', { userId: user.id, error: e });
96
- // explicit decision: continue without notification
97
- }
54
+ // BAD — the write failed, the caller is told it succeeded
55
+ try { await writeState(next); } catch {}
56
+ return { saved: true };
57
+
58
+ // GOOD — a deliberate, explained fallback
59
+ try { await removeTempFile(path); }
60
+ catch { /* best effort: a leftover temp file is swept by the next run */ }
98
61
  ```
99
62
 
100
- ### Rule 4: No Unhandled Promise Rejections
101
- See `async-patterns.mdc` Rule 4 ("No Unhandled Promise Rejections") for the full rule, examples, and rationale — it belongs there because it is fundamentally about promise/async control flow, not error typing.
63
+ ### Rule 4: No unhandled promise rejections
64
+ Every promise is awaited inside a `try/catch` or has a `.catch()`; a fire-and-forget call handles its own rejection. Examples are in `async-patterns.mdc` Rule 4.
102
65
 
103
- ### Rule 5: Propagate, Don't Wrap Blindly
104
- When catching and re-throwing, preserve the original error as `cause`:
66
+ ### Rule 5: Keep the cause
67
+ When catching and rethrowing, pass the original as `cause`. Do not both log and rethrow the same error in one `catch`: whoever handles it logs it.
105
68
 
106
69
  ```typescript
107
- // BAD — original stack trace lost
108
- catch (e) { throw new Error('database failed'); }
70
+ // BAD — the original stack is lost
71
+ catch (e) { throw new Error("database failed"); }
109
72
 
110
- // GOOD — chain preserved
111
- catch (e) { throw new DatabaseError('write failed', { cause: e }); }
73
+ // GOOD
74
+ catch (e) { throw new DatabaseError("write failed", { cause: e }); }
112
75
  ```
113
76
 
114
- ### Rule 6: No Assertions in Production Code
115
- `assert(condition, msg)` that throws in production is an anti-pattern for recoverable errors. Use guard clauses that return `Result` or throw typed errors.
77
+ ### Rule 6: Assertions guard invariants, not recoverable input
78
+ Do not throw from an `assert` on input a caller can legitimately send. Validate it and fail per Rule 1.
116
79
 
117
80
  ---
118
81
 
119
- ## Error Boundary Hierarchy
82
+ ## Review severities (shared with reviewers)
120
83
 
121
- ```
122
- External boundary (API, DB, filesystem)
123
- └─ Return Result<T, DomainError> ← convert to typed error here
124
- └─ Domain / use-case layer
125
- └─ Return Result<T, E> up the stack
126
- └─ Controller / handler
127
- └─ Map to HTTP status / user message here
128
- ```
84
+ `review-clean-code`, `review-logic`, `review-backend` and `review-frontend` rate failure paths by this table and keep only framework-specific rows of their own (a NestJS exception type, a MobX store's `try/catch/finally`). Change a row here, never in a reviewer.
129
85
 
130
- **Only the outermost layer (controller/handler) maps errors to HTTP responses or user messages.** Business logic never formats error messages for the UI.
86
+ | Signal | A finding when | Default | Not a finding |
87
+ |---|---|---|---|
88
+ | `catch` that hides a failure (Rule 3) | the caller then proceeds as if it succeeded | `major` — `blocker` only if the caller then persists or returns wrong data | a correct fallback with a comment giving the reason |
89
+ | Failure returned as `null` / `false` / `-1` / `[]` (Rule 1) | a caller can read it as a valid result | `major` with that caller named, else `minor` | a type that makes absence explicit and is checked |
90
+ | Rethrow without `cause`; message without operation or input (Rules 2, 5) | at a module boundary / any new message | `minor` | a throw that is not a `Result`; a plain contextual `Error` inside a module |
91
+ | Log and rethrow in one `catch` (Rule 5) | always | `minor` | — |
92
+ | Unhandled promise rejection (Rule 4) | it reaches the process | `blocker` (crash) | a rejection a framework's exception layer turns into an error response: rate that response instead |
93
+ | `catch (err: any)` in TypeScript | always | `minor` | `catch (err: unknown)` |
131
94
 
132
95
  ---
133
96
 
134
97
  ## Iron Laws
135
98
 
136
- **IRON LAW 1: A `catch (_) {}` block is forbidden. Every caught exception must be logged or returned as Result.**
137
- **IRON LAW 2: Generic `throw new Error('message')` in domain code is forbidden. Always use typed error classes.**
138
- **IRON LAW 3: Any function that can fail due to external conditions MUST reflect that in its return type.**
139
-
140
- ---
141
-
142
- ## Red Flags — Stop and re-read this rule if you are thinking:
143
-
144
- | Rationalization | Why it's wrong |
145
- |---|---|
146
- | "I'll just throw here, the caller will handle it" | The caller often doesn't handle it — unhandled rejections crash processes silently |
147
- | "The error is unlikely, I'll skip the error case" | Unlikely errors are exactly the ones that cause production incidents |
148
- | "I'll add proper error handling in a follow-up" | Error handling added after-the-fact misses edge cases that were obvious during initial implementation |
149
- | "Using Result makes the code verbose" | Verbosity here is intentional: it forces the caller to acknowledge that failure is possible |
150
- | "I'll wrap everything in a try/catch at the top" | Top-level catch loses all type information and context — handle errors close to their source |
151
- | "I can just check if the value is null after" | Null is not an error type — it conveys nothing about why the operation failed |
152
-
153
- **IRON LAW: SILENCE IS NOT A VALID ERROR STRATEGY. EVERY FAILURE PATH MUST BE OBSERVABLE.**
99
+ **IRON LAW 1: A catch that hides a failure from a caller who then proceeds is forbidden.**
100
+ **IRON LAW 2: A failure is never signalled by a value a caller can read as success.**
101
+ **IRON LAW 3: A rethrow keeps the original error as `cause`.**
102
+ </content>
@@ -0,0 +1,190 @@
1
+ ---
2
+ description: "Content standard for skill, reviewer-lens and rule text: keep only what changes model behaviour — trigger, finish line, filters, calibration, output format, project decisions — and name a published canon instead of restating it."
3
+ alwaysApply: false
4
+ applies_to: process
5
+ ---
6
+
7
+ # Skill Authoring Standard
8
+
9
+ ## Purpose
10
+
11
+ Current models already know the published canon of software engineering: design principles,
12
+ well-known books, framework documentation. A skill earns its context with what the model
13
+ cannot know — this project's decisions, where the work ends, what not to report, how to grade
14
+ a result. Text that restates the canon is paid for on every load and changes nothing.
15
+
16
+ Measured on keryx's own clean-code review lens: replacing its restated textbook material with
17
+ a table of project decisions cut the lens from 531 to 220 lines with no loss of recall and no
18
+ added noise, and one filter ("a threshold counts only when this change crosses it") removed a
19
+ third of the noise findings. Filters and decisions moved the numbers; principles did not.
20
+
21
+ This rule governs **content**. Storage, frontmatter and length ceilings are in
22
+ `skills-storage-workflow.mdc`; freshness is in `skill-lifecycle.mdc`.
23
+
24
+ ## When To Apply
25
+
26
+ - Writing or editing a `SKILL.md`, a reviewer lens, a rule file, or a subagent instruction.
27
+ - Reviewing a change to any of those.
28
+ - Auditing existing skills and rules for text that no longer changes behaviour.
29
+
30
+ ## Mandatory Behavior
31
+
32
+ ### 1. Apply the deletion test to every line
33
+
34
+ A line stays only if a capable model would behave differently without it. These fail:
35
+ definitions of well-known concepts, restated principles, generic advice ("write readable
36
+ code"), and motivation for doing the task well. When unsure about a line you are writing,
37
+ leave it out and let the evidence in section 7 decide; for text that already ships, follow
38
+ section 9.
39
+
40
+ ### 2. Name the canon, then state what the name cannot carry
41
+
42
+ Reference a published standard by name, in one line. Then write the part the name leaves
43
+ open:
44
+
45
+ - which side wins where the canon contradicts itself or another named canon (small functions
46
+ against deep modules, removing duplication against keeping code local);
47
+ - where this project departs from the canon on purpose, and why — otherwise the departure is
48
+ reported as a defect on every run.
49
+
50
+ A named canon brings its dogma with it. Pair every such reference with filters (section 3),
51
+ or the output fills with findings the canon implies and the project does not want.
52
+
53
+ A line that mixes the two is split: in "functions should be small and focused; flag as
54
+ minor", the grade stays and the explanation goes.
55
+
56
+ ### 3. Carry the content a model cannot derive
57
+
58
+ Include each of these that applies to the skill:
59
+
60
+ - **Trigger** — `description` says what the skill does and when to use it. Conditions of use
61
+ live there, because the body is not loaded until the skill is chosen.
62
+ - **Finish line** — the state in which the work is done.
63
+ - **Filters** — what not to do or report: debt that predates the change, anything a linter
64
+ already catches, anything the change did not touch.
65
+ - **Calibration** — for a skill that grades: the severity scale, the confidence below which a
66
+ finding is dropped, and the evidence a finding must carry (a failing input, not "violates
67
+ a principle").
68
+ - **Input and output contracts** — a template or a schema, for what the skill receives
69
+ and what it returns.
70
+ - **Project decisions** — thresholds, conventions, and the departures from section 2. A
71
+ decision is a specific value or choice the canon leaves open: "40 lines", "locality wins".
72
+ A language's or framework's published default (camelCase in TypeScript) is canon;
73
+ choosing between published conventions, or departing from the default, is a decision.
74
+ In a shipped rule it is a default a project may override; it stays even when its origin
75
+ was never recorded, because the value still constrains the result where the explanation
76
+ around it does not.
77
+ - **Known default failures** — specific outputs the model produces by default and should
78
+ not. A change that adds one names the run where it was seen.
79
+
80
+ ### 4. Write steps only where order is a constraint
81
+
82
+ Use numbered steps when a step is a gate for the next one or the operation is fragile enough
83
+ that one path is safe. Otherwise state the goal and the finish line. An operation that must
84
+ run the same way every time belongs in a script the skill runs, not in prose the model
85
+ re-derives.
86
+
87
+ ### 5. Give the reason, not the emphasis
88
+
89
+ A hard rule states its reason in the same sentence, so the model can apply it to a case the
90
+ rule did not foresee. Capitalised emphasis is for a gate whose miss cannot be undone; used
91
+ elsewhere it makes the model apply the rule too widely.
92
+
93
+ ### 6. Offer one default
94
+
95
+ Give one recommended approach and the condition under which to use the alternative. A list
96
+ of equivalent options moves the choice back to the model without the context to make it.
97
+
98
+ ### 7. Add a line for an observed failure, keep it while it shows an effect
99
+
100
+ A new line answers a failure seen in a run, not one imagined in advance. For a shipped skill,
101
+ compare its routing and behaviour evals with and without the change; a line that moves
102
+ nothing is removed, and a change that makes them worse is recorded as
103
+ `skills-storage-workflow.mdc` ("Rejected Changes") requires.
104
+
105
+ ### 8. Check the smallest tier the skill runs on
106
+
107
+ A skill dispatched to a lighter tier (`model-selection.mdc`) is tested on that tier. A line
108
+ the flagship does not need can pass the deletion test for the lighter model; keep it, and say
109
+ which tier it is for. This protects procedure and precision, not restated canon or
110
+ motivation: every tier already knows the published canon.
111
+
112
+ ### 9. Audit existing text by what reading can decide
113
+
114
+ Reading settles sections 1 and 2; sections 4, 7 and 8 need a run. An audit of text that
115
+ already ships therefore sorts each block into one of three:
116
+
117
+ - **Remove** — restated canon or motivation, with no decision, filter or grade in it. A code
118
+ example of a published principle is restated canon; an example that shows a project
119
+ decision is not.
120
+ - **Keep** — anything section 3 lists, and any block a test pins or a required section
121
+ holds. For a skill, the required sections are its anatomy; for a rule, the headings
122
+ `rule-management-workflow.mdc` ("Rule File Standard") requires — the heading stays, its
123
+ content follows sections 1 and 2. A line that feeds a required field of the output (a
124
+ `Fix`, a severity) stays whole. To remove pinned text, change the check in the same
125
+ change.
126
+ - **Undecided** — everything else. It stays until a run decides: an eval comparison, or a
127
+ run on the lightest tier the skill is dispatched to. Where no eval covers the file, say
128
+ so; reading alone does not justify the removal.
129
+
130
+ Two findings are reported rather than sorted: a capitalised rule without a reason
131
+ (section 5) is rewritten with its reason, and numbered steps that are not gates
132
+ (section 4) are Undecided.
133
+
134
+ An existing line is not removed for lacking a record of the failure it answers; that record
135
+ is required only of lines added from now on.
136
+
137
+ A file that shrinks to a few lines stays a short file while anything cites it by name.
138
+ Shortness is the expected result, not a gap to refill.
139
+
140
+ ## Output Contract
141
+
142
+ When this rule drives an edit or a review of a skill or rule:
143
+
144
+ - Report each removed block as `file:line` with the section of this rule it failed.
145
+ - Report each added line with the observed failure it answers.
146
+ - Report the line count before and after; a trimmed shipped skill lowers its ceiling in the
147
+ same change (`skills-storage-workflow.mdc`, "Length Ceilings").
148
+ - Report each undecided block with the run that would decide it.
149
+ - Input and output formats and schemas, and safety, permission and confirmation text are out
150
+ of scope —
151
+ never removed under this rule.
152
+
153
+ ## Examples
154
+
155
+ ### Restated canon → named canon plus the project's decision
156
+
157
+ ```
158
+ # Before
159
+ The Single Responsibility Principle states that a class should have only one
160
+ reason to change. A function should do one thing, and do it well. Functions
161
+ should be small...
162
+
163
+ # After
164
+ Review against SOLID and Clean Code. In this project:
165
+ - a function mixing I/O with a transform is a finding at any length;
166
+ - length alone is a finding only past 40 lines;
167
+ - where "small functions" and locality conflict, locality wins.
168
+ ```
169
+
170
+ ### Principle → filter
171
+
172
+ ```
173
+ # Before
174
+ Report long functions, duplicated literals and long parameter lists.
175
+
176
+ # After
177
+ A threshold counts only when this change crosses it. One more line in a
178
+ function that was already too long is not a finding.
179
+ ```
180
+
181
+ ### Emphasis → reason
182
+
183
+ ```
184
+ # Before
185
+ NEVER report style issues.
186
+
187
+ # After
188
+ Leave style to the linter: a finding the linter already raises is noise
189
+ for the author and hides the ones it cannot see.
190
+ ```
@@ -11,6 +11,11 @@ Keep skill definitions consistent across master source and global agent director
11
11
  ## Trigger
12
12
  Apply when user asks to create, update, or sync a skill.
13
13
 
14
+ ## Content Standard
15
+ What a skill's text must and must not contain is in `skill-authoring.mdc` — read
16
+ it before writing or trimming skill prose. This rule covers where a skill lives
17
+ and how it is shipped.
18
+
14
19
  ## Mandatory Clarification Step
15
20
  Before creating or editing a skill, ask and confirm:
16
21
  1. Target location