SuperAPI AI Directory

csl

Writing & research

View repository

Updated 10-15 20:28

About this skill

CSL Style Generator

All templates, parameters, and rules are located under the ${CLAUDE_SKILL_DIR} directory.

The following path constants run through the entire workflow:

Constant Path
Preset directory ${CLAUDE_SKILL_DIR}/presets/
Component directory ${CLAUDE_SKILL_DIR}/components/
Validation script ${CLAUDE_SKILL_DIR}/scripts/validate_csl.py
Preview script ${CLAUDE_SKILL_DIR}/scripts/preview_csl.py
Validation rules ${CLAUDE_SKILL_DIR}/validate/rules.md
Output directory ${CLAUDE_SKILL_DIR}/output/

Step 0: Collect information

Analyze user input $ARGUMENTS, and determine whether the information is sufficient. If it is insufficient,you must first confirm the following with the user before starting generation:

  1. In-text citation method(choose one of three, determining the CSL class and citation configuration):

    • Superscript marker: In the text, [1-3] appears in superscript form → class="in-text", vertical-align="sup"
    • Inline number: In the text, [1-3] appears on the same line and at the same font size as the text → class="in-text"
    • Footnote/endnote: Insert a footnote marker in the text, and the citation content appears in the footer or at the end of the document → class="note"
  2. Reference list examples: The user must provide at least 2-3 original references of different types (journal, book, conference, etc.), used to infer format parameters.

  3. In-text citation examples(optional): Original paragraph containing citation markers, used to confirm the citation style.

If the user has already provided the above information (such as pasted references and body text), proceed directly to Step 1 for analysis.

Step 1: Parse requirements

Extract format requirements from user input and match preset keywords:

Keyword Preset file
GB/T 7714, national standard, Chinese numeric citation gbt7714-numeric.md
GB/T 7714 author-date, author-date gbt7714-author-date.md
APA apa7.md
Chicago Notes, Chicago footnotes chicago-notes.md
IEEE ieee.md
MLA mla9.md
Chinese humanities and social sciences note, footnote style chinese-note.md
  • Matched → proceed to Step 2a
  • Not matched → proceed to Step 2b (infer parameters from the user's description or reference examples)

Step 2: Read recipe

2a Preset path: Read ${CLAUDE_SKILL_DIR}/presets/{preset}.md, and obtain all parameters.

2b Custom path: Read component templates under ${CLAUDE_SKILL_DIR}/components/ as needed:

Component File Responsibility
Author name.md Name format, et-al, sorting
Title title.md Italics/quotation marks/book title marks
Date date.md Year/month/day format
Journal/book container container.md Journal name, book title format
Volume, issue, pages locators.md Volume/issue/page format
Publication information publisher.md Place of publication, publisher
DOI/URL access.md Electronic resource access information
In-text citation citation.md citation layout
Reference list bibliography.md bibliography layout
Chinese terms locale-zh.md Chinese localized terms
English terms locale-en.md English localization terminology

Selectively read relevant components according to user needs; no need to load all of them.

Step 3: Generate CSL

Assemble the complete .csl file according to the following skeleton:

style (xmlns, class, version, default-locale)
  ├── info (title, id, category, updated)
  ├── locale × N (术语覆盖)
  ├── macro × N (按组件模板填充)
  ├── citation (正文引用 / 脚注)
  └── bibliography (参考文献列表)
  • The XML implementation of each macro is obtained from the component templates, and attribute values are adjusted according to the preset parameters
  • Output to ${CLAUDE_SKILL_DIR}/output/{style-name}.csl

Step 4: Validate

python ${CLAUDE_SKILL_DIR}/scripts/validate_csl.py <file>
  • The script outputs results in JSON format
  • If "status": "FAIL", fix according to errors and validate again until PASS
  • Read ${CLAUDE_SKILL_DIR}/validate/rules.md for supplementary review (common pitfalls check)

Step 5: Preview

python ${CLAUDE_SKILL_DIR}/scripts/preview_csl.py <file>
  • Show the actual rendered result to the user
  • Wait for user confirmation, or return to Step 3 to modify based on feedback

Step 6: Modify an existing style (optional)

When the user provides an existing .csl file and requests modifications:

  1. Read the file and locate the parts that need modification
  2. Modify by referring to the corresponding component template
  3. Re-execute Step 4 + Step 5