# Japanese Anki

> Use when the user wants to turn a Japanese sentence into two Anki cards inside Codex, without calling the OpenAI API separately. This skill generates 2 natural Japanese rewrites, 2 realistic usage scenarios in Chinese, and a short Chinese explanation, shows the result to the user, asks for confirmation, and then adds the cards to Anki via AnkiConnect.

- Skill: `dongdongcai/japanese-anki` (Agent Skill, multi-file: 3 files)
- Install (CLI): `npx skillmds@latest add dongdongcai/japanese-anki`
- Raw SKILL.md: https://api.skillmd.com/api/skills/dongdongcai/japanese-anki/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Integrations & APIs
- Author: dongdongcai (https://skillmd.com/u/dongdongcai)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/dongdongcai/japanese-anki

---


# Japanese Anki

## Overview

Use this skill when the user wants an end-to-end Codex workflow for turning one Japanese sentence into two Anki cards. Codex should generate the language content directly, ask for confirmation before writing anything, and then use the bundled script to add the notes through AnkiConnect.

## Workflow

1. Take one Japanese sentence from the user.
2. Generate exactly these items in the chat:
- 2 natural Japanese rewrites
- 2 realistic usage scenarios in Chinese
- 1 short explanation in Chinese about nuance and usage
3. Show the generated content clearly.
4. Ask the user whether to add the cards to Anki.
5. Only after the user confirms, call `scripts/add_anki_notes.py` to create the notes.

## Output Requirements

Keep the generated content concise and natural.

- Rewrites:
  They should sound like something a native speaker would actually say in everyday context. Avoid stiff textbook phrasing unless the original sentence is formal.
- Scenarios in Chinese:
  They should describe realistic situations, not generic labels. Short is fine.
- Explanation in Chinese:
  Keep it brief and practical. Focus on tone, nuance, or where the sentence fits naturally.

## Card Format

Create exactly two Anki notes using the configured deck and note type.

Card 1:
- Front: the two Chinese usage scenarios
- Back: the two Japanese rewrites

Card 2:
- Front: the original Japanese sentence
- Back: the Chinese explanation plus the two Japanese rewrites

The helper script expects this JSON shape:

```json
{
  "original_sentence": "今日は早めに失礼しよかと",
  "rewrites": [
    "今日は先に失礼しますね",
    "今日はちょっと早めに帰ろうかな"
  ],
  "scenarios_zh": [
    "下班时对同事这样说",
    "和朋友聊天时表示今天想早点走"
  ],
  "explanation_zh": "这句话比较口语，带有一点试探和自言自语的感觉。"
}
```

## Running The Helper

Use the bundled script:
- [add_anki_notes.py](./scripts/add_anki_notes.py)

Recommended flow:
1. Write the JSON payload to a temporary file in `/tmp`.
2. Run:
   `python3 /Users/dongdong/.codex/skills/japanese-anki/scripts/add_anki_notes.py /tmp/<payload>.json`
3. Report success or any error returned by the script.
4. Delete the temporary JSON payload from `/tmp` after the script returns.

## Configuration

The helper script reads these optional environment variables:

- `ANKI_CONNECT_URL`
  Defaults to `http://localhost:8765`
- `ANKI_DECK`
  Defaults to `Japanese Reading`
- `ANKI_NOTE_TYPE`
  Defaults to `Basic`

Assume `Basic` unless the user explicitly wants a different note type.

## Failure Handling

If Anki is not open or AnkiConnect is unavailable, explain that clearly and do not pretend the notes were added.

If the note type is missing or incompatible with `Front` and `Back`, tell the user to switch to `Basic` or provide a compatible note type.

If the deck is missing, the helper script will try to create it first.

Always clean up the temporary payload file after execution, even if note creation fails.

