agentleFS
m98m98/fluent/.claude/skills/fluent-sm2-calculator/SKILL.md

fluent-sm2-calculator

Skill420 starsChanged 6 months agoMITView on GitHub

SM-2 spaced-repetition algorithm reference for the Fluent language learning system. Use whenever the tutor schedules the next review of a vocabulary item, grammar rule, or error pattern — i.e. after every answered review question. Defines the 0-5 quality scale, interval formula, easiness-factor update, and mastery-level transitions that keep the spaced-repetition database correct.

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 1 is distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    After each answer, the item in spaced-repetition.json must have:

    line 78
  2. Very specific:

    If the learner got it wrong (quality < 3), keep the item in review_queue.today so it reappears in the same session.

    line 97
  3. Very specific:

    Do not hand-edit spaced-repetition.json.

    line 101
  4. Distinctive:

    Floor EF at 1.3: Never let the easiness factor drop lower — rounds to infinite daily reviews.

    line 126
  5. Very specific:

    Prefer update-db.py: Only reimplement this math when the script is unavailable.

    line 129

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

SM-2 Calculator

Overview

Fluent uses SM-2 (SuperMemo 2) to decide when the learner next sees an item. This skill is the single source of truth for the algorithm. Every practice skill updates <data_dir>/spaced-repetition.json (where <data_dir> is resolved by fluent_paths.data_dir()) through these rules after each answered question.

When to Use

Load this skill whenever the tutor:

  • Grades a review-queue item and must compute its next due date.
  • Maps a 0-10 score to an SM-2 quality.
  • Updates easiness_factor, interval_days, repetitions, or mastery_level on a spaced-repetition item.
  • Decides which queue (today / tomorrow / this_week / later) to place an item in.

Skip this skill when the fluent-db-updater skill is already being used — the update-db.py script runs SM-2 internally.

Instructions

1. Convert score to quality

ScoreQualityMeaning
10/105Perfect, instant recall
8-94Correct after hesitation
6-73Correct with difficulty
4-52Incorrect but remembered when shown
2-31Incorrect, familiar
0-10Complete blackout

Rule: quality = floor(score / 2).

2. Update interval

if quality >= 3:   # correct
    if repetitions == 0:
        interval = 1
    elif repetitions == 1:
        interval = 6
    else:
        interval = round(previous_interval * easiness_factor)
    repetitions += 1
else:              # incorrect
    interval = 1
    repetitions = 0

3. Update easiness factor

Apply after every answer:

EF_new = EF + (0.1 - (5 - quality) * (0.08 + (5 - quality) * 0.02))
EF_new = max(1.3, EF_new)

4. Update mastery level

Track consecutive_correct and consecutive_incorrect per item:

if consecutive_correct >= 5:
    mastery_level = min(5, mastery_level + 1)
    consecutive_correct = 0
elif consecutive_incorrect >= 3:
    mastery_level = max(0, mastery_level - 1)
    consecutive_incorrect = 0

5. Update per-item fields

After each answer, the item in spaced-repetition.json must have:

  • easiness_factor — updated via formula
  • interval_days — new interval
  • repetitions — incremented or reset
  • consecutive_correct / consecutive_incorrect — one incremented, the other reset
  • total_reviews — incremented
  • mastery_level — possibly changed
  • due_date — today + interval_days (YYYY-MM-DD)
  • last_reviewed — today

6. Route to correct queue

After updating:

  • interval_days == 1 → review_queue.tomorrow
  • interval_days <= 7 → review_queue.this_week
  • interval_days > 7 → review_queue.later

If the learner got it wrong (quality < 3), keep the item in review_queue.today so it reappears in the same session.

7. Preferred implementation

Do not hand-edit spaced-repetition.json. Call .claude/hooks/update-db.py with a review_results array — the script runs SM-2 atomically and rebuilds the queue. Only do manual math when the script is unavailable. See the fluent-db-updater skill for the payload schema.

python3 "${CLAUDE_PLUGIN_ROOT:-${CLAUDE_PROJECT_DIR:-.}}/.claude/hooks/update-db.py" <<'EOF'
{
  "session_id": "session-NNN",
  "date": "YYYY-MM-DD",
  "review_results": [
    { "item_id": "vocab_huis", "quality": 4 }
  ]
}
EOF

Examples

See .claude/references/sm2-worked-examples.md for 4 worked examples covering: correct answer (regular case), wrong answer (reset + EF drop), 5th consecutive correct (mastery bump), 3rd consecutive wrong (mastery drop). Each example shows the full before/after state.

Quick version:

  • Correct, q=4: interval = round(prev * EF), repetitions += 1, EF barely moves.
  • Wrong, q<3: interval = 1, repetitions = 0, EF drops sharply, item stays in today's queue.

Critical Rules

  • Floor EF at 1.3. Never let the easiness factor drop lower — rounds to infinite daily reviews.
  • Reset repetitions on wrong answer. The item returns to the start of the learning sequence.
  • Do not hand-tune intervals. Trust the algorithm. Shortcuts break long-term retention.
  • Prefer update-db.py. Only reimplement this math when the script is unavailable.

Why This Matters

SM-2 reviews items just before the learner forgets them, maximizing long-term retention per minute of practice. Wrong scheduling means wasted reviews (too early) or forgotten items (too late). The whole Fluent system rests on these numbers being correct.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.