@yaawn/workflow 0.0.0-stage → 0.3.1

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 (101) hide show
  1. package/README.md +172 -2
  2. package/agents/instructions/output-styles/yaawn-eli5.instructions.md +45 -0
  3. package/agents/instructions/yaawn-accessibility.css.instructions.md +58 -0
  4. package/agents/instructions/yaawn-accessibility.html.instructions.md +90 -0
  5. package/agents/instructions/yaawn-accessibility.javascript.instructions.md +50 -0
  6. package/agents/instructions/yaawn-clean-code.typescript.instructions.md +74 -0
  7. package/agents/instructions/yaawn-function-coupling.typescript.instructions.md +100 -0
  8. package/agents/instructions/yaawn-html-css-js.html.instructions.md +32 -0
  9. package/agents/instructions/yaawn-open-source-first.instructions.md +38 -0
  10. package/agents/instructions/yaawn-personas.instructions.md +18 -0
  11. package/agents/instructions/yaawn-semantic-html.html.instructions.md +40 -0
  12. package/agents/instructions/yaawn-vanilla-css.css.instructions.md +50 -0
  13. package/agents/output-styles/yaawn-eli5.instructions.md +45 -0
  14. package/agents/personas/yaawn-developer.md +16 -0
  15. package/agents/personas/yaawn-product-owner.md +18 -0
  16. package/agents/personas/yaawn-reviewer.md +16 -0
  17. package/agents/skills/yaawn-clean-code/SKILL.md +61 -0
  18. package/agents/skills/yaawn-clean-code/references/classes.md +114 -0
  19. package/agents/skills/yaawn-clean-code/references/comments.md +164 -0
  20. package/agents/skills/yaawn-clean-code/references/error-handling.md +151 -0
  21. package/agents/skills/yaawn-clean-code/references/formatting.md +146 -0
  22. package/agents/skills/yaawn-clean-code/references/functions.md +261 -0
  23. package/agents/skills/yaawn-clean-code/references/meaningful-names.md +234 -0
  24. package/agents/skills/yaawn-clean-code/references/objects-and-data-structures.md +130 -0
  25. package/agents/skills/yaawn-clean-code/references/principles.md +76 -0
  26. package/agents/skills/yaawn-clean-code/references/simple-design-and-code-smells.md +130 -0
  27. package/agents/skills/yaawn-clean-code/references/unit-tests.md +114 -0
  28. package/agents/skills/yaawn-create-plan/SKILL.md +228 -0
  29. package/agents/skills/yaawn-grill-bug-report/SKILL.md +31 -0
  30. package/agents/skills/yaawn-grill-bug-report/references/bug-report-checklist.md +27 -0
  31. package/agents/skills/yaawn-grill-design/SKILL.md +68 -0
  32. package/agents/skills/yaawn-grill-design/references/design-checklist.md +36 -0
  33. package/agents/skills/yaawn-grill-other/SKILL.md +31 -0
  34. package/agents/skills/yaawn-grill-other/references/other-checklist.md +19 -0
  35. package/agents/skills/yaawn-grill-refactor/SKILL.md +31 -0
  36. package/agents/skills/yaawn-grill-refactor/references/refactor-checklist.md +26 -0
  37. package/agents/skills/yaawn-grill-spike/SKILL.md +31 -0
  38. package/agents/skills/yaawn-grill-spike/references/spike-checklist.md +25 -0
  39. package/agents/skills/yaawn-grill-story/SKILL.md +34 -0
  40. package/agents/skills/yaawn-grill-story/references/concept-challenge.md +67 -0
  41. package/agents/skills/yaawn-grill-story/references/story-checklist.md +43 -0
  42. package/agents/skills/yaawn-implement-plan/SKILL.md +196 -0
  43. package/agents/skills/yaawn-implement-plan/assets/fix-prompt.md +66 -0
  44. package/agents/skills/yaawn-implement-plan/assets/review-prompt.md +89 -0
  45. package/agents/skills/yaawn-implement-plan/assets/session-prompt.md +80 -0
  46. package/agents/skills/yaawn-implement-plan/scripts/agent.ts +218 -0
  47. package/agents/skills/yaawn-implement-plan/scripts/caffeinate.ts +56 -0
  48. package/agents/skills/yaawn-implement-plan/scripts/groups.ts +233 -0
  49. package/agents/skills/yaawn-implement-plan/scripts/overnight.ts +772 -0
  50. package/agents/skills/yaawn-implement-plan/scripts/parallel.ts +1176 -0
  51. package/agents/skills/yaawn-implement-plan/scripts/processes.ts +53 -0
  52. package/agents/skills/yaawn-implement-plan/scripts/stages.ts +65 -0
  53. package/agents/skills/yaawn-implement-plan/scripts/targets.ts +381 -0
  54. package/agents/skills/yaawn-implement-plan/scripts/worktrees.ts +431 -0
  55. package/agents/skills/yaawn-owasp-security/SKILL.md +106 -0
  56. package/agents/skills/yaawn-owasp-security/references/a01-broken-access-control.md +58 -0
  57. package/agents/skills/yaawn-owasp-security/references/a02-security-misconfiguration.md +56 -0
  58. package/agents/skills/yaawn-owasp-security/references/a03-software-supply-chain-failures.md +56 -0
  59. package/agents/skills/yaawn-owasp-security/references/a04-cryptographic-failures.md +67 -0
  60. package/agents/skills/yaawn-owasp-security/references/a05-injection.md +53 -0
  61. package/agents/skills/yaawn-owasp-security/references/a06-insecure-design.md +48 -0
  62. package/agents/skills/yaawn-owasp-security/references/a07-authentication-failures.md +68 -0
  63. package/agents/skills/yaawn-owasp-security/references/a08-software-data-integrity-failures.md +45 -0
  64. package/agents/skills/yaawn-owasp-security/references/a09-security-logging-alerting-failures.md +59 -0
  65. package/agents/skills/yaawn-owasp-security/references/a10-mishandling-exceptional-conditions.md +63 -0
  66. package/agents/skills/yaawn-prepare-plan/SKILL.md +110 -0
  67. package/agents/skills/yaawn-save-plan/SKILL.md +65 -0
  68. package/agents/skills/yaawn-save-plan/scripts/plan-body.ts +331 -0
  69. package/agents/skills/yaawn-save-plan/scripts/save-plan.ts +443 -0
  70. package/agents/skills/yaawn-split-story/SKILL.md +189 -0
  71. package/agents/skills/yaawn-split-story/references/spider.md +64 -0
  72. package/agents/skills/yaawn-split-story/scripts/create-issue.ts +162 -0
  73. package/agents/skills/yaawn-verify-executed-plan/SKILL.md +154 -0
  74. package/agents/skills/yaawn-verify-executed-plan/scripts/overnight.ts +362 -0
  75. package/agents/skills/yaawn-verify-executed-plan/scripts/pull-request.ts +131 -0
  76. package/agents/skills/yaawn-write-bug-report/SKILL.md +87 -0
  77. package/agents/skills/yaawn-write-other/SKILL.md +90 -0
  78. package/agents/skills/yaawn-write-refactor/SKILL.md +94 -0
  79. package/agents/skills/yaawn-write-spike/SKILL.md +94 -0
  80. package/agents/skills/yaawn-write-user-story/SKILL.md +187 -0
  81. package/agents/skills/yaawn-write-user-story/references/acceptance-criteria.md +186 -0
  82. package/agents/skills/yaawn-write-user-story/references/five-types-of-value.md +82 -0
  83. package/agents/skills/yaawn-write-user-story/references/user-story-fundamentals.md +75 -0
  84. package/agents/yaawn-glossary.md +146 -0
  85. package/agents/yaawn-grilling.md +75 -0
  86. package/agents/yaawn-worktrees.md +69 -0
  87. package/config/install-tasks.json +35 -0
  88. package/config/settings.json +23 -0
  89. package/config/wizard.json +128 -0
  90. package/github/ISSUE_TEMPLATE/yaawn-bug-report.md +59 -0
  91. package/github/ISSUE_TEMPLATE/yaawn-other.md +38 -0
  92. package/github/ISSUE_TEMPLATE/yaawn-refactor.md +38 -0
  93. package/github/ISSUE_TEMPLATE/yaawn-spike.md +16 -0
  94. package/github/ISSUE_TEMPLATE/yaawn-story.md +56 -0
  95. package/package.json +33 -4
  96. package/scripts/install.js +73 -0
  97. package/yaawn/gitignore +1 -0
  98. package/yaawn/yaawn-definition-of-done.md +5 -0
  99. package/yaawn/yaawn-project-glossary.md +7 -0
  100. package/yaawn/yaawn-user-roles.md +3 -0
  101. package/yaawn/yaawn-verification-commands.md +7 -0
@@ -0,0 +1,38 @@
1
+ ---
2
+ applyTo: "**/*"
3
+ description: "When creating new code, research whether existing open source packages already provide the feature before writing it from scratch."
4
+ ---
5
+
6
+ ## Open Source First
7
+
8
+ Before writing new code from scratch, always research whether a well-maintained open source package already provides the feature. Do not blindly rewrite what the ecosystem already offers.
9
+
10
+ ### Research before you write
11
+
12
+ - Search for existing libraries that solve the problem (npm, PyPI, crates.io, etc. depending on the ecosystem)
13
+ - Evaluate candidates on: maintenance activity, popularity, bundle size, license compatibility, and API fit
14
+ - Prefer battle-tested, widely-used packages over rolling your own solution
15
+
16
+ ### Use an existing package when
17
+
18
+ - The package is actively maintained and widely adopted
19
+ - Its license is compatible with the project
20
+ - It covers the needed feature without excessive bloat
21
+ - Adopting it is faster and less error-prone than writing the code yourself
22
+
23
+ ### Write it yourself when
24
+
25
+ - No suitable package exists
26
+ - The package is unmaintained, has incompatible licensing, or is bloated for the use case
27
+ - The feature is a core differentiator that needs full control
28
+ - The implementation would be trivial and adding a dependency is not justified
29
+
30
+ ### Modern, lightweight utility libraries
31
+
32
+ - [es-toolkit](https://es-toolkit.dev) — a modern, performant, tree-shakeable alternative to lodash
33
+ - [tailwind](https://tailwindcss.com) — a modern, performant, utility-first CSS framework
34
+ - Look for similar focused, well-maintained alternatives in every domain before writing custom code
35
+
36
+ ### Rule of thumb
37
+
38
+ Reuse first, write second.
@@ -0,0 +1,18 @@
1
+ ---
2
+ applyTo: "**/*"
3
+ description: "Pick the agent persona for the task under the hood: Developer by default, Reviewer for reviews, Product Owner for work item writing."
4
+ ---
5
+
6
+ ## Agent Personas
7
+
8
+ Before you start a task, pick the persona that fits it, read its file, and work in that persona until the task is done. Pick it yourself — never ask the user to choose a persona, and never mention the switch unless asked.
9
+
10
+ | Task | Persona | File |
11
+ | -------------------------------------------------------------------------------------------------------------------- | ------------- | ----------------------------------------- |
12
+ | Reviewing code, a pull request, a plan, or a diff; audits | Reviewer | `.agents/personas/yaawn-reviewer.md` |
13
+ | Writing, refining, grilling (conceptual), or splitting work items (story, refactor, spike, bug report, other change) | Product Owner | `.agents/personas/yaawn-product-owner.md` |
14
+ | Everything else — implementing, fixing, refactoring, planning, technical grilling, explaining | Developer | `.agents/personas/yaawn-developer.md` |
15
+
16
+ - Developer is the default. When a task fits no other row, or a persona file is missing, work as the Developer.
17
+ - A skill that names a persona wins over this table.
18
+ - A persona sets the mindset only. It never overrides the user's request, `AGENTS.md`, or other instructions.
@@ -0,0 +1,40 @@
1
+ ---
2
+ applyTo: '**/*.{html,tsx,jsx}'
3
+ description: 'Always use semantic HTML elements instead of meaningless div or span elements. See https://web.dev/learn/html/semantic-html'
4
+ ---
5
+
6
+ ## Semantic HTML
7
+
8
+ When creating HTML, always prefer semantic elements over meaningless `<div>` or `<span>` wrappers. Semantic HTML describes the meaning of the content to browsers, assistive technologies, and search engines.
9
+
10
+ ### Use the right element for the job
11
+
12
+ - `<header>`, `<nav>`, `<main>`, `<article>`, `<section>`, `<aside>`, `<footer>` — for page structure
13
+ - `<h1>`–`<h6>` — for headings, in hierarchical order (never skip levels for styling; use CSS instead)
14
+ - `<p>` — for paragraphs of text
15
+ - `<ul>` / `<ol>` / `<li>` — for lists
16
+ - `<a>` — for links (use `href`, not JS click handlers, whenever navigation is the intent)
17
+ - `<button>` — for actions (not `<div onclick>`)
18
+ - `<form>`, `<label>`, `<input>`, `<select>`, `<textarea>` — for forms, with proper label associations
19
+ - `<img>` with meaningful `alt` text — for images
20
+ - `<table>`, `<thead>`, `<tbody>`, `<th>`, `<td>` — for tabular data (not for layout)
21
+ - `<figure>` / `<figcaption>` — for self-contained content with a caption
22
+ - `<time>` — for dates and times
23
+ - `<blockquote>` / `<q>` / `<cite>` — for quotations
24
+
25
+ ### Why semantic HTML matters
26
+
27
+ - **Accessibility**: screen readers and other assistive technologies rely on semantic structure to navigate and announce content
28
+ - **SEO**: search engines understand content hierarchy and importance from semantic elements
29
+ - **Maintainability**: code is self-documenting — the element name tells you what the content is
30
+ - **Resilience**: semantic HTML works without CSS and degrades gracefully
31
+
32
+ ### Rules
33
+
34
+ - Never use `<div>` or `<span>` when a semantic element exists for the purpose
35
+ - Do not choose elements for their default styling — style semantic elements with CSS instead
36
+ - Keep a logical heading hierarchy (`h1` → `h2` → `h3`, never skip levels)
37
+ - Every `<img>` must have an `alt` attribute (use `alt=""` only for purely decorative images)
38
+ - Every form input must have an associated `<label>`
39
+
40
+ Reference: [web.dev — Learn HTML: Semantic HTML](https://web.dev/learn/html/semantic-html)
@@ -0,0 +1,50 @@
1
+ ---
2
+ applyTo: '**/*.css'
3
+ description: 'Write vanilla CSS only, with class names following the OOCSS or BEM pattern. See https://www.frontendmentor.io/articles/understanding-css-naming-conventions-bem-oocss-smacss-and-suit-css-V6ZZUYs1xz'
4
+ ---
5
+
6
+ ## Vanilla CSS with OOCSS or BEM naming
7
+
8
+ All CSS is hand-written vanilla CSS — no preprocessor, no utility framework, no CSS-in-JS. Class names follow the OOCSS or BEM pattern so styles stay predictable, reusable, and free of collisions.
9
+
10
+ ### Vanilla CSS only
11
+
12
+ - Write plain `.css` files — no Sass/Less, no Tailwind or other utility-first frameworks, no CSS-in-JS
13
+ - Keep styles in stylesheets, not in `style` attributes or JS strings
14
+ - Keep selectors flat — nest at most one level deep, prefer class names over long descendant chains
15
+ - Keep specificity low
16
+ - Reserve `!important` for overriding third-party styles
17
+
18
+ ### Naming: OOCSS or BEM
19
+
20
+ - **Pick one pattern per component and stick to it.**
21
+
22
+ **OOCSS** — separate structure from skin:
23
+
24
+ - Structure (layout, sizing, positioning) and skin (colors, borders, backgrounds) live in separate classes
25
+ - Example: `class="btn btn-primary"` — `.btn` carries the structure, `.btn-primary` carries the skin
26
+ - Reuse the structure class across components instead of repeating layout rules
27
+
28
+ **BEM** — Block, Element, Modifier:
29
+
30
+ - `.block` — a standalone component
31
+ - `.block__element` — a part of the block, joined with a double underscore
32
+ - `.block--modifier` / `.block__element--modifier` — a variant, joined with a double dash
33
+ - Example: `.card`, `.card__title`, `.card__body`, `.card--highlighted`, `.card__title--large`
34
+ - Reach every component through class names, not bare element selectors or IDs
35
+
36
+ ### Rules
37
+
38
+ - Class names are lowercase kebab-case; BEM separators are `__` (element) and `--` (modifier)
39
+ - Give each class one responsibility — split unrelated styles into separate classes
40
+ - Scope component styles to their block or root class so components stay portable
41
+ - Name classes after what they are, not how they look (`class="alert"`, not `class="red-box"`) — modifiers carry the variants
42
+
43
+ ### Why this pattern
44
+
45
+ - Predictability: the name tells you the component, the part, and the variant at a glance
46
+ - No collisions: namespaced names keep components from leaking styles into each other
47
+ - Reusability: separating structure from skin lets you recombine them across components
48
+ - Maintainability: flat, low-specificity selectors are easy to override and refactor
49
+
50
+ Reference: [Frontend Mentor — Understanding CSS naming conventions: BEM, OOCSS, SMACSS, and SUIT CSS](https://www.frontendmentor.io/articles/understanding-css-naming-conventions-bem-oocss-smacss-and-suit-css-V6ZZUYs1xz)
@@ -0,0 +1,45 @@
1
+ ---
2
+ name: ELI5
3
+ description: 'Use only when the user explicitly asks for an ELI5, beginner-level, or plainly-worded explanation. Rewrites chat prose to use analogies, everyday vocabulary, and short sentences. Changes wording only — never code, commands, or file paths.'
4
+ keep-coding-instructions: true
5
+ ---
6
+
7
+ # ELI5
8
+
9
+ Explain things the way you would to someone smart who has never seen this system before.
10
+
11
+ ## Scope
12
+
13
+ This style changes **the prose of chat answers only**. It never changes:
14
+
15
+ - code, identifiers, and type names
16
+ - file paths and shell commands
17
+ - API names, endpoints, and configuration keys
18
+ - error messages, stack traces, and log output
19
+ - diffs and code comments
20
+ - commit messages and PR descriptions
21
+ - i18n keys and i18n values
22
+ - anything inside a fenced code block
23
+
24
+ Reproduce all of the above verbatim. Generated code follows the repository's existing conventions and is never reworded to fit this style.
25
+
26
+ Accuracy outranks every rule below:
27
+
28
+ - Never simplify a technical term into an inaccurate one.
29
+ - Never shorten an error message or a security warning.
30
+ - Never drop a caveat to make a sentence shorter.
31
+
32
+ If a rule in this file would make the answer wrong, the rule loses.
33
+
34
+ If another output style is also active, stop and ask which one applies.
35
+
36
+ ## Writing rules
37
+
38
+ - Lead with an analogy or a concrete everyday comparison, then connect it back to the real thing.
39
+ - Use everyday vocabulary. Prefer "reads" over "consumes", "goes wrong" over "fails to resolve".
40
+ - Keep sentences short. One idea per sentence.
41
+ - Introduce every technical term the first time it appears: name it, then say what it does in plain words.
42
+ - Prefer concrete examples over abstract description.
43
+ - Say what something is _for_ before saying how it works.
44
+ - Do not use jargon as a shortcut. If a term is unavoidable, explain it.
45
+ - Keep the answer as short as the question allows. Simple is not the same as long.
@@ -0,0 +1,16 @@
1
+ # Persona: Developer
2
+
3
+ The default persona. Wear it for every task that no other persona claims — implementing, fixing, refactoring, technical grilling of an implementation design, explaining code, running the plan pipeline.
4
+
5
+ ## Mindset
6
+
7
+ - Deliver working, tested code — not a sketch, not a suggestion.
8
+ - Follow the team's definition of done in `.yaawn/yaawn-definition-of-done.md` and the instructions that apply to the files you touch.
9
+ - Keep changes small and surgical; leave the code a little cleaner than you found it.
10
+ - Bake security in while you write — load the `yaawn-owasp-security` lens; never leave it as a follow-up note.
11
+ - Prove it works: add or update the tests that cover the change.
12
+
13
+ ## Avoid
14
+
15
+ - Unrequested features, speculative abstractions, or rewrites of code you were not asked to touch.
16
+ - Declaring work done before it is verified.
@@ -0,0 +1,18 @@
1
+ # Persona: Product Owner
2
+
3
+ Wear it for writing, refining, conceptually grilling, or splitting work items — stories, refactors, spikes, and bug reports — the what, never the how.
4
+
5
+ ## Mindset
6
+
7
+ - Start from value: who benefits, what changes for them, and why it matters now.
8
+ - Write stories from the product's user roles in `.yaawn/yaawn-user-roles.md`; with none listed, write for the Developer.
9
+ - Hold every story to INVEST — independent, negotiable, valuable, estimable, small, testable.
10
+ - Make acceptance criteria sharp: observable outcomes a non-developer can verify.
11
+ - Give every other type its own sharp fields: a refactor's goal and done means, a spike's one question, timebox, and exit criteria, a bug's steps to reproduce and current versus expected behavior.
12
+ - Prefer thin vertical slices that ship value early.
13
+
14
+ ## Avoid
15
+
16
+ - Implementation details, file names, or code in any work item.
17
+ - Generic "As a user" stories.
18
+ - Forcing a refactor, spike, or bug report into story shape — no persona, no "As a … I want …".
@@ -0,0 +1,16 @@
1
+ # Persona: Reviewer
2
+
3
+ Wear it for every review — code review, pull request review, plan review, or audit.
4
+
5
+ ## Mindset
6
+
7
+ - Review like a staff engineer: judge correctness, design, security, and maintainability, not taste.
8
+ - Flag only what matters — bugs, logic errors, security risks, missing tests, broken contracts. Skip style nits a linter would catch.
9
+ - Be specific: name the file and line, explain the impact, and propose a concrete fix.
10
+ - Rank findings by severity so the most important ones come first.
11
+ - Say clearly when something is good enough to ship.
12
+
13
+ ## Avoid
14
+
15
+ - Rewriting the change yourself instead of giving feedback.
16
+ - Vague remarks ("this could be better") without a reason or a fix.
@@ -0,0 +1,61 @@
1
+ ---
2
+ name: yaawn-clean-code
3
+ description: "Clean Code rules based on Robert C. Martin's book. Use when: reviewing code quality, naming variables/functions/classes, refactoring long functions, reducing complexity, improving readability, writing clean tests, handling errors, formatting code, detecting code smells, applying SOLID/DRY/KISS/YAGNI principles, code review feedback."
4
+ user-invocable: false
5
+ context: fork
6
+ metadata:
7
+ github-repo: https://github.com/markusfalk/yaawn
8
+ author: markusfalk
9
+ ---
10
+
11
+ # Clean Code Rules
12
+
13
+ Provides clean code rules and guidelines based on Robert C. Martin's _Clean Code: A Handbook of Agile Software Craftsmanship_, distilled from the [gpcoder gitbook summary](https://gpcoder.gitbook.io/clean-code) and adapted for TypeScript.
14
+
15
+ This skill **complements** the always-on [yaawn-clean-code.typescript.instructions.md](../../../.agents/instructions/yaawn-clean-code.typescript.instructions.md) which provides a lightweight summary. Use this skill for deeper guidance on specific topics.
16
+
17
+ ## When to Use
18
+
19
+ - **Code review**: Evaluating naming, function size, class design, comment quality
20
+ - **Refactoring**: Breaking down large functions/classes, removing duplication, improving readability
21
+ - **Design decisions**: Choosing between data structures vs objects, error handling strategies, abstraction levels
22
+ - **Test quality**: Writing clean, readable, independent tests following F.I.R.S.T. principles
23
+ - **Code smell detection**: Identifying rigidity, fragility, immobility, needless complexity, opacity
24
+
25
+ ## Topic Routing Table
26
+
27
+ Identify which topic(s) are relevant to the user's question, then load **only** the matching reference file(s).
28
+
29
+ | Topic Keywords | Reference File |
30
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------- |
31
+ | naming, variables, functions, classes, intention-revealing, pronounceable, searchable, encodings, prefixes, context, disinformation | [meaningful-names.md](./references/meaningful-names.md) |
32
+ | functions, small, do one thing, abstraction level, stepdown rule, nesting, negative conditionals, switch, polymorphism, arguments, flag arguments, side effects, command-query, error codes, DRY | [functions.md](./references/functions.md) |
33
+ | classes, organization, encapsulation, small classes, god class, SRP, cohesion, SOLID, patterns | [classes.md](./references/classes.md) |
34
+ | comments, self-documenting, JSDoc, redundant comments, misleading, TODO, journal comments, noise, commented-out code | [comments.md](./references/comments.md) |
35
+ | error handling, exceptions, try-catch, typed errors, null, undefined, fail fast, error context, wrapper errors | [error-handling.md](./references/error-handling.md) |
36
+ | tests, unit tests, readability, one assert, single concept, F.I.R.S.T., fast, independent, repeatable, self-validating, timely, AAA, given-when-then | [unit-tests.md](./references/unit-tests.md) |
37
+ | formatting, vertical, horizontal, whitespace, density, openness, indentation, team rules, dependent functions | [formatting.md](./references/formatting.md) |
38
+ | objects, data structures, abstraction, anti-symmetry, hybrids, Law of Demeter, DTO, encapsulation | [objects-and-data-structures.md](./references/objects-and-data-structures.md) |
39
+ | simple design, code smells, duplication, expressiveness, rigidity, fragility, immobility, opacity, dead code, feature envy | [simple-design-and-code-smells.md](./references/simple-design-and-code-smells.md) |
40
+ | SOLID, SRP, OCP, LSP, ISP, DIP, KISS, DRY, YAGNI, Boy Scout Rule, design patterns, coding conventions | [principles.md](./references/principles.md) |
41
+
42
+ ## Quick Decision Guide
43
+
44
+ | Question | Answer |
45
+ | ------------------------------------------ | ----------------------------------------- |
46
+ | Is a name unclear? | Load **meaningful-names.md** |
47
+ | Is a function too long or doing too much? | Load **functions.md** |
48
+ | Is a class too large or unfocused? | Load **classes.md** |
49
+ | Should I add a comment? | Load **comments.md** — probably not |
50
+ | How should I handle this error? | Load **error-handling.md** |
51
+ | Are my tests clean and maintainable? | Load **unit-tests.md** |
52
+ | Is the code layout hard to follow? | Load **formatting.md** |
53
+ | Should this be a class or a plain object? | Load **objects-and-data-structures.md** |
54
+ | Something feels wrong but I can't name it? | Load **simple-design-and-code-smells.md** |
55
+ | Which principle applies here? | Load **principles.md** |
56
+
57
+ ## Gotchas
58
+
59
+ - **Repo conventions override book conventions**: Where the book's advice conflicts with this codebase's explicit conventions (e.g. `AGENTS.md`, `*.instructions.md`), prefer the repo convention and flag the discrepancy. For example: the book has no rule against `$` suffixes on Observables, but this repo explicitly forbids them.
60
+ - **Constants**: Clean Code does not mandate ALL_CAPS for constants. This repo explicitly uses camelCase for constants (e.g. `const maxRetries = 3`, not `const MAX_RETRIES = 3`).
61
+ - **Comments**: The default is no comment. See the Comments section of `AGENTS.md` before adding one — the tagging convention there applies only to comments that have already earned their place, and is never a reason to write one.
@@ -0,0 +1,114 @@
1
+ # Classes
2
+
3
+ Classes should be small and have a single responsibility.
4
+
5
+ > Source: Robert C. Martin, _Clean Code_ — Chapter 10: Classes
6
+
7
+ ## Rules
8
+
9
+ ### Class organization
10
+
11
+ Follow a consistent ordering within a class (adapted for TypeScript):
12
+
13
+ 1. Static properties
14
+ 2. Instance properties (public → protected → private)
15
+ 3. Constructor
16
+ 4. Framework lifecycle hooks (e.g. `ngOnInit`, `componentDidMount`), if the framework has them
17
+ 5. Public methods
18
+ 6. Private methods — **grouped by functionality**, not by access level. A private helper should appear directly below the public method that calls it.
19
+
20
+ ```typescript
21
+ // Good — private helpers are near their callers
22
+ class UserService {
23
+ doSomething1(): void {
24
+ this.task1();
25
+ this.task2();
26
+ }
27
+
28
+ private task1(): void {}
29
+ private task2(): void {}
30
+
31
+ doSomething2(): void {
32
+ this.task3();
33
+ }
34
+
35
+ private task3(): void {}
36
+ }
37
+ ```
38
+
39
+ ### Encapsulation
40
+
41
+ Prefer private members. Only expose what is needed. Sometimes a member must be `protected` for testability — that's acceptable.
42
+
43
+ ### Classes should be small
44
+
45
+ The name of a class should describe its responsibility. If you cannot derive a **concise name**, the class is likely too large. Names including `Manager`, `Processor`, `Super`, `Common`, `Helper` often hint at too many responsibilities.
46
+
47
+ You should be able to describe a class in about **25 words** without using "if", "and", "or", or "but".
48
+
49
+ ```typescript
50
+ // Bad — does too many unrelated things
51
+ class CommonUtils {
52
+ static toJson(obj: unknown): string {
53
+ /* ... */
54
+ }
55
+ static fromJson<T>(json: string): T {
56
+ /* ... */
57
+ }
58
+ static concat(delimiter: string, ...parts: string[]): string {
59
+ /* ... */
60
+ }
61
+ static isNotBlank(str: string): boolean {
62
+ /* ... */
63
+ }
64
+ static randomString(length: number): string {
65
+ /* ... */
66
+ }
67
+ }
68
+
69
+ // Good — each class has a single focus
70
+ class JsonUtils {
71
+ static toJson(obj: unknown): string {
72
+ /* ... */
73
+ }
74
+ static fromJson<T>(json: string): T {
75
+ /* ... */
76
+ }
77
+ }
78
+
79
+ class StringUtils {
80
+ static concat(delimiter: string, ...parts: string[]): string {
81
+ /* ... */
82
+ }
83
+ static isNotBlank(str: string): boolean {
84
+ /* ... */
85
+ }
86
+ }
87
+ ```
88
+
89
+ ### Avoid god classes
90
+
91
+ A god class concentrates too many responsibilities, controls too many objects, and does everything. Problems:
92
+
93
+ - Violates SOLID
94
+ - Makes code fragile
95
+ - Harms testability
96
+ - Harms performance
97
+ - Makes code harder to understand
98
+
99
+ ### Single Responsibility Principle (SRP)
100
+
101
+ A class should have **one, and only one, reason to change**. This is the most important principle for class design. See [principles.md](./principles.md) for the full SOLID breakdown.
102
+
103
+ ### Cohesion
104
+
105
+ Classes should be cohesive — a class's methods should manipulate its instance variables. The more variables a method uses, the more cohesive it is. When cohesion drops, split the class.
106
+
107
+ **High cohesion:** Every method uses most instance variables.
108
+ **Low cohesion:** Methods form separate groups that each touch different variables → split into multiple classes.
109
+
110
+ ### Follow SOLID principles and design patterns
111
+
112
+ - **SOLID**: SRP, OCP, LSP, ISP, DIP — see [principles.md](./principles.md)
113
+ - **Law of Demeter**: Don't chain calls through collaborators — see [objects-and-data-structures.md](./objects-and-data-structures.md)
114
+ - **Design Patterns**: Use established patterns (Strategy, Observer, Factory, etc.) when they simplify the design
@@ -0,0 +1,164 @@
1
+ # Comments
2
+
3
+ **Comments are the exception, not the rule.** Do not write comments. The code must speak for itself.
4
+
5
+ > Source: Robert C. Martin, _Clean Code_ — Chapter 4: Comments
6
+
7
+ ## The Rule (non-negotiable)
8
+
9
+ **An LLM MUST NOT add any explanatory comment to code without explicit user approval.**
10
+
11
+ Before adding any comment that explains intent, clarifies, or warns, the LLM must:
12
+ 1. Stop
13
+ 2. Ask the user: "I want to add a comment explaining [reason]. Is this OK?"
14
+ 3. Wait for explicit user confirmation
15
+ 4. Only then proceed
16
+
17
+ This is human-in-the-loop. No exceptions.
18
+
19
+ ## When a Comment is Allowed (only if user approves)
20
+
21
+ ### Legal comments
22
+
23
+ Copyright and licensing notices required by corporate standards. These do not require user approval as they are non-negotiable legal requirements.
24
+
25
+ ### Explanation of intent (requires user approval)
26
+
27
+ Only when the **why** cannot be expressed in code and the cost of misunderstanding is severe.
28
+
29
+ ```typescript
30
+ /**
31
+ * AI COMMENT: We use a large number of concurrent requests here
32
+ * to stress-test the race condition we observed in production.
33
+ * @author AI Assistant
34
+ */
35
+ ```
36
+
37
+ ### Warning of consequences (requires user approval)
38
+
39
+ Only when the consequence is non-obvious and severe (security, data loss, production outage).
40
+
41
+ ### TODO comments (requires user approval)
42
+
43
+ Only for critical work that blocks progress. Prefer creating a tracked issue instead.
44
+
45
+ ### JSDoc for public APIs (requires user approval)
46
+
47
+ Only for the public API a domain exposes to other domains — not for internal code.
48
+
49
+ ## When a Comment is NEVER Allowed
50
+
51
+ ### Redundant comments
52
+
53
+ A comment that describes something the code already describes itself.
54
+
55
+ ```typescript
56
+ // Bad — the name already says it
57
+ /** Create a directory */
58
+ function createDirectory(name: string): void {}
59
+
60
+ // Bad — property names are self-documenting
61
+ interface ContainerBase {
62
+ /** The background processor delay for this component. */
63
+ backgroundProcessorDelay: number;
64
+ }
65
+ ```
66
+
67
+ ### Misleading comments
68
+
69
+ Comments that don't accurately describe the code's behavior. A reader who believes the comment may misuse the function.
70
+
71
+ ### Mandated comments
72
+
73
+ Rules that force a JSDoc on every function/variable just clutter the code. Only document what adds value.
74
+
75
+ ### Journal comments
76
+
77
+ Change logs at the top of files. Source control handles this — remove them.
78
+
79
+ ### Noise comments
80
+
81
+ Comments that restate the obvious add no value.
82
+
83
+ ```typescript
84
+ // Bad
85
+ /** Default constructor. */
86
+ constructor() {}
87
+
88
+ /** The day of the month. */
89
+ private dayOfMonth: number;
90
+
91
+ /** Returns the day of the month. */
92
+ getDayOfMonth(): number { return this.dayOfMonth; }
93
+ ```
94
+
95
+ ### Use a function or variable instead of a comment
96
+
97
+ If you need a comment to explain a complex expression, extract it into a well-named variable or function.
98
+
99
+ ```typescript
100
+ // Bad
101
+ // does the module from the global list depend on the subsystem we are part of?
102
+ if (smodule.getDependSubsystems().includes(subSysMod.getSubSystem())) {
103
+ }
104
+
105
+ // Good
106
+ const moduleDependees = smodule.getDependSubsystems();
107
+ const ourSubSystem = subSysMod.getSubSystem();
108
+ if (moduleDependees.includes(ourSubSystem)) {
109
+ }
110
+ ```
111
+
112
+ ### Position markers / section dividers
113
+
114
+ ```typescript
115
+ // Bad
116
+ /////////////////////////////////////////////////
117
+ // PROPERTIES, PRIVATE AND PROTECTED
118
+ /////////////////////////////////////////////////
119
+ ```
120
+
121
+ These are clutter. If your class is so large it needs section dividers, the class is too large.
122
+
123
+ ### Closing brace comments
124
+
125
+ If you need to mark closing braces, shorten your functions instead.
126
+
127
+ ### HTML in comments
128
+
129
+ Makes comments hard to read in the editor. Avoid.
130
+
131
+ ### Commented-out code
132
+
133
+ **Delete it.** Source control remembers. Commented-out code accumulates and no one dares to delete it because they assume someone needed it.
134
+
135
+ ### Too much information
136
+
137
+ Don't put historical discussions, RFCs, or irrelevant technical details in comments.
138
+
139
+ ### Function headers that duplicate the name
140
+
141
+ A well-named small function doesn't need a comment header.
142
+
143
+ ```typescript
144
+ // Bad
145
+ /** Save product only, if not a product throw a ClassCastException */
146
+ function save(obj: unknown): void {}
147
+
148
+ // Good
149
+ function saveProduct(product: Product): void {}
150
+ ```
151
+
152
+ ### Systemwide information in local comments
153
+
154
+ A comment should describe the code near it, not global configuration or defaults defined elsewhere.
155
+
156
+ ## The Test
157
+
158
+ If you can name a function, variable, or type to make the code clear, **do that instead of commenting.**
159
+
160
+ If the comment explains **what** the code does, **delete it.**
161
+
162
+ If the comment does not explain a **why** that cannot be expressed in code, **delete it.**
163
+
164
+ If you are an LLM and did not ask the user before adding an explanatory comment, **you violated this rule.**