python-syntax-tutor

A Python syntax tutor that explains unfamiliar language features in the code where they appear. Python is a programming language; examples include decorators, async code, generators, and type hints.

In plain words
What is it for?
Use it to explain why a particular Python construct is used, what it does there, and what common pitfalls to watch for.
Why use it?
It helps readers understand code that uses advanced or easy-to-misread Python notation without turning the explanation into a general course.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/swhee/diffscope/python-syntax-tutor
Any agent
npx skills add SWHee/diffscope --skill python-syntax-tutor
Clone the repo
git clone --depth 1 https://github.com/SWHee/diffscope

Made for: Claude Code, Codex.

Per session 238 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,673 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00238 $0.01673
Opus 5 $0.00119 $0.00837
Sonnet 5 $0.00048 $0.00335
Haiku 4.5 $0.00024 $0.00167

Measured yesterday against content hash 8a2fd1387d24, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

python-syntax-tutor scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/python-syntax-tutor/SKILL.md · 105 lines

How it starts

The opening of the file, as written. The whole thing — 105 lines — stays where its author put it; the contents beside it link to each section on GitHub.

python-syntax-tutor — Python 문법 해설

Python 코드를 읽다 막힌 사람에게 그 자리에서 필요한 만큼만 설명한다. 문법 강의가 아니라 눈앞의 코드에 붙이는 주석에 가깝다.

왜 이 스킬이 필요한가

코딩 에이전트가 쓴 Python은 숙련자용 이디엄을 거리낌 없이 쓴다. 데코레이터가 제어 흐름을 감추고, 타입 힌트가 실제 동작과 무관해 보이고, yield가 함수의 반환 개념을 바꿔 놓는다. 로직은 따라가도 표기에서 막히면 코드가 통째로 불투명해진다. 이 스킬은 그 표기만 걷어낸다.

해설 원칙

1. 일반론이 아니라 이 코드의 설명

@lru_cache를 만나면 캐시 이론이 아니라 이 함수에 왜 붙었는지부터 말한다. 일반화는 그 뒤에 한 줄로 붙인다. 순서를 뒤집으면 학습자는 자기 코드와 설명을 연결하지 못한다.

1. 이 자리에서 하는 일     ← 2~3줄
2. 안 썼으면 어떻게 됐을지  ← 1줄
3. 최소 예시              ← 3~6줄
4. 언제 쓰는 문법인가      ← 1줄

2. 고를 줄 아는 것이 실력

전부 설명하면 아무것도 설명하지 않은 것과 같다. 모르면 코드 흐름을 잘못 읽게 되는 것만 고른다. for, if, def, 단순한 표준 라이브러리 호출은 설명하지 않는다.

우선순위:

  1. 제어 흐름을 숨기는 것 — 데코레이터, 컨텍스트 매니저, 제너레이터, async
  2. 함정 — 가변 기본 인자, 늦은 바인딩, 얕은 복사, is vs ==
  3. 이름으로 동작을 알 수 없는 것 — dunder, 디스크립터, 메타클래스
  4. 타입 표기Protocol, TypeVar, Literal, overload
  5. 최신 문법match, :=, dataclass 옵션

한 번에 3~5개. 함정은 개수 제한과 무관하게 반드시 포함한다.

3. 예시는 그 코드의 이름으로

foo/bar로 쓴 예시는 원본과 연결되지 않아 기억에 남지 않는다. 설명 중인 코드의 함수명·변수명을 그대로 써서, 예시가 곧 그 코드의 축소판이 되게 한다.

4. 추측하지 말고 실행한다

"아마 이렇게 될 것"이라고 쓰고 싶어지면 python3 -c '...'로 확인한다. Python은 직관을 배신하는 구석이 많다(스코프, 평가 시점, 복사 깊이). 틀린 문법 설명은 아무 설명도 없는 것보다 나쁘다 — 학습자가 그걸 믿고 계속 간다.

확인할 수 없으면 "확실하지 않음"이라고 밝힌다.

5. 프로젝트 고유 문법은 정의부를 읽는다

@retry, @app.route 같은 것은 Python 문법이 아니라 그 프로젝트/라이브러리의 데코레이터다. 일반론으로 넘기지 말고 Grep으로 정의부를 찾아 실제로 무슨 일을 하는지 읽고 설명한다. 찾지 못하면 그 사실을 밝힌다.

참조 자료

깊이가 필요할 때만 해당 파일을 읽는다. 전부 읽지 않는다 — 대부분의 해설은 이 SKILL.md만으로 충분하고, 참조는 설명이 얕아질 때만 연다.

등장 요소 파일
데코레이터, @property, functools, 디스크립터, 메타클래스 references/decorators-and-descriptors.md
타입 힌트, 제네릭, Protocol, TypeVar, overload, Self references/typing-and-generics.md
async/await, 이벤트 루프, gather, 스레드/GIL references/async-and-concurrency.md
제너레이터, yield, 이터레이터, 컴프리헨션, itertools references/iterators-and-comprehensions.md
dunder 메서드, dataclass, 연산자 오버로딩, __slots__ references/dunder-and-data-model.md
가변 기본 인자, 늦은 바인딩, 복사, 스코프, is vs == references/gotchas.md

Read the full file on GitHub · 105 lines

Files

What ships with it

6 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 105 lines · 238 tokens per session scan A 8a2fd1387d24

Subscribe to this mod's changes

python-syntax-tutor is a skill published in the GitHub repository SWHee/diffscope (1 stars, last pushed 29d ago), licensed MIT. It adds 238 tokens to every session and 1,673 once invoked, about $0.0012 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

revdiff

Review diffs, files, and documents with inline annotations in a TUI overlay, or answer questions about revdiff usage, configuration, themes, and keybindings. Opens revdiff in tmux/zellij/herdr/kitty/wezterm/cmux/ghostty/iterm2/emacs-vterm, captures annotations, and addresses them. Works in git, hg, and jj repos…

umputun/revdiff · 246 tokens

revdiff-plan

Review the last Codex assistant message (plan, analysis, or proposal) with inline annotations in a TUI overlay. Extracts the most recent response from Codex rollout files and opens it in revdiff for review and annotation. Activates on "revdiff-plan", "review plan with revdiff", "annotate plan", "review last response"…

umputun/revdiff · 84 tokens

blazediff

Run, author, or update BlazeDiff visual regression tests. Trigger on "visual test", "screenshot regression", "blazediff", "/blazediff".

teimurjan/blazediff · 37 tokens

hooks-eval

Evaluate hook security, performance, and SDK compliance. Use for audits.

athola/claude-night-market · 18 tokens

add-pattern

Add a new conflict-resolution pattern to GitWand core. Use this skill whenever someone wants to add a pattern, resolution rule, new conflict case, new heuristic, teach the resolver to handle a new kind of conflict automatically, or extend the pattern registry with a new ConflictType.

devlint/GitWand · 59 tokens

add-resolver

Add a format-specific resolver to GitWand core. Use this skill whenever someone wants to add support for a new file format, file extension, lockfile, config file type, or format-specific conflict resolution strategy. Triggers: "add resolver for .prisma", "handle composer.lock conflicts", "resolve .tf files", "new…

devlint/GitWand · 90 tokens