codewhale.history 2.8.13 → 2.9.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.
- package/README.md +20 -3
- package/package.json +1 -1
- package/skills/teach-me/SKILL.md +185 -14
package/README.md
CHANGED
|
@@ -78,11 +78,13 @@ Git already has your back.
|
|
|
78
78
|
|
|
79
79
|
### `//teach-me`
|
|
80
80
|
An interactive code-teaching quiz that randomly selects real snippets from your
|
|
81
|
-
current project.
|
|
81
|
+
current project. Three modes across five difficulty levels:
|
|
82
82
|
|
|
83
83
|
- **Passive** (default): Explain what the code does and how it works.
|
|
84
84
|
- **Interactive**: Lines are removed from the file — you restore the missing
|
|
85
85
|
logic, then say `done` for the model to verify your work.
|
|
86
|
+
- **SOLID**: Working code is rewritten with deliberate anti-patterns (breaks
|
|
87
|
+
SOLID, DRY, cohesion). You restore good design, then say `done`.
|
|
86
88
|
|
|
87
89
|
**Triggers:** `teach me` · `quiz me` · `test my knowledge` · `code quiz` ·
|
|
88
90
|
`drill me`
|
|
@@ -93,7 +95,8 @@ current project. Two modes across five difficulty levels:
|
|
|
93
95
|
|----------|---------|-------------|
|
|
94
96
|
| Language | `teach me python` | Restrict to Python, TypeScript, Rust, Go, Java… |
|
|
95
97
|
| Level | `teach me level 3` or `teach me l3` | Set difficulty 1–5 (default: 3) |
|
|
96
|
-
| Mode | `teach me interactive` | Reconstruction
|
|
98
|
+
| Mode | `teach me interactive` | Reconstruction — restore missing lines |
|
|
99
|
+
| Mode | `teach me solid` | Anti-pattern detection — fix degraded design |
|
|
97
100
|
| Scope | `teach me services/` | Narrow to a specific file or folder |
|
|
98
101
|
| Concept | `teach me decorators` | Target: decorators, async, generators, context managers, comprehensions, error handling, type hints, threading |
|
|
99
102
|
|
|
@@ -109,11 +112,25 @@ current project. Two modes across five difficulty levels:
|
|
|
109
112
|
|
|
110
113
|
**Mid-round commands:** `hint` (get a nudge) · `skip` (see the answer) ·
|
|
111
114
|
`next` (draw a new snippet) · `level N` · `easier` · `harder` ·
|
|
112
|
-
`interactive` · `passive` · `done` (verify
|
|
115
|
+
`interactive` · `passive` · `solid` · `done` (verify work) · `stop`
|
|
113
116
|
|
|
114
117
|
**At the end** you get a session summary: rounds completed, mode, files covered,
|
|
115
118
|
what you're strong on, what to review, and a suggested next level.
|
|
116
119
|
|
|
120
|
+
### SOLID Mode
|
|
121
|
+
|
|
122
|
+
| Trigger | What happens |
|
|
123
|
+
|---------|-------------|
|
|
124
|
+
| `teach me solid` | SOLID mode at level 3, passive feedback |
|
|
125
|
+
| `teach me SOLID level 4` | Level 4, passive |
|
|
126
|
+
| `teach me solid interactive` | SOLID mode, you edit the file (not just describe) |
|
|
127
|
+
|
|
128
|
+
**How it works:** The model picks code, rewrites it with deliberate anti-patterns
|
|
129
|
+
(STUPID, WET, god objects, tight coupling), presents the degraded code, and you
|
|
130
|
+
restore good design. The model assesses across anti-patterns fixed, design
|
|
131
|
+
quality, functional correctness, and intentionality. Files are always restored
|
|
132
|
+
with `git checkout` after each round.
|
|
133
|
+
|
|
117
134
|
## Requirements
|
|
118
135
|
- Node.js (for the `codewhale-history` command)
|
|
119
136
|
- [CodeWhale](https://codewhale.net/en/docs)
|
package/package.json
CHANGED
package/skills/teach-me/SKILL.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: teach-me
|
|
3
|
-
description: Interactive code-teaching quiz. Selects random snippets from the current project and quizzes the user on application logic and language semantics. Triggered by 'teach me', 'quiz me', 'test my knowledge', 'code quiz', or 'drill me'. Supports difficulty levels 1–5 and
|
|
3
|
+
description: Interactive code-teaching quiz. Selects random snippets from the current project and quizzes the user on application logic and language semantics. Triggered by 'teach me', 'quiz me', 'test my knowledge', 'code quiz', or 'drill me'. Supports difficulty levels 1–5 and three modes: passive (explain), interactive (reconstruct), and solid (anti-pattern detection).
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Teach Me — Interactive Code Quiz
|
|
@@ -13,6 +13,9 @@ current project. Two modes:
|
|
|
13
13
|
accomplishes) and **language mechanics** (syntax and semantics).
|
|
14
14
|
- **Interactive**: removes lines from the file; the user restores them and
|
|
15
15
|
says `done`; the model diffs against the original and gives feedback.
|
|
16
|
+
- **SOLID**: rewrites working code to be deliberately anti-pattern-ridden
|
|
17
|
+
(STUPID principles, WET code, poor cohesion). The user restores good
|
|
18
|
+
design and says `done`; the model evaluates against the original.
|
|
16
19
|
|
|
17
20
|
## Session Trigger
|
|
18
21
|
|
|
@@ -37,15 +40,19 @@ Optionally followed by modifiers:
|
|
|
37
40
|
|
|
38
41
|
Modifiers combine freely: `teach me decorators level 4`,
|
|
39
42
|
`teach me async services/`, `teach me generators l2`,
|
|
40
|
-
`teach me level 2 interactive`, `teach me interactive decorators
|
|
43
|
+
`teach me level 2 interactive`, `teach me interactive decorators`,
|
|
44
|
+
`teach me solid level 3`, `teach me SOLID`
|
|
41
45
|
|
|
42
|
-
|
|
46
|
+
Three modes are available, orthogonal to difficulty:
|
|
43
47
|
|
|
44
48
|
- **`passive`** (default) — You explain what the code does and how it works.
|
|
45
49
|
- **`interactive`** — Lines are removed from the file; you restore the missing
|
|
46
50
|
logic. When done, say `done` or `check my work` and the model verifies.
|
|
51
|
+
- **`solid`** / **`SOLID`** — Working code is rewritten with deliberate
|
|
52
|
+
anti-patterns (breaks SOLID, DRY, cohesion, abstraction). You restore good
|
|
53
|
+
design principles. When done, say `done` or `check my work`.
|
|
47
54
|
|
|
48
|
-
Switch modes mid-session with `interactive
|
|
55
|
+
Switch modes mid-session with `passive`, `interactive`, or `solid`.
|
|
49
56
|
|
|
50
57
|
If no level is specified, default to **level 3** and adjust based on
|
|
51
58
|
performance across rounds.
|
|
@@ -204,6 +211,109 @@ Type `hint` for a clue, `skip` to see the answer, or `stop` to end.
|
|
|
204
211
|
---
|
|
205
212
|
```
|
|
206
213
|
|
|
214
|
+
### 2c. SOLID Mode — Anti-Pattern Reconstruction
|
|
215
|
+
|
|
216
|
+
When mode is `solid` (or `SOLID`), the model rewrites working code to be
|
|
217
|
+
deliberately anti-pattern-ridden — breaking SOLID principles, DRY, cohesion,
|
|
218
|
+
and abstraction — while keeping the code functional. The user must restore
|
|
219
|
+
good design.
|
|
220
|
+
|
|
221
|
+
#### Scope by Level
|
|
222
|
+
|
|
223
|
+
| Level | Scope | Anti-patterns introduced |
|
|
224
|
+
|-------|-------|--------------------------|
|
|
225
|
+
| 1 | Single method, 5–15 lines | 2 (e.g., bad naming + duplication) |
|
|
226
|
+
| 2 | Single method, 8–20 lines | 3–4 (add tight coupling, god method creep) |
|
|
227
|
+
| 3 | Method + immediate collaborators, 12–30 lines each | 4–5 across methods (tight coupling, WET, poor cohesion) |
|
|
228
|
+
| 4 | Small class, 18–45 lines of method bodies | 5–6 systemic anti-patterns |
|
|
229
|
+
| 5 | Full class or multiple related classes, 25–55+ lines | Architectural: Singleton abuse, dependency inversion violation, shotgun surgery |
|
|
230
|
+
|
|
231
|
+
#### Anti-Pattern Catalog
|
|
232
|
+
|
|
233
|
+
The model chooses from this catalog when deconstructing code. Select
|
|
234
|
+
anti-patterns appropriate to the language and scope:
|
|
235
|
+
|
|
236
|
+
**STUPID principles (broken SOLID):**
|
|
237
|
+
- **S**ingleton abuse — unnecessary global/static state
|
|
238
|
+
- **T**ight coupling — hardcoded dependencies, `new` inside methods, no DI
|
|
239
|
+
- **U**ntestable — no seams, side effects mixed with logic, `new Date()` inline
|
|
240
|
+
- **P**remature optimization — complex code for imaginary performance needs
|
|
241
|
+
- **I**ndescriptive naming — single-letter vars (`x`, `tmp`, `data`), misleading names
|
|
242
|
+
- **D**uplication — copy-pasted logic blocks, WET (Write Everything Twice)
|
|
243
|
+
|
|
244
|
+
**Broken design principles:**
|
|
245
|
+
- Single Responsibility violation — one function/method does 3+ unrelated things
|
|
246
|
+
- Open/Closed violation — `if isinstance()` chains or giant `switch` for extensibility
|
|
247
|
+
- Interface Segregation violation — fat interfaces with unused methods
|
|
248
|
+
- Dependency Inversion violation — high-level modules depending on low-level details
|
|
249
|
+
- Leaky abstraction — exposing implementation details through the API
|
|
250
|
+
- God object — one class/method that knows and does everything
|
|
251
|
+
- Shotgun surgery — one change requires touching many files/methods
|
|
252
|
+
|
|
253
|
+
#### SOLID Mode Per-Round Flow
|
|
254
|
+
|
|
255
|
+
0. **Snapshot git state.** Run `git status --porcelain <file>` before touching it.
|
|
256
|
+
1. **Select** a snippet using the standard rules (section 2). For levels 3–5,
|
|
257
|
+
read enough context (callers, callees, class definition) to rewrite coherently.
|
|
258
|
+
2. **Save** the original code in memory (full selected scope).
|
|
259
|
+
3. **Deconstruct** the code. Rewrite the file with `write_file` (full file) or
|
|
260
|
+
`edit_file` (targeted) to introduce anti-patterns. The code MUST still
|
|
261
|
+
compile/run and produce the same behavior as the original.
|
|
262
|
+
4. **Present** the deconstructed code. State the scope, the number of
|
|
263
|
+
anti-patterns introduced, but do NOT name or annotate them — the user must
|
|
264
|
+
find them.
|
|
265
|
+
5. **Instruct:** "Open `<file>`, find and fix the [N] anti-patterns. The code
|
|
266
|
+
should still work. Say `done` or `check my work` when ready."
|
|
267
|
+
6. **Wait.** Do not evaluate until the user signals completion.
|
|
268
|
+
7. **Re-read** the file. Compare against the saved original.
|
|
269
|
+
8. **Feedback** (see SOLID Evaluation below). Restore with `git checkout -- <file>`.
|
|
270
|
+
9. **Restore.** After feedback, `git checkout -- <file>` for a byte-perfect reset.
|
|
271
|
+
If pre-existing uncommitted changes (step 0), warn the user and offer manual
|
|
272
|
+
restore.
|
|
273
|
+
|
|
274
|
+
#### Thinking Suppression (SOLID Mode)
|
|
275
|
+
|
|
276
|
+
Same as interactive mode: use **Skip** thinking during steps 1–5 (selection
|
|
277
|
+
through presentation). Resume normal depth at step 6. Never include the
|
|
278
|
+
original code or the specific anti-patterns chosen in your reasoning.
|
|
279
|
+
|
|
280
|
+
#### SOLID Mode Presentation Format
|
|
281
|
+
|
|
282
|
+
```
|
|
283
|
+
---
|
|
284
|
+
## Round N — Level X · solid | `path/to/file.py` (lines A–B)
|
|
285
|
+
|
|
286
|
+
```python
|
|
287
|
+
42 class ReportGenerator:
|
|
288
|
+
43 def process(self, data):
|
|
289
|
+
44 x = data.strip()
|
|
290
|
+
45 # Parse + validate + format all in one method
|
|
291
|
+
46 if ',' in x:
|
|
292
|
+
47 parts = x.split(',')
|
|
293
|
+
48 if len(parts) != 3: return None
|
|
294
|
+
49 result = f"{parts[0].upper()}: {parts[1]} - {parts[2]}"
|
|
295
|
+
50 elif '|' in x:
|
|
296
|
+
51 parts = x.split('|')
|
|
297
|
+
52 if len(parts) != 3: return None
|
|
298
|
+
53 result = f"{parts[0].upper()}: {parts[1]} - {parts[2]}"
|
|
299
|
+
54 else:
|
|
300
|
+
55 return None
|
|
301
|
+
56 # Save + notify all in one place
|
|
302
|
+
57 db = DatabaseConnection() # hardcoded dependency
|
|
303
|
+
58 db.save(result)
|
|
304
|
+
59 EmailSender().send("admin@corp.com", "Report", result)
|
|
305
|
+
60 return result
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
⚠️ **SOLID Mode.** This code still works, but contains ~5 anti-patterns
|
|
309
|
+
(violating SOLID, DRY, and cohesion principles). Open
|
|
310
|
+
`path/to/file.py` and restore good design. When you're done, say
|
|
311
|
+
**`done`** or **`check my work`**.
|
|
312
|
+
|
|
313
|
+
Type `hint` for a clue, `skip` to see the answer, or `stop` to end.
|
|
314
|
+
---
|
|
315
|
+
```
|
|
316
|
+
|
|
207
317
|
### 3. Presentation — Show the Snippet
|
|
208
318
|
|
|
209
319
|
For each round, present the snippet with its filename:
|
|
@@ -311,6 +421,56 @@ Here's what was removed:
|
|
|
311
421
|
After strike 3, restore the original lines in the file and proceed to the
|
|
312
422
|
next round automatically (no "another round?" prompt).
|
|
313
423
|
|
|
424
|
+
#### D. SOLID Mode Evaluation
|
|
425
|
+
|
|
426
|
+
When mode is `solid`, evaluation compares the user's restored design against
|
|
427
|
+
the saved original and the anti-patterns that were introduced. Score across
|
|
428
|
+
these dimensions:
|
|
429
|
+
|
|
430
|
+
| Dimension | What to check |
|
|
431
|
+
|-----------|--------------|
|
|
432
|
+
| **Anti-patterns fixed** | How many of the N introduced anti-patterns did the user address? |
|
|
433
|
+
| **Design quality** | Does the restored code follow SOLID, DRY, and cohesion principles at least as well as the original? |
|
|
434
|
+
| **Functional correctness** | Does the code still work? Same inputs → same outputs? |
|
|
435
|
+
| **Intentionality** | Did the user identify WHY each anti-pattern was wrong, or just guess? |
|
|
436
|
+
|
|
437
|
+
Feedback structure:
|
|
438
|
+
|
|
439
|
+
```
|
|
440
|
+
**Anti-patterns addressed:** [N/M] — [list which ones and how]
|
|
441
|
+
|
|
442
|
+
**What you improved:**
|
|
443
|
+
- [specific anti-pattern they fixed well]
|
|
444
|
+
|
|
445
|
+
**What you missed:**
|
|
446
|
+
- [anti-patterns still present or not fully addressed]
|
|
447
|
+
|
|
448
|
+
**Comparison to original:**
|
|
449
|
+
[How their solution compares to the original — is it equivalent, better, or
|
|
450
|
+
does it introduce new issues?]
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
**Strikes in SOLID mode:**
|
|
454
|
+
|
|
455
|
+
**Strike 1** — Category nudge (name the principle, not the fix):
|
|
456
|
+
```
|
|
457
|
+
Good effort. Think about [principle — e.g., "Single Responsibility"] —
|
|
458
|
+
does this method do too many different things?
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
**Strike 2** — Near-explicit hint (name the anti-pattern):
|
|
462
|
+
```
|
|
463
|
+
You're close. Look at the duplication between lines 46-49 and 50-53. That's
|
|
464
|
+
WET code — both branches do the same parsing. Also, `DatabaseConnection()`
|
|
465
|
+
on line 57 creates tight coupling.
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
**Strike 3** — Reveal the original code and move to the next round:
|
|
469
|
+
```
|
|
470
|
+
Here's the original design. Compare it with yours to see what was improved.
|
|
471
|
+
```
|
|
472
|
+
Then restore with `git checkout -- <file>` and proceed automatically.
|
|
473
|
+
|
|
314
474
|
#### Weighted Evaluation for Targeted Concepts
|
|
315
475
|
|
|
316
476
|
When a concept is targeted (e.g., `teach me decorators`), bias the
|
|
@@ -391,13 +551,14 @@ nailed everything at-level, say so and highlight the nuance they caught.
|
|
|
391
551
|
| `harder` | Increase level by 1 (maximum 5). |
|
|
392
552
|
| `interactive` | Switch to interactive (reconstruction) mode for subsequent rounds. |
|
|
393
553
|
| `passive` | Switch to passive (explanation) mode for subsequent rounds. |
|
|
394
|
-
| `
|
|
554
|
+
| `solid` / `SOLID` | Switch to SOLID (anti-pattern reconstruction) mode for subsequent rounds. |
|
|
555
|
+
| `done` / `check my work` | (Interactive/SOLID mode) Signal that work is complete. Triggers verification. |
|
|
395
556
|
| `stop` / `end` | End session. Deliver summary. |
|
|
396
557
|
|
|
397
558
|
### 5. Loop — Keep Going
|
|
398
559
|
|
|
399
560
|
After a successful evaluation or a `next` skip, ask:
|
|
400
|
-
"Another round? (yes / no / level N / interactive / passive / stop)"
|
|
561
|
+
"Another round? (yes / no / level N / interactive / passive / solid / stop)"
|
|
401
562
|
|
|
402
563
|
After a strike-3 reveal, do **not** ask — proceed directly to the next
|
|
403
564
|
round with:
|
|
@@ -456,15 +617,18 @@ criteria for the Mechanics axis:
|
|
|
456
617
|
- **Interactive mode file edits.** The model MAY remove lines from files to set
|
|
457
618
|
up reconstruction exercises. The model MUST NOT add or modify lines — only
|
|
458
619
|
the user restores code.
|
|
459
|
-
- **
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
620
|
+
- **SOLID mode file rewrites.** The model MAY rewrite files to introduce
|
|
621
|
+
anti-patterns. The deconstructed code MUST still compile/run with the same
|
|
622
|
+
behavior. The model MUST NOT delete code or break functionality — only
|
|
623
|
+
degrade the design.
|
|
624
|
+
- **Restore after each round.** After feedback in interactive or SOLID mode,
|
|
625
|
+
restore each touched file with `git checkout -- <file>` for a byte-perfect
|
|
626
|
+
reset. If the file had pre-existing uncommitted changes (noted in step 0),
|
|
627
|
+
restore the original lines manually via `edit_file` instead and warn the user.
|
|
464
628
|
- **Restore on session end.** When the session ends, check whether any files
|
|
465
|
-
still contain `# ... N lines removed ...` placeholders
|
|
466
|
-
|
|
467
|
-
|
|
629
|
+
still contain `# ... N lines removed ...` placeholders or deconstructed
|
|
630
|
+
code from interactive/SOLID mode. If so, restore them with
|
|
631
|
+
`git checkout -- <file>` (or `edit_file` if pre-existing changes).
|
|
468
632
|
|
|
469
633
|
## Verification
|
|
470
634
|
|
|
@@ -479,3 +643,10 @@ After each round, confirm:
|
|
|
479
643
|
- (Interactive mode) The file was re-read before evaluating the user's restoration
|
|
480
644
|
- (Interactive mode) Feedback accurately describes any differences from the original
|
|
481
645
|
- (Interactive mode) Gapped files were restored or the user was offered restoration on session end
|
|
646
|
+
- (SOLID mode) The original code was saved before deconstruction
|
|
647
|
+
- (SOLID mode) The deconstructed code is functional (same behavior, just degraded design)
|
|
648
|
+
- (SOLID mode) Anti-patterns were introduced deliberately — no accidental breakage
|
|
649
|
+
- (SOLID mode) The number of anti-patterns was stated in the presentation
|
|
650
|
+
- (SOLID mode) Individual anti-patterns were NOT annotated or revealed before evaluation
|
|
651
|
+
- (SOLID mode) The file was re-read before evaluating the user's restoration
|
|
652
|
+
- (SOLID mode) Deconstructed files were restored with `git checkout` on round end
|