Plugin Claude Code regroupant : - le skill `math-exercises` (génération et correction de séries d'exercices progressifs, suivi de progression et des notions à revoir) ; - la commande `/exos`, qui force Opus via son frontmatter `model:` ; - un hook `UserPromptSubmit` qui vérifie automatiquement les affirmations mathématiques tapées dans un message (chaînes d'égalités et de congruences, divisibilité, primalité, pgcd/ppcm/φ) et rend un verdict ligne par ligne. Le dépôt sert à la fois de plugin et de marketplace à entrée unique, pour pouvoir être installé directement depuis son URL. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
267 lines
14 KiB
Markdown
267 lines
14 KiB
Markdown
---
|
||
name: math-exercises
|
||
description: >
|
||
Generate a set of 4 increasingly-difficult practice exercises on the next
|
||
not-yet-mastered topic of the crypto-maths course (the
|
||
outline in CLAUDE.md), styled after the TD PDFs in this directory, then
|
||
grade the user's answers, track per-topic completion in PROGRESS.md and
|
||
track not-first-try notions in REVISIONS.md for spaced re-testing.
|
||
Trigger whenever the user asks for math exercises or practice problems in
|
||
this course — "give me an exercise", "exercices", "des exos", "donne-moi un
|
||
exercice", "je veux m'entraîner", "quiz me", "practice", "next topic",
|
||
"continue les exercices", or any follow-up where the user submits answers
|
||
to exercises this skill generated earlier. Always use this skill instead of
|
||
improvising ad-hoc problems — it keeps difficulty calibrated to mental
|
||
arithmetic, keeps notation consistent with the course, and keeps PROGRESS.md
|
||
and REVISIONS.md in sync.
|
||
---
|
||
|
||
# Math exercises for the crypto-maths course
|
||
|
||
## 0. Run on Opus — check before anything else
|
||
|
||
This loop (writing calibrated exercises, grading proofs, diagnosing
|
||
conceptual vs. arithmetic mistakes) is tuned for Opus. **Before reading any
|
||
PDF or picking a topic**, check which model this session is running:
|
||
|
||
- **Already Opus** → continue straight to step 1, say nothing about it.
|
||
- **Not Opus** → stop immediately. Do not read PDFs, pick a topic, or write
|
||
exercises. Tell the user, in one line, to run `/model opus` and then ask
|
||
again — or to use `/exos`, the command shipped by this plugin, which forces
|
||
Opus via its `model: opus` frontmatter (`commands/exos.md`). Only proceed on a
|
||
weaker model if the user explicitly says to go ahead anyway.
|
||
|
||
A skill cannot switch the session model on its own — there is no tool for it,
|
||
and SKILL.md frontmatter has no `model:` field. `/exos` is the enforcement
|
||
mechanism; this step is the fallback when the skill is triggered by plain
|
||
language ("donne-moi un exercice") instead of the command.
|
||
|
||
This skill runs a full loop: pick a topic → write a series → grade what the
|
||
user submits → remediate mistakes → record what wasn't passed first try →
|
||
mark the topic done. Course outline: `CLAUDE.md`. Notation reference:
|
||
`NOTATIONS_REFERENCE.md`. Progress tracker: `PROGRESS.md`. Weak-notion
|
||
tracker: `REVISIONS.md`. Source PDFs (course + exercise sheets +
|
||
corrections): `TD1-arithmetique.pdf`, `TD1-arithmetique-correctionEx.pdf`,
|
||
`TD2-groupes.pdf`, `TD2-groupes_feuilleexercice.pdf`, `TD3-anneaux.pdf`,
|
||
`TD3-anneaux-correction.1-5.pdf`.
|
||
|
||
### What "passed on the first try" means
|
||
|
||
An exercise counts as **first-try** only if the user's *first* submission for
|
||
it is fully correct, with no help beyond the original statement. All of these
|
||
count as **not** first-try, and get recorded in `REVISIONS.md`:
|
||
|
||
- a wrong first answer, even if a later retry is correct;
|
||
- asking for a hint, a nudge, or "help" before producing a correct answer;
|
||
- an answer correct in substance but resting on an invalid step the user had
|
||
to be walked back from.
|
||
|
||
Pure transcription typos (writing `n − 2` for `n + 2` while reasoning
|
||
correctly throughout) do **not** count as failures — note them and move on.
|
||
|
||
## 1. Pick the topic — or enter remediation mode
|
||
|
||
Read `PROGRESS.md` and `REVISIONS.md` first. If either doesn't exist, create
|
||
it: `PROGRESS.md` by listing every sub-section heading under TD1/TD2/TD3 in
|
||
`CLAUDE.md`, in order, as unchecked boxes (the topic list lives in CLAUDE.md,
|
||
PROGRESS.md only tracks status); `REVISIONS.md` with the two headings
|
||
`## À revoir` and `## Résolus` and nothing under them.
|
||
|
||
Then count the unresolved entries under `## À revoir` in `REVISIONS.md`:
|
||
|
||
- **More than 4 unresolved → REMEDIATION MODE.** Do *not* advance to a new
|
||
topic and do *not* touch `PROGRESS.md` this round. Instead build a series
|
||
of exactly 4 exercises, one targeting each of the **4 oldest** unresolved
|
||
entries (oldest first, so nothing starves). Say so plainly up front, e.g.
|
||
*"5 notions en attente de révision — on ne passe pas au sujet suivant,
|
||
cette série est une remise à niveau."* Skip to step 2, calibrating against
|
||
whichever TD each entry belongs to.
|
||
- **4 or fewer unresolved → normal mode.** Pick the topic as follows:
|
||
- Default topic = the **first unchecked box** in `PROGRESS.md`, in file
|
||
order (TD1 top to bottom, then TD2, then TD3).
|
||
- If the user names a specific topic/TD explicitly, use that instead. If
|
||
it's already checked off, generate the exercises anyway as a review round
|
||
but don't touch its checkbox (only the auto-picked "next" topic gets
|
||
marked done by this flow).
|
||
- Tell the user which topic you picked and why (e.g. "Next up: *Division
|
||
euclidienne et algorithme d'Euclide* (TD1)") before giving the exercises.
|
||
|
||
## 2. Calibrate against the PDFs
|
||
|
||
Read the course PDF(s) for the relevant TD (and the correction PDF if one
|
||
exists for it) to calibrate notation, phrasing and difficulty range — use the
|
||
`Read` tool's `pages` param if a PDF is long. **Do not copy an existing
|
||
exercise's numbers or statement.** Write new exercises in the same spirit.
|
||
Cross-check any notation you use against `NOTATIONS_REFERENCE.md` so it
|
||
matches what the student already sees in lecture (e.g. `pgcd`, `φ(n)`,
|
||
`Z×ₙ`, `≡ mod N`).
|
||
|
||
## 3. Write the series
|
||
|
||
### 3a. The 4 main exercises, increasing difficulty
|
||
|
||
Label each with a difficulty tag and keep them on the chosen topic:
|
||
|
||
1. **Facile** — direct, one-step application of a single definition/theorem.
|
||
2. **Moyen** — combines two small steps (e.g. compute something, then apply
|
||
a theorem to it).
|
||
3. **Difficile** — requires a short justification/proof, or a less obvious
|
||
case (e.g. picking the right theorem among several).
|
||
4. **Expert / synthèse** — the trickiest angle on this topic: an edge case, a
|
||
short proof, or a light combination with a topic already marked done in
|
||
`PROGRESS.md` (skip the combination if nothing is done yet).
|
||
|
||
In **remediation mode** the four exercises instead target the four oldest
|
||
unresolved notions, still ordered easiest-to-hardest, each labelled with the
|
||
notion it re-tests: *"Exercice 2 — révision : lemme de linéarité de la
|
||
divisibilité"*.
|
||
|
||
### 3b. Bonus revision exercises
|
||
|
||
In **normal mode**, after the 4 main exercises, append up to **2 bonus
|
||
exercises** drawn from the unresolved entries in `REVISIONS.md`, oldest
|
||
first. Label them `Bonus A` / `Bonus B` and name the notion each re-tests.
|
||
|
||
- Target the **notion**, not the literal exercise — re-asking the identical
|
||
question tests recall, not understanding. Change the numbers, the framing,
|
||
or the direction of the implication.
|
||
- Bonus exercises are **never** required to mark a topic done (see step 5),
|
||
and a failed bonus never blocks topic completion — it just keeps its entry
|
||
unresolved.
|
||
- If `REVISIONS.md` has no unresolved entries, there are no bonus exercises;
|
||
don't invent any.
|
||
|
||
### 3c. Keep arithmetic mental-math friendly, always
|
||
|
||
- No number a human must compute with should exceed 2 digits (≤ 99).
|
||
- Prefer small factors (2, 3, 5, 7, 11, 13) so divisions/multiplications land
|
||
cleanly; don't manufacture ugly remainders unless the exercise is
|
||
specifically about remainders (and then keep the remainder itself small).
|
||
- For modular exponentiation, keep the modulus ≤ 50 and the exponent small
|
||
enough to do by hand in ≤ 3–4 squaring steps.
|
||
- If a topic is purely structural/proof-based with no numbers, "difficulty"
|
||
still escalates as described above — the mental-math constraint just
|
||
doesn't apply to that exercise.
|
||
|
||
Work out the full solution for each exercise yourself and keep it private —
|
||
don't reveal it until grading (or until the user asks you to give up on one).
|
||
|
||
Present the whole series at once, clearly numbered and tagged, then stop and
|
||
wait for the user's attempt(s). Don't dump solutions preemptively.
|
||
|
||
## 4. Grade what the user submits
|
||
|
||
The user may answer one exercise at a time or all at once — handle either.
|
||
For each submitted answer:
|
||
|
||
- **Correct:** confirm briefly, note in one line *why* it's correct (ties
|
||
back to the theorem/definition used), move on.
|
||
- **Incorrect:** diagnose which of the two applies before replying:
|
||
- **Conceptual mistake** (wrong theorem, wrong definition, invalid step):
|
||
explain the correct reasoning using the vocabulary from `CLAUDE.md` /
|
||
`NOTATIONS_REFERENCE.md`, give a short worked mini-example, and point to
|
||
exactly where to look — TD number, filename, and the sub-section name,
|
||
e.g. *"revoir TD2-groupes.pdf, partie 'Ordres et structures cycliques'
|
||
(théorème de Lagrange)"*. Let them retry the same exercise rather than
|
||
handing over the answer outright. If they stall across two or three
|
||
scaffolded attempts, stop withholding: show the full proof, annotate the
|
||
misconception, then re-test the technique on a fresh small exercise.
|
||
- **Calculation slip** (right method, arithmetic error): point out exactly
|
||
where the number went wrong, then give ONE relevant mental-math check
|
||
from the table below, and mention they can type the intermediate
|
||
calculation as a bare statement (e.g. `gcd(84, 18) = 6`, `15 mod 7 = 1`,
|
||
`3^4 mod 5 = 1`) — **this plugin already auto-verifies such statements on
|
||
every message** via its `UserPromptSubmit` hook
|
||
(`hooks/verify-calculations.sh`) and will flag a ✗
|
||
instantly if it's wrong. Point this out the first time it's relevant in a
|
||
session; no need to repeat every time after that.
|
||
|
||
### 4a. Record every exercise not passed first try
|
||
|
||
As soon as an exercise fails the first-try bar defined above, **append an
|
||
entry to `## À revoir` in `REVISIONS.md`** — do it at grading time, not at
|
||
the end of the series, so nothing is lost if the session is interrupted.
|
||
One line per entry:
|
||
|
||
```
|
||
- [ ] **<notion, 3-6 words>** — <topic name> (<TD>) · échoué le <AAAA-MM-JJ> · <the specific misconception, one clause>
|
||
```
|
||
|
||
Record the **notion**, not the exercise number — "exercice 3b" is meaningless
|
||
three weeks later, "preuve pgcd(a,b) = pgcd(b,r) par double inclusion" is
|
||
not. If an entry for that notion already exists, don't duplicate it: append
|
||
`· re-échoué le <date>` to the existing line instead.
|
||
|
||
Entries stay unresolved until the user clears them per step 5. A correct
|
||
*retry* never clears an entry — only a first-try pass on a later bonus or
|
||
remediation exercise does.
|
||
|
||
### Notation conventions agreed with the user
|
||
|
||
- **A `mod N` written on ANY link scopes the whole chain.** In `a ≡ b ≡ c mod
|
||
N` — and equally in `a mod N = b = c`, where the modulus is stated once up
|
||
front — every term is taken mod N. Do not read the modulus as binding only
|
||
to the link it happens to be written on. Grade chains accordingly; the
|
||
plugin's `hooks/verify-calculations.sh` applies the same rule.
|
||
- A chain of `≡` asserts that **every** term is congruent to every other, so
|
||
line-wide scoping makes the claim stronger, not weaker. A chain whose terms
|
||
reduce to different residues is false however the modulus scopes.
|
||
- Flag `=` used where `≡` belongs (`38 × 27 = 3 × 2 mod 5`), but treat it as a
|
||
notation note, not a conceptual error.
|
||
|
||
### Mental-math verification techniques (pick the one matching the slip)
|
||
|
||
| Operation | Quick manual check |
|
||
|---|---|
|
||
| Multiplication `a×b` | Casting out nines: digit-sum(a) mod 9 × digit-sum(b) mod 9 ≡ digit-sum(product) mod 9 |
|
||
| Division euclidienne `a = bq + r` | Re-expand `bq + r` and confirm it equals `a`, and `0 ≤ r < b` |
|
||
| `pgcd(a, b)` | Confirm the claimed gcd divides both `a` and `b` exactly |
|
||
| Bézout `ua + vb = pgcd(a,b)` | Plug `u, v` back in and recompute `ua + vb` directly |
|
||
| Modular exponentiation `a^k mod n` | Redo it by repeated squaring, reducing mod n after every squaring step |
|
||
| `φ(n)` | Recompute via `φ(n) = n·∏(1 − 1/p)` over its prime factors and cross-check it matches `p−1` for each prime factor |
|
||
| Any arithmetic/modular/gcd/divisibility/primality claim | Just state it plainly in your message — the repo's hook checks it automatically |
|
||
|
||
### Divisibility proofs — lead with this frame
|
||
|
||
This user's recurring trap. When grading any proof involving `|`, state it
|
||
up front rather than waiting for them to flounder:
|
||
|
||
- To **use** `d | x`: substitute `x = kd`.
|
||
- To **prove** `d | y`: exhibit `y = (integer) × d`.
|
||
- **Never divide** — forming a fraction like `(a−r)/b` is always the wrong
|
||
move; reading `x/q = y` as `q | y` is a false step.
|
||
- `d` is an **arbitrary** common divisor, never the gcd itself.
|
||
- Proving every common divisor divides `k` gives an **upper bound** on the
|
||
pgcd, not its value — check attainment separately.
|
||
|
||
## 5. Close out
|
||
|
||
### 5a. Clear resolved revision entries
|
||
|
||
When the user passes a **bonus** (normal mode) or **remediation** (remediation
|
||
mode) exercise **on the first try**, its notion is cleared: move that line
|
||
from `## À revoir` to `## Résolus` in `REVISIONS.md`, flipping it to
|
||
`- [x] … · résolu le <AAAA-MM-JJ>`. If they need a retry or a hint, the entry
|
||
stays put and will come back in a later series.
|
||
|
||
### 5b. Mark the topic done
|
||
|
||
In **normal mode only**, once exercises 1–3 for the **auto-picked** topic are
|
||
answered correctly (after however many retries), check its box in
|
||
`PROGRESS.md`: `- [x] <topic name> (fait le <today's date>)`. Then tell the
|
||
user what's next in `PROGRESS.md` order and ask whether to start it now or
|
||
stop here.
|
||
|
||
- Exercise 4 (expert/synthèse) is optional for marking completion: the user
|
||
may skip it, and the topic is still marked done as soon as exercises 1–3
|
||
are all valid — don't withhold the checkbox waiting on exercise 4. If the
|
||
user does attempt exercise 4, it must also be correct before marking done.
|
||
- Bonus exercises are likewise never required for completion.
|
||
- A review round on an already-done topic never touches `PROGRESS.md`.
|
||
- **Remediation mode never marks a topic done** — it only clears
|
||
`REVISIONS.md` entries. Once the unresolved count drops to 4 or fewer, the
|
||
next series returns to normal mode and advances to the next topic.
|
||
|
||
Whenever a series ends, state the current counts in one line — topics done
|
||
out of total, and unresolved revision entries — so the user knows where the
|
||
next series will go.
|