tools/templates Workflows
Use this skill when scaffolding new notes, creating pytextgen sections, or using pre-built templates for knowledge base content.
What tools/templates contains
The tools/templates/ directory contains scripts for scaffolding new content:
- •
new wiki page.py: Generate YAML frontmatter + Wikipedia link template for encyclopedia notes - •
pytextgen generate *.md: Templates for common pytextgen fence patterns
When to use
- •Creating new encyclopedia notes with proper frontmatter
- •Scaffolding pytextgen sections (flashcards, code blocks, data exports)
- •Ensuring consistent YAML structure across notes
- •Quick-starting new knowledge base entries
Workflows
Scaffold a new wiki-sourced note
Purpose: Create a new encyclopedia note with pre-filled frontmatter and Wikipedia attribution.
Command: python -m "templates.new wiki page"
Workflow:
- •
Script prompts for article name (or reads from argument)
- •
Generates YAML frontmatter template:
yaml--- aliases: [] tags: [flashcard/active, language/in/English] ---
- •
Adds Wikipedia source link comment:
markdown<!-- Source: https://en.wikipedia.org/wiki/Article_Name -->
- •
Copies template to clipboard
- •
User pastes into new file in
general/(orspecial/if specialized)
Next steps:
- •Use
python -m "convert wiki"to ingest Wikipedia HTML below the template - •Add content manually or from other sources
- •Update
aliasesandtagsas needed
Create pytextgen flashcard section
Template: tools/templates/pytextgen generate flashcards.md
Purpose: Scaffold a new flashcard generation section in an existing note.
Content (example):
## Flashcards <!--pytextgen generate section="flashcards-main" format="cloze"--> <!--/pytextgen-->
Usage:
- •Copy template content from
tools/templates/pytextgen generate flashcards.md - •Paste into target note
- •Update section ID (
flashcards-main→ unique identifier) - •Add cloze markup to note content:
{@{ hidden text }@},::@::,:@: - •Run
python -m init generate <file>to populate flashcards
Create pytextgen code block section
Template: tools/templates/pytextgen generate code.md
Purpose: Scaffold a Python code block that generates Markdown content.
Content (example):
```python
# pytextgen generate module="data.courses" function="generate_course_list"
def generate_course_list():
courses = [...]
return export_seq(courses)
```
Usage:
- •Copy template from
tools/templates/pytextgen generate code.md - •Paste into target note
- •Update module/function references
- •Implement generation logic
- •Run
python -m init generate <file>to execute and insert output
Other templates
Additional templates may exist for:
- •Data export fences (JSON/CSV → Markdown tables)
- •Cross-reference generators (link indexes, backreferences)
- •Structured list generators (course lists, bibliography)
Check tools/templates/ directory for all available templates.
Template conventions
YAML frontmatter
Standard fields:
- •
aliases: Alternative names for the note (list) - •
tags: Categories and metadata (list)- •
flashcard/active: Enable flashcard generation - •
language/in/English: Note language (orlanguage/in/Korean, etc.) - •Semester tags:
2023-fall,2024-spring - •Subject tags:
coursework,tutorial,business
- •
Example:
--- aliases: [GDP, Gross Domestic Product] tags: [flashcard/active, language/in/English, economics] ---
pytextgen fence templates
Critical rules (inherited from pytextgen conventions):
- •Do NOT modify
# pytextgen generate ...comment lines in templates - •Do NOT change fence delimiters (triple backticks + language)
- •Preserve section IDs in HTML comments (
<!--pytextgen generate section="id"-->) - •Keep
return export_seq(...)signatures intact
Placeholder protection:
- •Templates may use
{{placeholder}}or<REPLACE_ME>for user-editable parts - •Replace placeholders before running generation
- •Never commit templates with unresolved placeholders into content notes
Integration with other workflows
wiki-ingestion workflow
- •Run
python -m "templates.new wiki page"to create frontmatter - •Paste template into new file
general/Article Name.md - •Run
python -m "convert wiki"to ingest Wikipedia HTML - •Content is appended below frontmatter
- •Run
python -m init generate <file>to create flashcards from cloze markup
Academic coursework workflow
- •Use LMS converters (
tools-specialskill) to generate course YAML - •Use templates to scaffold course
index.mdwith sections - •Add pytextgen fences for assignment lists, grade tables
- •Regenerate with
python -m init generate
Custom content generation
- •Copy appropriate pytextgen template
- •Implement Python function or reference existing module
- •Update fence comment with correct module/function path
- •Test generation with
python -m init generate <file> - •Debug any errors (see
pytextgenskill for troubleshooting)
Best practices
- •Consistent frontmatter: Use templates to ensure YAML structure matches conventions
- •Template versioning: If templates change, update existing notes gradually
- •Section IDs: Use descriptive, unique IDs for pytextgen sections (e.g.,
flashcards-chapter-1) - •Template testing: Test new templates on dummy files before using in production notes
- •Documentation: Comment template files with usage instructions
When to ask for help
- •If template placeholders are unclear, ask user for guidance
- •If new template patterns are needed, discuss requirements with user
- •If pytextgen fence syntax is complex, refer to
pytextgenskill
Common issues
- •Placeholder leakage: Forgot to replace
{{placeholder}}before generation - •Section ID collisions: Multiple pytextgen sections with same ID in one file
- •Fence syntax errors: Broken fence delimiters or comment lines
- •Module import errors: Python module paths incorrect in fence comments
Editing guidelines for tools/templates/**
When editing files in tools/templates/:
- •Preserve placeholder tokens: Keep tokens like
(name),(Wikipedia name),(tag name)intact; do not hardcode example values - •Maintain clipboard-copy behavior: Python templates like
new wiki page.pyshould keep clipboard copying and normalization/replacement maps intact unless fixing bugs - •Keep pytextgen fence syntax: Never modify template fences/comments (
# pytextgen generate ...,<!--pytextgen generate section="..."-->) - •Avoid filename changes: Downstream scripts expect specific file names and extensions; changing them may break workflows
- •Use UTF-8 encoding: Keep newline handling as-is and avoid rewrapping markdown bodies in templates
- •Document changes: If template structure changes, note impact on existing notes and update documentation