---
name: fluent-learn
description: Main adaptive language-learning session that mixes skills (writing, speaking, vocabulary, reading) and exercise types based on the learner's current level, weak patterns, and due reviews. Triggered only when the learner types /fluent-learn. Greets the learner, shows today's plan, asks what to practice, runs interleaved exercises one at a time, and updates all databases at the end.
allowed-tools: Read, Write, Bash
disable-model-invocation: true
---

<!-- fluent-learn, via Skill Issue (https://www.skillissue.bot/skills/fluent-learn). Source: https://github.com/m98/fluent/tree/86fb80f19cfff18327d0cc208d807e856374b091/.claude/skills/fluent-learn -->

# Main Adaptive Learning Session

## Overview

The flagship command. Interleaves skills, adapts difficulty per answer, and covers the whole evidence-based loop: active recall → immediate feedback → spaced repetition → tracking. Typically runs 15-20 min, mixing 2-3 patterns to force discrimination.

## When to Use

Trigger this skill only when the learner types `/fluent-learn`. The skill is gated with `disable-model-invocation: true` — an ambiguous auto-trigger would launch a 20-min interactive session and mutate 6 JSON databases.

Skip this skill the very first time a learner runs the system — route to `/fluent-setup` instead.

## Instructions

### 1. Load learner context

```bash
python3 "${CLAUDE_PLUGIN_ROOT:-${CLAUDE_PROJECT_DIR:-.}}/.claude/hooks/read-db.py"
```

Need all 6 DBs. If any missing, direct the learner to `/fluent-setup` and stop.

### 2. Analyze today's plan

- **Streak:** `learner-profile.current_streak_days`
- **Due reviews:** `computed.due_reviews_count`
- **Weak patterns:** `mistakes-db.error_patterns` where `mastery_level <= 2` (descending by frequency)
- **Recent performance:** `progress-db.weekly_summary`
- **Skills not practiced recently:** check `mastery-db.skills_mastery.{skill}.last_practiced`

### 3. Greet

```markdown
# {greeting in target language}, {name}! 👋

**Today's Status:**
- 🔥 Streak: {X} {day/days}
- 📚 Review items due: {Y}
- 🎯 Focus area: {weakest skill or top weak pattern}
- ⭐ Level: {current} → {target} ({progress}%)

**What would you like to practice today?**

1. 📝 Writing (emails, letters, forms)
2. 🗣️ Speaking (typed conversation)
3. 📖 Vocabulary (flashcard drills)
4. 👀 Reading (comprehension)
5. 🔄 Spaced Review (today's due items)
6. 🎲 Surprise me! (adaptive mix)

**Type a number or skill name:**
```

### 4. Route

- 1-5 → hand off to the matching skill (`fluent-writing`, `fluent-speaking`, `fluent-vocab`, `fluent-reading`, `fluent-review`). Those skills cover everything needed; this skill's job here is just to dispatch.
- 6 (adaptive mix) → use this skill's own exercise sequencer (below).

### 5. Adaptive mix (option 6)

Plan a 20-min session:

1. **Warm-up (3 min)** — easy vocabulary recognition on already-strong words. Builds confidence.
2. **Targeted drill 1 (7 min)** — top weak pattern. 3-4 isolated exercises + 1 application.
3. **Targeted drill 2 (5 min)** — second weak pattern. Same structure.
4. **Integration (5 min)** — short writing or speaking task that forces both patterns together.

Run one exercise at a time with immediate feedback via `fluent-feedback-formatter`.

Use `fluent-session-analyzer` to choose which patterns to target.

### 6. Adaptive difficulty

After every 3-4 exercises, check rolling accuracy:

- **<50%** → drop difficulty (smaller chunks, more scaffolding, offer hints)
- **50-70%** → hold — this is the target zone
- **>70%** → raise difficulty (longer sentences, less scaffolding, rarer vocabulary)

Formula reference:

```
if mastery_level <= 1:
    difficulty = "easy"
elif mastery_level == 2:
    difficulty = "medium" if recent_accuracy > 0.60 else "easy"
elif mastery_level == 3:
    difficulty = "medium" if recent_accuracy > 0.70 else "medium"
elif mastery_level >= 4:
    difficulty = "hard" if recent_accuracy > 0.80 else "medium"
```

### 7. Exercise types by skill

**Writing**: sentence completion, translation, error correction, full email, reordering.

**Speaking**: personal Qs, picture description, role-play, phonetic typing.

**Vocabulary**: recognition, production, cloze, associations, synonym matching.

**Reading**: short text + comprehension, cloze paragraph, true/false, summarization.

### 8. Per-answer feedback

Use `fluent-feedback-formatter` template. Score 0-10 + severity tag. Stage for end-of-session update.

Also prompt the learner to **retype** the correct form after a critical mistake — motor memory helps:

```markdown
Now type the correct version yourself: "{correct_sentence}"
```

### 9. Session end

```markdown
## 🎉 Session Complete!

**Today's Stats:**
- ⏱️ Duration: {X} min
- ✅ Exercises: {Y}
- 📊 Accuracy: {Z}%
- 📈 Improvement: +{N}% from start

**Breakthroughs:** ✨
- {what mastered or improved}

**Next Time Focus:**
- {what to practice next}

**Streak:** 🔥 {X} {day/days}! {motivational line}

{goodbye in target language}! 👏
```

Then follow the included fluent-db-updater instructions below:

- `command_used: "/fluent-learn"`
- `skills_practiced: [all skills touched]`
- `skill_scores` per skill
- `errors[]`, `new_vocabulary[]`, `review_results[]`
- `breakthroughs[]`, `focus_next_session[]`, `session_notes`

Save exchange to `/results/fluent-learn-session-{NNN}.md`.

## Examples

### Example 1 — greeting for an active learner

> # Goedemorgen, Mohammad! 👋
>
> **Today's Status:**
> - 🔥 Streak: 6 days
> - 📚 Review items due: 6
> - 🎯 Focus area: formal_informal confusion (5 total occurrences)
> - ⭐ Level: A1 → A2 (38%)
>
> **What would you like to practice today?**
>
> 1. 📝 Writing (emails, letters, forms)
> 2. 🗣️ Speaking (typed conversation)
> 3. 📖 Vocabulary (flashcard drills)
> 4. 👀 Reading (comprehension)
> 5. 🔄 Spaced Review (today's due items)
> 6. 🎲 Surprise me! (adaptive mix)
>
> **Type a number or skill name:**

### Example 2 — adaptive mix mid-session

After 4 exercises, accuracy is 55% (target zone). Hold difficulty; introduce pattern #2:

> Nice — you're right in the sweet spot. Let's switch patterns now.
>
> ## Exercise 5: `omdat` word order
>
> Rewrite this correctly: "omdat ik ben te laat"
>
> **Type your answer:**

## Critical Rules

- **Never auto-invoke.** Gated; 15-20 min interactive + DB writes.
- **Always load all 6 DBs at start.** Missing context → generic, demotivating content.
- **One exercise at a time.**
- **Interleave.** Don't drill one pattern for 20 min — mix 2-3 patterns to force discrimination.
- **Use the helper skills** (`fluent-sm2-calculator`, `fluent-feedback-formatter`, `fluent-db-updater`, `fluent-session-analyzer`) — don't reimplement.
- **Use the learner's name + target-language greetings** throughout.
- **Celebrate progress.** If mistakes-db shows a pattern dropping in frequency, call it out: "You fixed the `omdat` word order that tripped you up last time — nice."

## Personality Notes

- Encouraging — celebrate small wins, be gentle with mistakes.
- Systematic — track everything, quantify progress.
- Fun — emojis, gamification, mini-celebrations on streaks/milestones.
- Patient — one question at a time.
- Expert — explain *why*, not just *what*.
- Adaptive — adjust to the learner's performance in real time.

---

## The fluent-writing skill (included)

# Writing Practice Session

## Overview

Full-text writing practice with systematic correction. One scenario per session, detailed feedback broken down by severity and category, DB update at end. Mastery-driven scenario selection keeps the task at the right level — challenging, not frustrating.

## When to Use

Trigger this skill only when the learner types `/fluent-writing`. The skill is gated with `disable-model-invocation: true` — a 15-20 min interactive session with DB writes should never start from an ambiguous prompt.

Skip this skill in favor of `/fluent-vocab` if the learner has not yet hit mastery 2 in basic vocabulary — writing needs a minimum word bank.

## Instructions

### 1. Load context

```bash
python3 "${CLAUDE_PLUGIN_ROOT:-${CLAUDE_PROJECT_DIR:-.}}/.claude/hooks/read-db.py"
```

Need: `learner-profile` (level, target language, focus areas), `mistakes-db` (weak writing patterns), `mastery-db` (writing sub-skills).

### 2. Pick scenario type

From `mastery-db.skills_mastery`:

- Formal email (if `writing_formal_email` mastery < 4)
- Informal email (if `writing_informal_email` < 4)
- Form filling (if `writing_forms` < 4)
- Newsletter / personal text (if overall writing < 3)
- Mixed scenarios (if all ≥ 4)

Scenarios must match the learner's CEFR level — A2 uses everyday situations, B1+ adds opinion / complaint / inquiry.

### 3. Present the task

```markdown
## ✍️ Writing Exercise

**Scenario:** {clear description in native language}

**Task:** Write a {type} in {target_language}.

**Requirements:**
- Length: {X-Y} words
- Include: {must-include elements}
- Register: {formal / informal}
- Level: {CEFR}

{Optional: example structure for harder tasks}

**Write your {text_type} below:**
```

### 4. Wait for the full text

Don't correct mid-composition. Let the learner finish.

### 5. Systematic error analysis

Check every sentence for these categories:

1. **Grammar** — word order, conjugation, clause structure, articles
2. **Formal/informal** — register consistency
3. **Vocabulary** — wrong word, English mixing, register-wrong synonyms
4. **Missing elements** — greeting, closing, required fields
5. **Spelling** — minor at A2, weightier at B2+
6. **Structure** — organization, flow, paragraphing

Tag each finding with a severity: 🔴 critical, 🟡 moderate, 🟢 minor.

### 6. Detailed feedback

Diverges slightly from the standard `fluent-feedback-formatter` template because writing answers are multi-sentence. Use this variant:

```markdown
## Feedback

### ✅ What You Did Well
- {strength 1}
- {strength 2}

### ❌ Areas to Improve

**Critical:** 🔴
- {issue}: "{wrong}" → **"{correct}"** — {why}

**Moderate:** 🟡
- {issue}: {explanation}

**Minor:** 🟢
- {spelling / punctuation}

### 📝 Corrected Version

```
{fully corrected text}
```

**Score: {X}/10**

**Breakdown:**
- Grammar: {Y}/10
- Vocabulary: {Z}/10
- Structure: {W}/10
- Communication: {V}/10

---
```

### 7. Optional rewrite

If score < 7, offer:

```markdown
**Want to try again?** Rewriting with the corrections locks in the patterns.

Type "rewrite" to try again, or "next" to continue.
```

### 8. Session summary

```markdown
## 📊 Writing Session Summary

**Text Type:** {type}
**Score:** {X}/10
**Key Takeaways:**
- {learning 1}
- {learning 2}
- {learning 3}

**Next Time:**
- Focus on: {weak pattern}
- Review: {relevant flashcards}

{target-language "well done"}! ✍️
```

### 9. Update all databases

Use the `fluent-db-updater` skill:

- `command_used: "/fluent-writing"`, `skills_practiced: ["writing"]`
- `skill_scores.writing: {exercises: 1, correct: 1_if_score_≥_7_else_0, time_minutes}`
- `errors[]` — one per distinct pattern found (dedupe; the script bumps frequency)
- `focus_next_session[]` — top 2 patterns to drill

Also save the exchange as `/results/fluent-writing-session-{NNN}.md` with the full task, the learner's original text, the corrected version, and the error table. The `fluent-session-analyzer` skill depends on this format.

## Examples

### Example 1 — formal email task (Dutch A2)

> ## ✍️ Writing Exercise
>
> **Scenario:** You need to cancel a doctor's appointment you have on Thursday.
>
> **Task:** Write a formal email to the doctor's office in Dutch.
>
> **Requirements:**
> - Length: 40-60 words
> - Include: greeting, reason, request for new appointment, closing
> - Register: formal
> - Level: A2
>
> **Write your email below:**

Learner: "Hallo, Ik schrijf je omdat ik kan niet komen op donderdag. Ik ben ziek. Kunnen we een andere dag afspreken? Bedankt, Mohammad"

> ## Feedback
>
> ### ✅ What You Did Well
> - Clear reason for cancellation.
> - Correct request structure.
>
> ### ❌ Areas to Improve
>
> **Critical:** 🔴
> - `formal_informal`: "Hallo" + "je" — formal email needs "Beste meneer/mevrouw" + "u". Mixed registers cost exam points.
> - `grammar`: "ik kan niet komen" is OK standalone, but after "omdat" Dutch word order flips: **"omdat ik niet kan komen"**.
>
> **Moderate:** 🟡
> - `missing`: no formal closing. Use "Met vriendelijke groet,".
>
> **Minor:** 🟢
> - Capitalize "Donderdag"? Actually no — Dutch doesn't capitalize weekdays. You were right.
>
> ### 📝 Corrected Version
>
> ```
> Beste meneer/mevrouw,
>
> Ik schrijf u omdat ik niet kan komen op donderdag. Ik ben ziek.
> Kunnen we een andere dag afspreken?
>
> Met vriendelijke groet,
> Mohammad
> ```
>
> **Score: 6/10**
> - Grammar: 6/10 — omdat word order tripped you up.
> - Vocabulary: 8/10 — solid word choice.
> - Structure: 5/10 — missing proper opening + closing.
> - Communication: 7/10 — message was clear despite issues.

## Critical Rules

- **One scenario per session.** Don't chain multiple writing tasks — depth over breadth.
- **Wait for the full answer** before correcting.
- **Severity tagging is mandatory.** Fed into `mistakes-db` and drives spaced repetition priority.
- **Always save the session file** in `/results/` for later analysis by `fluent-session-analyzer`.
- **Never auto-invoke.** This skill is gated; must fire only on explicit `/fluent-writing`.

## Language Reference

### Dutch A2 patterns

**Formal emails:** always "u" (not "je"); open `Beste meneer/mevrouw {NAME},`; closing `Met vriendelijke groet,` + name.

**Informal emails:** "je" not "u"; open `Hallo {NAME},`; closing `Groetjes,` or `Tot snel,`.

**Common mistakes:** mixing formal/informal in one text; word order in `omdat` clauses (verb last); time expressions (`om 10:00 uur`, `op dinsdag`).

Add similar sections for other target languages as the learner needs them.

---

## The fluent-db-updater skill (included)

# DB Updater

## Overview

Every practice skill ends with a DB update. Instead of hand-editing 6 JSON files (error-prone, racy, easy to desync), pipe one JSON report to `update-db.py`. The script runs pre-write backups, validates the payload, applies all changes atomically via `.tmp + fsync + rename`, and rebuilds the spaced-repetition queue.

## When to Use

Load this skill whenever the tutor:

- Finishes a practice session and needs to persist results.
- Needs to add new vocabulary to the spaced-repetition queue.
- Needs to record new errors, review results, or mastery changes.
- Needs to bump `total_sessions`, `current_streak_days`, or `total_study_minutes`.

Skip this skill for read-only operations (use the `fluent-progress` skill or `read-db.py` directly) and during session setup (use `fluent-setup` skill instead — `update-db.py` is for session deltas, not bootstrap).

## Instructions

### 1. Call the script

Run from the repo root:

```bash
python3 "${CLAUDE_PLUGIN_ROOT:-${CLAUDE_PROJECT_DIR:-.}}/.claude/hooks/update-db.py" <<'EOF'
{ ...payload... }
EOF
```

Exit codes: `0` success, `1` validation error, `2` I/O error.

### 2. Fill the payload

**Required fields**

- `session_id` — string, convention `session-NNN`. Use `computed.next_session_id` from `read-db.py`.
- `date` — YYYY-MM-DD.

**Optional fields** — omit to skip. Full canonical example (copy-paste this and fill in):

```
${CLAUDE_PLUGIN_ROOT:-${CLAUDE_PROJECT_DIR:-.}}/.claude/references/db-updater-payload.example.json
```

Key blocks the example covers: `skill_scores`, `errors[]`, `new_vocabulary[]`, `review_results[]`, `topics_covered`, `breakthroughs`, `focus_next_session`, `session_notes`, `achievements_earned`, `milestones`.

### 3. Field notes

- `errors[]` — one entry per distinct mistake this session. Collapse duplicates (same `pattern_id`) before sending; `frequency` is bumped by the script.
- `new_vocabulary[]` — items the learner met for the first time. Fill every field; incomplete entries yield incomplete spaced-repetition records.
- `review_results[]` — items already in the queue that were reviewed. The script runs SM-2 on each. See the `fluent-sm2-calculator` skill. Mapping: `quality = floor(score / 2)`.
- `skill_scores[].correct` counts correct exercises, not a percentage. Accuracy is derived.
- `confidence` in `learner-profile.skills` is 0–100 integer; `accuracy` in `progress-db` is 0.0–1.0 float. The script handles the conversion.
- `milestones[]` — each entry is a bare string OR an object `{ "milestone": <required non-empty string>, "date": <optional YYYY-MM-DD, defaults to the session date> }`. Don't set a nested `session_id`; the script stamps the authoritative top-level one. A malformed entry (neither string nor object, or an object missing/empty `milestone`) exits `1` with no files written. Each milestone becomes both a `session-log.milestones[]` record and a `learner-profile.achievements[]` entry.

### 4. Read before writing

Always call `read-db.py` at session start to get current state + `next_session_id`. Don't read each JSON file separately:

```bash
python3 "${CLAUDE_PLUGIN_ROOT:-${CLAUDE_PROJECT_DIR:-.}}/.claude/hooks/read-db.py"
```

Returns all 6 databases plus computed fields (`due_reviews_count`, `next_session_id`, `streak_active`, `days_since_last_session`).

## Examples

### Example 1 — /fluent-review session with 5 items

```bash
python3 "${CLAUDE_PLUGIN_ROOT:-${CLAUDE_PROJECT_DIR:-.}}/.claude/hooks/update-db.py" <<'EOF'
{
  "session_id": "session-012",
  "date": "2026-04-24",
  "duration_minutes": 12,
  "command_used": "/fluent-review",
  "skills_practiced": ["vocabulary", "grammar"],
  "skill_scores": {
    "vocabulary": { "exercises": 3, "correct": 3, "time_minutes": 7 },
    "grammar":    { "exercises": 2, "correct": 1, "time_minutes": 5 }
  },
  "review_results": [
    { "item_id": "vocab_huis", "quality": 5 },
    { "item_id": "vocab_deur", "quality": 4 },
    { "item_id": "vocab_raam", "quality": 5 },
    { "item_id": "grammar_omdat_word_order", "quality": 2 },
    { "item_id": "grammar_past_tense", "quality": 4 }
  ],
  "errors": [
    {
      "pattern_id": "grammar_omdat_word_order",
      "category": "grammar",
      "your_answer": "omdat ik ben moe",
      "correct_answer": "omdat ik moe ben",
      "context": "subordinate clause word order",
      "severity": "critical"
    }
  ],
  "focus_next_session": ["Drill 'omdat' word order"]
}
EOF
```

### Example 2 — /fluent-vocab session with a new word

```bash
python3 "${CLAUDE_PLUGIN_ROOT:-${CLAUDE_PROJECT_DIR:-.}}/.claude/hooks/update-db.py" <<'EOF'
{
  "session_id": "session-013",
  "date": "2026-04-25",
  "command_used": "/fluent-vocab",
  "skills_practiced": ["vocabulary"],
  "new_vocabulary": [
    {
      "item_id": "vocab_keuken",
      "item_type": "vocabulary",
      "content": "de keuken",
      "answer": "the kitchen",
      "category": "household_rooms",
      "difficulty": "A1",
      "initial_quality": 4,
      "priority": "medium"
    }
  ]
}
EOF
```

## Critical Rules

- **Call once per session, at the end.** The script rebuilds the review queue each run — partial updates risk inconsistency.
- **Never hand-edit `spaced-repetition.review_queue`.** It's regenerated from scratch on every run.
- **Same `session_id` replaces.** Sending the same ID twice overwrites the first call. Useful for corrections, dangerous if unintentional.
- **Backups are automatic.** Written to `.backups/pre-update-<session_id>/` before any change. Check there to roll back.
- **Exit code 1 means validation failed, no files touched.** Fix the payload and retry.
- **Exit code 2 means I/O failure, no files touched.** Check disk space, permissions, then retry.

## Why This Matters

Six interdependent JSON files must agree: a new `session-log` entry, a bumped `total_sessions`, updated SM-2 params, new mistake patterns, recalculated accuracy, refreshed streak. Hand-editing causes silent desync — streak says 7 days but session-log has 6 entries, mastery says 4 stars but accuracy says 45%. The script is the single source of truth.
