limbo-code 0.1.0__tar.gz

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 (104) hide show
  1. limbo_code-0.1.0/.agents/skills/grill-with-docs/SKILL.md +7 -0
  2. limbo_code-0.1.0/.agents/skills/grill-with-docs/agents/openai.yaml +5 -0
  3. limbo_code-0.1.0/.agents/skills/improve-codebase-architecture/HTML-REPORT.md +123 -0
  4. limbo_code-0.1.0/.agents/skills/improve-codebase-architecture/SKILL.md +71 -0
  5. limbo_code-0.1.0/.agents/skills/improve-codebase-architecture/agents/openai.yaml +5 -0
  6. limbo_code-0.1.0/.agents/skills/tdd/SKILL.md +36 -0
  7. limbo_code-0.1.0/.agents/skills/tdd/agents/openai.yaml +3 -0
  8. limbo_code-0.1.0/.agents/skills/tdd/mocking.md +59 -0
  9. limbo_code-0.1.0/.agents/skills/tdd/tests.md +77 -0
  10. limbo_code-0.1.0/.github/workflows/publish.yml +49 -0
  11. limbo_code-0.1.0/.github/workflows/test.yml +30 -0
  12. limbo_code-0.1.0/.gitignore +13 -0
  13. limbo_code-0.1.0/AGENTS.md +183 -0
  14. limbo_code-0.1.0/PKG-INFO +16 -0
  15. limbo_code-0.1.0/README.md +154 -0
  16. limbo_code-0.1.0/design/confirm_view.html +137 -0
  17. limbo_code-0.1.0/design/limbo-ui-minimal.md +345 -0
  18. limbo_code-0.1.0/design/limbo-ui-redesign.md +529 -0
  19. limbo_code-0.1.0/design/prototype-minimal-confirm.png +0 -0
  20. limbo_code-0.1.0/design/prototype-minimal.html +710 -0
  21. limbo_code-0.1.0/design/prototype-minimal.png +0 -0
  22. limbo_code-0.1.0/design/prototype.html +923 -0
  23. limbo_code-0.1.0/design/prototype.png +0 -0
  24. limbo_code-0.1.0/docs/assets/limbo-current-ui.png +0 -0
  25. limbo_code-0.1.0/docs/assets/limbo-new-ui.png +0 -0
  26. limbo_code-0.1.0/docs/session-management.md +124 -0
  27. limbo_code-0.1.0/docs/skills.md +49 -0
  28. limbo_code-0.1.0/docs/ui-redesign-proposal.md +108 -0
  29. limbo_code-0.1.0/pyproject.toml +44 -0
  30. limbo_code-0.1.0/skills-lock.json +23 -0
  31. limbo_code-0.1.0/src/limbo/__init__.py +3 -0
  32. limbo_code-0.1.0/src/limbo/__main__.py +6 -0
  33. limbo_code-0.1.0/src/limbo/agent.py +456 -0
  34. limbo_code-0.1.0/src/limbo/app.py +107 -0
  35. limbo_code-0.1.0/src/limbo/config.py +99 -0
  36. limbo_code-0.1.0/src/limbo/history.py +90 -0
  37. limbo_code-0.1.0/src/limbo/llm/__init__.py +1 -0
  38. limbo_code-0.1.0/src/limbo/llm/anthropic_client.py +320 -0
  39. limbo_code-0.1.0/src/limbo/llm/catalog.py +234 -0
  40. limbo_code-0.1.0/src/limbo/llm/client.py +21 -0
  41. limbo_code-0.1.0/src/limbo/llm/factory.py +46 -0
  42. limbo_code-0.1.0/src/limbo/llm/openai_client.py +261 -0
  43. limbo_code-0.1.0/src/limbo/models.py +81 -0
  44. limbo_code-0.1.0/src/limbo/sessions.py +258 -0
  45. limbo_code-0.1.0/src/limbo/skills.py +89 -0
  46. limbo_code-0.1.0/src/limbo/tools/__init__.py +1 -0
  47. limbo_code-0.1.0/src/limbo/tools/base.py +102 -0
  48. limbo_code-0.1.0/src/limbo/tools/bash.py +172 -0
  49. limbo_code-0.1.0/src/limbo/tools/edit.py +70 -0
  50. limbo_code-0.1.0/src/limbo/tools/find.py +71 -0
  51. limbo_code-0.1.0/src/limbo/tools/grep.py +182 -0
  52. limbo_code-0.1.0/src/limbo/tools/ignore.py +111 -0
  53. limbo_code-0.1.0/src/limbo/tools/ls.py +41 -0
  54. limbo_code-0.1.0/src/limbo/tools/read.py +105 -0
  55. limbo_code-0.1.0/src/limbo/tools/registry.py +66 -0
  56. limbo_code-0.1.0/src/limbo/tools/write.py +34 -0
  57. limbo_code-0.1.0/src/limbo/trace.py +100 -0
  58. limbo_code-0.1.0/src/limbo/ui/__init__.py +1 -0
  59. limbo_code-0.1.0/src/limbo/ui/app.py +52 -0
  60. limbo_code-0.1.0/src/limbo/ui/app.tcss +174 -0
  61. limbo_code-0.1.0/src/limbo/ui/banner.py +83 -0
  62. limbo_code-0.1.0/src/limbo/ui/commands.py +61 -0
  63. limbo_code-0.1.0/src/limbo/ui/screens/__init__.py +1 -0
  64. limbo_code-0.1.0/src/limbo/ui/screens/game2048.py +213 -0
  65. limbo_code-0.1.0/src/limbo/ui/screens/main.py +369 -0
  66. limbo_code-0.1.0/src/limbo/ui/screens/session_picker.py +59 -0
  67. limbo_code-0.1.0/src/limbo/ui/widgets/__init__.py +1 -0
  68. limbo_code-0.1.0/src/limbo/ui/widgets/chat.py +149 -0
  69. limbo_code-0.1.0/src/limbo/ui/widgets/command_menu.py +45 -0
  70. limbo_code-0.1.0/src/limbo/ui/widgets/input.py +199 -0
  71. limbo_code-0.1.0/src/limbo/ui/widgets/status_bar.py +32 -0
  72. limbo_code-0.1.0/src/limbo/ui/widgets/tool_card.py +179 -0
  73. limbo_code-0.1.0/tests/test_agent.py +729 -0
  74. limbo_code-0.1.0/tests/test_anthropic_client.py +331 -0
  75. limbo_code-0.1.0/tests/test_catalog.py +160 -0
  76. limbo_code-0.1.0/tests/test_cli.py +163 -0
  77. limbo_code-0.1.0/tests/test_config.py +83 -0
  78. limbo_code-0.1.0/tests/test_history.py +80 -0
  79. limbo_code-0.1.0/tests/test_integration.py +37 -0
  80. limbo_code-0.1.0/tests/test_llm_client.py +383 -0
  81. limbo_code-0.1.0/tests/test_models.py +23 -0
  82. limbo_code-0.1.0/tests/test_sessions.py +276 -0
  83. limbo_code-0.1.0/tests/test_skills.py +89 -0
  84. limbo_code-0.1.0/tests/test_trace.py +70 -0
  85. limbo_code-0.1.0/tests/tools/test_base.py +85 -0
  86. limbo_code-0.1.0/tests/tools/test_bash.py +223 -0
  87. limbo_code-0.1.0/tests/tools/test_edit.py +130 -0
  88. limbo_code-0.1.0/tests/tools/test_find.py +103 -0
  89. limbo_code-0.1.0/tests/tools/test_grep.py +138 -0
  90. limbo_code-0.1.0/tests/tools/test_ignore.py +53 -0
  91. limbo_code-0.1.0/tests/tools/test_ls.py +51 -0
  92. limbo_code-0.1.0/tests/tools/test_read.py +156 -0
  93. limbo_code-0.1.0/tests/tools/test_registry.py +63 -0
  94. limbo_code-0.1.0/tests/tools/test_write.py +63 -0
  95. limbo_code-0.1.0/tests/ui/test_app_smoke.py +31 -0
  96. limbo_code-0.1.0/tests/ui/test_command_menu.py +210 -0
  97. limbo_code-0.1.0/tests/ui/test_commands.py +68 -0
  98. limbo_code-0.1.0/tests/ui/test_game2048.py +277 -0
  99. limbo_code-0.1.0/tests/ui/test_input_history.py +222 -0
  100. limbo_code-0.1.0/tests/ui/test_main_screen.py +150 -0
  101. limbo_code-0.1.0/tests/ui/test_sessions_ui.py +219 -0
  102. limbo_code-0.1.0/tests/ui/test_skills_ui.py +174 -0
  103. limbo_code-0.1.0/tests/ui/test_startup_art.py +94 -0
  104. limbo_code-0.1.0/tests/ui/test_widgets.py +198 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ name: grill-with-docs
3
+ description: A relentless interview to sharpen a plan or design, which also creates docs (ADR's and glossary) as we go.
4
+ disable-model-invocation: true
5
+ ---
6
+
7
+ Run a `/grilling` session, using the `/domain-modeling` skill.
@@ -0,0 +1,5 @@
1
+ interface:
2
+ display_name: "Grill with Docs"
3
+ short_description: "Grill a design and write its docs"
4
+ policy:
5
+ allow_implicit_invocation: false
@@ -0,0 +1,123 @@
1
+ # HTML Report Format
2
+
3
+ The architectural review is rendered as a single self-contained HTML file in the OS temp directory. Tailwind and Mermaid both come from CDNs. Mermaid handles graph-shaped diagrams reliably; hand-built divs and inline SVG handle the more editorial visuals (mass diagrams, cross-sections). Mix the two — don't lean on Mermaid for everything, it'll start to look generic.
4
+
5
+ ## Scaffold
6
+
7
+ ```html
8
+ <!doctype html>
9
+ <html lang="en">
10
+ <head>
11
+ <meta charset="utf-8" />
12
+ <title>Architecture review — {{repo name}}</title>
13
+ <script src="https://cdn.tailwindcss.com"></script>
14
+ <script type="module">
15
+ import mermaid from "https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs";
16
+ mermaid.initialize({ startOnLoad: true, theme: "neutral", securityLevel: "loose" });
17
+ </script>
18
+ <style>
19
+ /* small custom layer for things Tailwind doesn't cover cleanly:
20
+ dashed seam lines, hand-drawn-feeling arrow heads, etc. */
21
+ .seam { stroke-dasharray: 4 4; }
22
+ .leak { stroke: #dc2626; }
23
+ .deep { background: linear-gradient(135deg, #0f172a, #1e293b); }
24
+ </style>
25
+ </head>
26
+ <body class="bg-stone-50 text-slate-900 font-sans">
27
+ <main class="max-w-5xl mx-auto px-6 py-12 space-y-12">
28
+ <header>...</header>
29
+ <section id="candidates" class="space-y-10">...</section>
30
+ <section id="top-recommendation">...</section>
31
+ </main>
32
+ </body>
33
+ </html>
34
+ ```
35
+
36
+ ## Header
37
+
38
+ Repo name, date, and a compact legend: solid box = module, dashed line = seam, red arrow = leakage, thick dark box = deep module. No introduction paragraph — straight into the candidates.
39
+
40
+ ## Candidate card
41
+
42
+ The diagrams carry the weight. Prose is sparse, plain, and uses the glossary terms (from the `/codebase-design` skill) without ceremony.
43
+
44
+ Each candidate is one `<article>`:
45
+
46
+ - **Title** — short, names the deepening (e.g. "Collapse the Order intake pipeline").
47
+ - **Badge row** — recommendation strength (`Strong` = emerald, `Worth exploring` = amber, `Speculative` = slate), plus a tag for the dependency category (`in-process`, `local-substitutable`, `ports & adapters`, `mock`).
48
+ - **Files** — monospaced list, `font-mono text-sm`.
49
+ - **Before / After diagram** — the centrepiece. Two columns, side by side. See patterns below.
50
+ - **Problem** — one sentence. What hurts.
51
+ - **Solution** — one sentence. What changes.
52
+ - **Wins** — bullets, ≤6 words each. e.g. "Tests hit one interface", "Pricing logic stops leaking", "Delete 4 shallow wrappers".
53
+ - **ADR callout** (if applicable) — one line in an amber-tinted box.
54
+
55
+ No paragraphs of explanation. If the diagram needs a paragraph to be understood, redraw the diagram.
56
+
57
+ ## Diagram patterns
58
+
59
+ Pick the pattern that fits the candidate. Mix them. Don't make every diagram look the same — variety is part of the point.
60
+
61
+ ### Mermaid graph (the workhorse for dependencies / call flow)
62
+
63
+ Use a Mermaid `flowchart` or `graph` when the point is "X calls Y calls Z, and look at the mess." Wrap it in a Tailwind-styled card so it doesn't feel parachuted in. Style with classDef to colour leakage edges red and the deep module dark. Sequence diagrams work well for "before: 6 round-trips; after: 1."
64
+
65
+ ```html
66
+ <div class="rounded-lg border border-slate-200 bg-white p-4">
67
+ <pre class="mermaid">
68
+ flowchart LR
69
+ A[OrderHandler] --> B[OrderValidator]
70
+ B --> C[OrderRepo]
71
+ C -.leak.-> D[PricingClient]
72
+ classDef leak stroke:#dc2626,stroke-width:2px;
73
+ class C,D leak
74
+ </pre>
75
+ </div>
76
+ ```
77
+
78
+ ### Hand-built boxes-and-arrows (when Mermaid's layout fights you)
79
+
80
+ Modules as `<div>`s with borders and labels. Arrows as inline SVG `<line>` or `<path>` elements positioned absolutely over a relative container. Reach for this when you want the "after" diagram to feel like one thick-bordered deep module with greyed-out internals — Mermaid won't render that with the right weight.
81
+
82
+ ### Cross-section (good for layered shallowness)
83
+
84
+ Stack horizontal bands (`h-12 border-l-4`) to show layers a call passes through. Before: 6 thin layers each doing nothing. After: 1 thick band labelled with the consolidated responsibility.
85
+
86
+ ### Mass diagram (good for "interface as wide as implementation")
87
+
88
+ Two rectangles per module — one for interface surface area, one for implementation. Before: interface rectangle is nearly as tall as the implementation rectangle (shallow). After: interface rectangle is short, implementation rectangle is tall (deep).
89
+
90
+ ### Call-graph collapse
91
+
92
+ Before: a tree of function calls rendered as nested boxes. After: the same tree collapsed into one box, with the now-internal calls shown faded inside it.
93
+
94
+ ## Style guidance
95
+
96
+ - Lean editorial, not corporate-dashboard. Generous whitespace. Serif optional for headings (`font-serif` works well with stone/slate).
97
+ - Colour sparingly: one accent (emerald or indigo) plus red for leakage and amber for warnings.
98
+ - Keep diagrams ~320px tall so before/after sits comfortably side by side without scrolling.
99
+ - Use `text-xs uppercase tracking-wider` for module labels inside diagrams — they should read as schematic, not as UI.
100
+ - The only scripts are the Tailwind CDN and the Mermaid ESM import. The report is otherwise static — no app code, no interactivity beyond Mermaid's own rendering.
101
+
102
+ ## Top recommendation section
103
+
104
+ One larger card. Candidate name, one sentence on why, anchor link to its card. That's it.
105
+
106
+ ## Tone
107
+
108
+ Plain English, concise — but the architectural nouns and verbs come straight from the `/codebase-design` skill. Concision is not an excuse to drift.
109
+
110
+ **Use exactly:** module, interface, implementation, depth, deep, shallow, seam, adapter, leverage, locality.
111
+
112
+ **Never substitute:** component, service, unit (for module) · API, signature (for interface) · boundary (for seam) · layer, wrapper (for module, when you mean module).
113
+
114
+ **Phrasings that fit the style:**
115
+
116
+ - "Order intake module is shallow — interface nearly matches the implementation."
117
+ - "Pricing leaks across the seam."
118
+ - "Deepen: one interface, one place to test."
119
+ - "Two adapters justify the seam: HTTP in prod, in-memory in tests."
120
+
121
+ **Wins bullets** name the gain in glossary terms: *"locality: bugs concentrate in one module"*, *"leverage: one interface, N call sites"*, *"interface shrinks; implementation absorbs the wrappers"*. Don't write *"easier to maintain"* or *"cleaner code"* — those terms aren't in the glossary and don't earn their place.
122
+
123
+ No hedging, no throat-clearing, no "it's worth noting that…". If a sentence could be a bullet, make it a bullet. If a bullet could be cut, cut it. If a term isn't in the `/codebase-design` glossary, reach for one that is before inventing a new one.
@@ -0,0 +1,71 @@
1
+ ---
2
+ name: improve-codebase-architecture
3
+ description: Scan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick.
4
+ disable-model-invocation: true
5
+ ---
6
+
7
+ # Improve Codebase Architecture
8
+
9
+ Surface architectural friction and propose **deepening opportunities** — refactors that turn shallow modules into deep ones. The aim is testability and AI-navigability.
10
+
11
+ This command is _informed_ by the project's domain model and built on a shared design vocabulary:
12
+
13
+ - Run the `/codebase-design` skill for the architecture vocabulary (**module**, **interface**, **depth**, **seam**, **adapter**, **leverage**, **locality**) and its principles (the deletion test, "the interface is the test surface", "one adapter = hypothetical seam, two = real"). Use these terms exactly in every suggestion — don't drift into "component," "service," "API," or "boundary."
14
+ - The domain language in `CONTEXT.md` gives names to good seams; ADRs in `docs/adr/` record decisions this command should not re-litigate.
15
+
16
+ ## Process
17
+
18
+ ### 1. Explore
19
+
20
+ **Scope before you scan — YAGNI.** Deepening a module pays off by making future changes to it easier, so put extra weight on the parts of the codebase that have recently changed. Decide *where* to look before you look:
21
+
22
+ - If the user named a direction — a module, a subsystem, a pain point — take it, and skip the inference below.
23
+ - Otherwise, walk back a good stretch of the commit history (`git log --oneline`) to find the codebase's hot spots — the files and areas that keep coming up — and let those paths pull your attention first. If the changes are scattered with no clear hot spot, widen the net.
24
+
25
+ Read the project's domain glossary (`CONTEXT.md`) and any ADRs in the area you're touching first.
26
+
27
+ Then use the Agent tool with `subagent_type=Explore` to walk the codebase. Don't follow rigid heuristics — explore organically and note where you experience friction:
28
+
29
+ - Where does understanding one concept require bouncing between many small modules?
30
+ - Where are modules **shallow** — interface nearly as complex as the implementation?
31
+ - Where have pure functions been extracted just for testability, but the real bugs hide in how they're called (no **locality**)?
32
+ - Where do tightly-coupled modules leak across their seams?
33
+ - Which parts of the codebase are untested, or hard to test through their current interface?
34
+
35
+ Apply the **deletion test** to anything you suspect is shallow: would deleting it concentrate complexity, or just move it? A "yes, concentrates" is the signal you want.
36
+
37
+ ### 2. Present candidates as an HTML report
38
+
39
+ Write a self-contained HTML file to the OS temp directory so nothing lands in the repo. Resolve the temp dir from `$TMPDIR`, falling back to `/tmp` (or `%TEMP%` on Windows), and write to `<tmpdir>/architecture-review-<timestamp>.html` so each run gets a fresh file. Open it for the user — `xdg-open <path>` on Linux, `open <path>` on macOS, `start <path>` on Windows — and tell them the absolute path.
40
+
41
+ The report uses **Tailwind via CDN** for layout and styling, and **Mermaid via CDN** for diagrams where a graph/flow/sequence reliably communicates the structure. Mix Mermaid with hand-crafted CSS/SVG visuals — use Mermaid when relationships are graph-shaped (call graphs, dependencies, sequences), and hand-built divs/SVG when you want something more editorial (mass diagrams, cross-sections, collapse animations). Each candidate gets a **before/after visualisation**. Be visual.
42
+
43
+ For each candidate, render a card with:
44
+
45
+ - **Files** — which files/modules are involved
46
+ - **Problem** — why the current architecture is causing friction
47
+ - **Solution** — plain English description of what would change
48
+ - **Benefits** — explained in terms of locality and leverage, and how tests would improve
49
+ - **Before / After diagram** — side-by-side, custom-drawn, illustrating the shallowness and the deepening
50
+ - **Recommendation strength** — one of `Strong`, `Worth exploring`, `Speculative`, rendered as a badge
51
+
52
+ End the report with a **Top recommendation** section: which candidate you'd tackle first and why.
53
+
54
+ **Use CONTEXT.md vocabulary for the domain, and the `/codebase-design` vocabulary for the architecture.** If `CONTEXT.md` defines "Order," talk about "the Order intake module" — not "the FooBarHandler," and not "the Order service."
55
+
56
+ **ADR conflicts**: if a candidate contradicts an existing ADR, only surface it when the friction is real enough to warrant revisiting the ADR. Mark it clearly in the card (e.g. a warning callout: _"contradicts ADR-0007 — but worth reopening because…"_). Don't list every theoretical refactor an ADR forbids.
57
+
58
+ See [HTML-REPORT.md](HTML-REPORT.md) for the full HTML scaffold, diagram patterns, and styling guidance.
59
+
60
+ Do NOT propose interfaces yet. After the file is written, ask the user: "Which of these would you like to explore?"
61
+
62
+ ### 3. Grilling loop
63
+
64
+ Once the user picks a candidate, run the `/grilling` skill to walk the decision tree with them — constraints, dependencies, the shape of the deepened module, what sits behind the seam, what tests survive.
65
+
66
+ Side effects happen inline as decisions crystallize — run the `/domain-modeling` skill to keep the domain model current as you go:
67
+
68
+ - **Naming a deepened module after a concept not in `CONTEXT.md`?** Add the term to `CONTEXT.md`. Create the file lazily if it doesn't exist.
69
+ - **Sharpening a fuzzy term during the conversation?** Update `CONTEXT.md` right there.
70
+ - **User rejects the candidate with a load-bearing reason?** Offer an ADR, framed as: _"Want me to record this as an ADR so future architecture reviews don't re-suggest it?"_ Only offer when the reason would actually be needed by a future explorer to avoid re-suggesting the same thing — skip ephemeral reasons ("not worth it right now") and self-evident ones.
71
+ - **Want to explore alternative interfaces for the deepened module?** Run the `/codebase-design` skill and use its design-it-twice parallel sub-agent pattern.
@@ -0,0 +1,5 @@
1
+ interface:
2
+ display_name: "Improve Codebase Architecture"
3
+ short_description: "Find and grill architecture improvements"
4
+ policy:
5
+ allow_implicit_invocation: false
@@ -0,0 +1,36 @@
1
+ ---
2
+ name: tdd
3
+ description: Test-driven development. Use when the user wants to build features or fix bugs test-first, mentions "red-green-refactor", or wants integration tests.
4
+ ---
5
+
6
+ # Test-Driven Development
7
+
8
+ TDD is the red → green loop. This skill is the reference that makes that loop produce tests worth keeping: what a good test is, where tests go, the anti-patterns, and the rules of the loop. Every section applies on every cycle — consult them before and during the loop, not after.
9
+
10
+ When exploring the codebase, read `CONTEXT.md` (if it exists) so test names and interface vocabulary match the project's domain language, and respect ADRs in the area you're touching.
11
+
12
+ ## What a good test is
13
+
14
+ Tests verify behavior through public interfaces, not implementation details. Code can change entirely; tests shouldn't. A good test reads like a specification — "user can checkout with valid cart" tells you exactly what capability exists — and survives refactors because it doesn't care about internal structure.
15
+
16
+ See [tests.md](tests.md) for examples and [mocking.md](mocking.md) for mocking guidelines.
17
+
18
+ ## Seams — where tests go
19
+
20
+ A **seam** is the public boundary you test at: the interface where you observe behavior without reaching inside. Tests live at seams, never against internals.
21
+
22
+ **Test only at pre-agreed seams.** Before writing any test, write down the seams under test and confirm them with the user. No test is written at an unconfirmed seam. You can't test everything — agreeing the seams up front is how testing effort lands on the critical paths and complex logic instead of every edge case.
23
+
24
+ Ask: "What's the public interface, and which seams should we test?"
25
+
26
+ ## Anti-patterns
27
+
28
+ - **Implementation-coupled** — mocks internal collaborators, tests private methods, or verifies through a side channel (querying the database instead of using the interface). The tell: the test breaks when you refactor but behavior hasn't changed.
29
+ - **Tautological** — the assertion recomputes the expected value the way the code does (`expect(add(a, b)).toBe(a + b)`, a snapshot derived by hand the same way, a constant asserted equal to itself), so it passes by construction and can never disagree with the code. Expected values must come from an independent source of truth — a known-good literal, a worked example, the spec.
30
+ - **Horizontal slicing** — writing all tests first, then all implementation. Bulk tests verify _imagined_ behavior: you test the _shape_ of things rather than user-facing behavior, the tests go insensitive to real changes, and you commit to test structure before understanding the implementation. Work in **vertical slices** instead — one test → one implementation → repeat, each test a **tracer bullet** that responds to what the last cycle taught you.
31
+
32
+ ## Rules of the loop
33
+
34
+ - **Red before green.** Write the failing test first, then only enough code to pass it. Don't anticipate future tests or add speculative features.
35
+ - **One slice at a time.** One seam, one test, one minimal implementation per cycle.
36
+ - **Refactoring is not part of the loop.** It belongs to the review stage (see the `code-review` skill), not the red → green implementation cycle.
@@ -0,0 +1,3 @@
1
+ interface:
2
+ display_name: "TDD"
3
+ short_description: "Test-driven red-green-refactor"
@@ -0,0 +1,59 @@
1
+ # When to Mock
2
+
3
+ Mock at **system boundaries** only:
4
+
5
+ - External APIs (payment, email, etc.)
6
+ - Databases (sometimes - prefer test DB)
7
+ - Time/randomness
8
+ - File system (sometimes)
9
+
10
+ Don't mock:
11
+
12
+ - Your own classes/modules
13
+ - Internal collaborators
14
+ - Anything you control
15
+
16
+ ## Designing for Mockability
17
+
18
+ At system boundaries, design interfaces that are easy to mock:
19
+
20
+ **1. Use dependency injection**
21
+
22
+ Pass external dependencies in rather than creating them internally:
23
+
24
+ ```typescript
25
+ // Easy to mock
26
+ function processPayment(order, paymentClient) {
27
+ return paymentClient.charge(order.total);
28
+ }
29
+
30
+ // Hard to mock
31
+ function processPayment(order) {
32
+ const client = new StripeClient(process.env.STRIPE_KEY);
33
+ return client.charge(order.total);
34
+ }
35
+ ```
36
+
37
+ **2. Prefer SDK-style interfaces over generic fetchers**
38
+
39
+ Create specific functions for each external operation instead of one generic function with conditional logic:
40
+
41
+ ```typescript
42
+ // GOOD: Each function is independently mockable
43
+ const api = {
44
+ getUser: (id) => fetch(`/users/${id}`),
45
+ getOrders: (userId) => fetch(`/users/${userId}/orders`),
46
+ createOrder: (data) => fetch('/orders', { method: 'POST', body: data }),
47
+ };
48
+
49
+ // BAD: Mocking requires conditional logic inside the mock
50
+ const api = {
51
+ fetch: (endpoint, options) => fetch(endpoint, options),
52
+ };
53
+ ```
54
+
55
+ The SDK approach means:
56
+ - Each mock returns one specific shape
57
+ - No conditional logic in test setup
58
+ - Easier to see which endpoints a test exercises
59
+ - Type safety per endpoint
@@ -0,0 +1,77 @@
1
+ # Good and Bad Tests
2
+
3
+ ## Good Tests
4
+
5
+ **Integration-style**: Test through real interfaces, not mocks of internal parts.
6
+
7
+ ```typescript
8
+ // GOOD: Tests observable behavior
9
+ test("user can checkout with valid cart", async () => {
10
+ const cart = createCart();
11
+ cart.add(product);
12
+ const result = await checkout(cart, paymentMethod);
13
+ expect(result.status).toBe("confirmed");
14
+ });
15
+ ```
16
+
17
+ Characteristics:
18
+
19
+ - Tests behavior users/callers care about
20
+ - Uses public API only
21
+ - Survives internal refactors
22
+ - Describes WHAT, not HOW
23
+ - One logical assertion per test
24
+
25
+ ## Bad Tests
26
+
27
+ **Implementation-detail tests**: Coupled to internal structure.
28
+
29
+ ```typescript
30
+ // BAD: Tests implementation details
31
+ test("checkout calls paymentService.process", async () => {
32
+ const mockPayment = jest.mock(paymentService);
33
+ await checkout(cart, payment);
34
+ expect(mockPayment.process).toHaveBeenCalledWith(cart.total);
35
+ });
36
+ ```
37
+
38
+ Red flags:
39
+
40
+ - Mocking internal collaborators
41
+ - Testing private methods
42
+ - Asserting on call counts/order
43
+ - Test breaks when refactoring without behavior change
44
+ - Test name describes HOW not WHAT
45
+ - Verifying through external means instead of interface
46
+
47
+ ```typescript
48
+ // BAD: Bypasses interface to verify
49
+ test("createUser saves to database", async () => {
50
+ await createUser({ name: "Alice" });
51
+ const row = await db.query("SELECT * FROM users WHERE name = ?", ["Alice"]);
52
+ expect(row).toBeDefined();
53
+ });
54
+
55
+ // GOOD: Verifies through interface
56
+ test("createUser makes user retrievable", async () => {
57
+ const user = await createUser({ name: "Alice" });
58
+ const retrieved = await getUser(user.id);
59
+ expect(retrieved.name).toBe("Alice");
60
+ });
61
+ ```
62
+
63
+ **Tautological tests**: Expected value restates the implementation, so the test passes by construction.
64
+
65
+ ```typescript
66
+ // BAD: Expected value is recomputed the way the code computes it
67
+ test("calculateTotal sums line items", () => {
68
+ const items = [{ price: 10 }, { price: 5 }];
69
+ const expected = items.reduce((sum, i) => sum + i.price, 0);
70
+ expect(calculateTotal(items)).toBe(expected);
71
+ });
72
+
73
+ // GOOD: Expected value is an independent, known literal
74
+ test("calculateTotal sums line items", () => {
75
+ expect(calculateTotal([{ price: 10 }, { price: 5 }])).toBe(15);
76
+ });
77
+ ```
@@ -0,0 +1,49 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ jobs:
9
+ build:
10
+ name: Build sdist and wheel
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+
15
+ - name: Set up Python
16
+ uses: actions/setup-python@v5
17
+ with:
18
+ python-version: "3.12"
19
+
20
+ - name: Install build tooling
21
+ run: pip install build
22
+
23
+ - name: Build distributions
24
+ run: python -m build
25
+
26
+ - name: Upload artifacts
27
+ uses: actions/upload-artifact@v4
28
+ with:
29
+ name: dist
30
+ path: dist/
31
+
32
+ publish:
33
+ name: Publish to PyPI (Trusted Publishing / OIDC)
34
+ needs: build
35
+ runs-on: ubuntu-latest
36
+ environment:
37
+ name: pypi
38
+ url: https://pypi.org/p/limbo-code
39
+ permissions:
40
+ id-token: write # required for PyPI Trusted Publishing (OIDC)
41
+ steps:
42
+ - name: Download artifacts
43
+ uses: actions/download-artifact@v4
44
+ with:
45
+ name: dist
46
+ path: dist/
47
+
48
+ - name: Publish to PyPI
49
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,30 @@
1
+ name: Test
2
+
3
+ on:
4
+ pull_request:
5
+ branches: [main]
6
+ push:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ pytest:
11
+ name: pytest (Python ${{ matrix.python-version }})
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ python-version: ["3.11", "3.12"]
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+
20
+ - name: Set up Python
21
+ uses: actions/setup-python@v5
22
+ with:
23
+ python-version: ${{ matrix.python-version }}
24
+ cache: pip
25
+
26
+ - name: Install dependencies
27
+ run: pip install -e ".[dev]"
28
+
29
+ - name: Run tests
30
+ run: python -m pytest -v
@@ -0,0 +1,13 @@
1
+ .worktrees/
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ .venv/
6
+ venv/
7
+ .env
8
+ .mypy_cache/
9
+ .ruff_cache/
10
+ .pytest_cache/
11
+ dist/
12
+ build/
13
+ .pi-subagents/