with one click
pytextgen
// Regenerate programmatically-generated content blocks in knowledge base notes using pytextgen.
// Regenerate programmatically-generated content blocks in knowledge base notes using pytextgen.
Content conventions, examples, and tooling for course notes under special/academia.
Repository-wide tooling including init wrapper, pack/publish utilities, and all helper scripts. Links to tools-special and tools-templates for subfolder details.
Ingest Wikipedia HTML, normalize links/media, and archive to knowledge base.
Help the user add spaced-repetition flashcards (cloze deletions or Q/A pairs) to existing Markdown notes across the repository. The skill encapsulates the multi‑step process the user follows in their finance lecture notes (e.g. FINA 3103) and elsewhere: read the prose, identify key terms, dates, formulas and logical assertions, and wrap them using flashcard markup (`{@{ }@}`, `::@::`, `:@:`). There are three supported forms: - **Cloze** (`{@{ }@}`) hides arbitrary text inside paragraphs. - **Two-sided QA** (`::@::`) on a single line, yielding two cards. - **One-sided QA** (`:@:`) on a single line, yielding a single card. For the QA formats remember the line-only rule; if visual separation is needed insert `<br/>`/`<p>` instead of newline characters. Representative examples later in this document illustrate all three types. Use existing flashcard files as style guides and adapt the output based on user feedback. The skill also suggests regeneration commands once flashcards are inserted.
Archive online content into archives/ with automatic index.md updates via pyarchivist tool.
| name | pytextgen |
| description | Regenerate programmatically-generated content blocks in knowledge base notes using pytextgen. |
Continuous improvement: see
continuous_improvement.mdin this folder for documented lessons and evolving best practices.
Use this skill when working with pytextgen-powered content generation, including regenerating flashcards, clearing generated regions, managing caches, and debugging generation issues.
Agent note: the examples below describe how the
init generatetool works when a human runs it. Agents should not trigger this command on their own while editing notes—flashcard and other generated content are rebuilt automatically during normal build and packaging workflows.
pytextgen is a Python library (git submodule in scripts/pytextgen/) that generates content programmatically in Markdown files:
{@{ }@}, ::@::, :@:)Command: uv run -m init generate [pytextgen flags] <paths?>
The init.py wrapper:
.md files (excluding .git, .obsidian, tools)(mtime, inode, text) to skip unchanged files\n before passing to pytextgenCommon flags:
-C / --no-cached: Rebuild init.py cache from scratch--no-code-cache: Disable pytextgen compile cache (in __pycache__/)--init-flashcards: Initialize or re-seed flashcard state<paths>: Optional; limit regeneration to specific files/directoriesExample: uv run -m init generate -C --init-flashcards
Command: uv run -m init clear --type CONTENT <paths?>
Clears generated content blocks without regenerating. Useful for:
Other ClearType values (see scripts/pytextgen/io.py):
CONTENT: Clear generated text onlyUse templates in scripts/templates/ to create new pytextgen fences:
pytextgen generate flashcards.md: Flashcard section templatepytextgen generate code.md: Code block template# pytextgen generate module="path.to.module" function="function_name"
# pytextgen generate data="./relative/path/to/data.json" format="table"
Critical rules:
# pytextgen generate ... comment linereturn export_seq(...) signatures exactly<!--pytextgen generate section="unique-id" format="list"-->
Generated content appears here
<!--/pytextgen-->
Critical rules:
pytextgen recognises three distinct patterns that drive flashcard creation. Keep them exactly as shown and understand their semantics:
Cloze flashcards use {@{hidden text}@}. The text between the
delimiters is hidden during review and replaced with a blank that the user
must recall. Clozes may appear anywhere in a paragraph and multiple clozes
can coexist on a single line.
Two-sided cards use a single line with a separator ::@::. Example:
term ::@:: definition. Two cards are generated: one showing the left
side and asking for the right, and vice versa. The entire source must be
on one Markdown line; visual breaks are represented with <br/> or <p>.
One-sided cards use a single line with separator :@:. Only one card
is produced (recall right side from left). The same single-line rule
applies.
Editing guidance:
{@{ }@} and around the ::@:: or :@:
separators.(The earlier term "cloze markup" is retained only for historical reasons.)
Syntax errors in fence comments:
# pytextgen generate ... linesFence delimiters broken:
Cache issues:
-C / --no-cached to rebuild init.py cache--no-code-cache to bypass pytextgen compile cache__pycache__/ for stale compiled modulesCloze markup broken:
{@{ }@} pairs are balanced::@::, :@:) are not modified# Regenerate with fresh caches
uv run -m init generate -C --no-code-cache
# Clear and regenerate specific file
uv run -m init clear --type CONTENT path/to/file.md
uv run -m init generate path/to/file.md
# Check for syntax errors (manual inspection)
grep -n "# pytextgen generate" path/to/file.md
-C when unsure if cache is stale--init-flashcards when creating new flashcard-enabled notesgit submodule update --remote scripts/pytextgen)scripts/pytextgen/**, ask user for permission (it's a submodule)convert_wiki, use init generate to create flashcards from cloze markuptemplates section of tools/SKILL.md for fence templates