Skip to content

LeoYeAI/agent-master-skills / skills/biomedical-paper-billing

biomedical-paper

Verified

AI-powered biomedical manuscript generation with docx output. Activates when user provides Chinese draft/outline and requests full English research paper. Includes: Abstract, Introduction, Methods, Results, Discussion, References. Specialized for: GBD epidemiology, cohort studies (CHARLS/NHANES), cross-sectional mediation analyses, pharmacovigilance (FAERS). Also supports: Chinese graduate/doctoral thesis (学位论文) formatting. Features: python-docx generation, Vancouver numbered references, journal-specific formatting. Confidence: High (validated workflow with 30+ successful papers)

FileKindSize
SKILL.mdskill md19.7 KB
_meta.jsonconfig309 B
assets/docx_builder.pyscript7.0 KB
package.jsonmanifest442 B
references/section-templates.mdmarkdown6.0 KB
references/style-guide.mdmarkdown2.0 KB

assets/docx_builder.py

View on GitHub
#!/usr/bin/env python3
"""
docx_builder.py — Reusable Word document builder for biomedical manuscripts.

Usage:
    from assets.docx_builder import ManuscriptBuilder
    mb = ManuscriptBuilder()
    mb.title("My Paper Title")
    mb.running_title("Short Running Title")
    mb.section("Abstract")
    mb.abstract_label("Background", "GBS is ...")
    mb.body("Regular body paragraph text...")
    mb.section("Introduction")
    mb.body("First paragraph...")
    mb.subsection("Data Source")
    mb.body("Methods paragraph...")
    mb.reference_list(["1. Author A. Title. Journal. 2024;..."])
    mb.save("/workspace/output.docx")
"""

from docx import Document
from docx.shared import Pt, Inches, Cm
from docx.enum.text import WD_ALIGN_PARAGRAPH
import re


class ManuscriptBuilder:
    def __init__(self):
        self.doc = Document()
        # Page margins
        for section in self.doc.sections:
            section.top_margin    = Cm(2.54)
            section.bottom_margin = Cm(2.54)
            section.left_margin   = Cm(3.17)
            section.right_margin  = Cm(3.17)
        # Base style
        normal = self.doc.styles['Normal']
        normal.font.name = 'Times New Roman'
        normal.font.size = Pt(11)
        normal.paragraph_format.space_after = Pt(0)

    # ── Inline markup ─────────────────────────────────────────
    def _inline(self, para, text, size=11):
        """Parse **bold** and *italic* and add runs to para."""
        for part in re.split(r'(\*\*[^*]+?\*\*|\*[^*]+?\*)', text):
            if part.startswith('**') and part.endswith('**'):
                r = para.add_run(part[2:-2]); r.bold = True
            elif part.startswith('*') and part.endswith('*'):
                r = para.add_run(part[1:-1]); r.italic = True
            else:
                r = para.add_run(part)
            r.font.name = 'Times New Roman'
            r.font.size = Pt(size)

    # ── Paragraph types ───────────────────────────────────────
    def title(self, text):
        p = self.doc.add_paragraph()
        p.alignment = WD_ALIGN_PARAGRAPH.CENTER
        p.paragraph_format.space_after = Pt(6)
        r = p.add_run(text); r.bold = True
        r.font.name = 'Times New Roman'; r.font.size = Pt(13)

    def running_title(self, text):
        p = self.doc.add_paragraph()
        p.alignment = WD_ALIGN_PARAGRAPH.LEFT
        p.paragraph_format.space_after = Pt(12)
        self._inline(p, text)

    def section(self, text):
        """Top-level section heading (Abstract, Introduction, Methods…)."""
        p = self.doc.add_paragraph()
        p.alignment = WD_ALIGN_PARAGRAPH.LEFT
        p.paragraph_format.space_before = Pt(10)
        p.paragraph_format.space_after  = Pt(2)
        r = p.add_run(text); r.bold = True
        r.font.name = 'Times New Roman'; r.font.size = Pt(11)

    def subsection(self, text):
        """Sub-section heading (bold-italic)."""
        p = self.doc.add_paragraph()
        p.alignment = WD_ALIGN_PARAGRAPH.LEFT
        p.paragraph_format.space_before = Pt(6)
        p.paragraph_format.space_after  = Pt(2)
        r = p.add_run(text); r.bold = True; r.italic = True
        r.font.name = 'Times New Roman'; r.font.size = Pt(11)

    def abstract_label(self, label, text):
        """e.g., abstract_label('Background', 'GBS is ...')"""
        p = self.doc.add_paragraph()
        p.alignment = WD_ALIGN_PARAGRAPH.JUSTIFY
        p.paragraph_format.first_line_indent = Inches(0.5)
        p.paragraph_format.space_before = Pt(2)
        p.paragraph_format.space_after  = Pt(2)
        p.paragraph_format.line_spacing  = Pt(22)
        rl = p.add_run(label + ': '); rl.bold = True
        rl.font.name = 'Times New Roman'; rl.font.size = Pt(11)
        self._inline(p, text)

    def body(self, text):
        """Standard body paragraph (justified, first-line indent, double-spaced)."""
        p = self.doc.add_paragraph()
        p.alignment = WD_ALIGN_PARAGRAPH.JUSTIFY
        p.paragraph_format.first_line_indent = Inches(0.5)
        p.paragraph_format.space_before = Pt(0)
        p.paragraph_format.space_after  = Pt(0)
        p.paragraph_format.line_spacing  = Pt(22)
        self._inline(p, text)

    def formula(self, text):
        """Centred italic formula line."""
        p = self.doc.add_paragraph()
        p.alignment = WD_ALIGN_PARAGRAPH.CENTER
        p.paragraph_format.space_before = Pt(4)
        p.paragraph_format.space_after  = Pt(4)
        r = p.add_run(text); r.italic = True
        r.font.name = 'Times New Roman'; r.font.size = Pt(11)

    def reference_list(self, refs):
        """refs: list of formatted reference strings."""
        for ref in refs:
            p = self.doc.add_paragraph()
            p.alignment = WD_ALIGN_PARAGRAPH.JUSTIFY
            p.paragraph_format.first_line_indent = Inches(-0.35)
            p.paragraph_format.left_indent       = Inches(0.35)
            p.paragraph_format.space_before = Pt(2)
            p.paragraph_format.space_after  = Pt(2)
            p.paragraph_format.line_spacing  = Pt(20)
            self._inline(p, ref, size=10)

    def save(self, path):
        self.doc.save(path)
        print(f"Saved → {path}")


# ── Convenience: build from plain-text markdown-ish source ───
def build_from_markdown(md_path, out_path):
    """
    Lightweight parser: recognises
      # Title
      Running title: ...
      ## Section
      ### Subsection
      **Label:** text   (abstract labels)
      ΔYLDs = ...       (formula)
      1. ref text       (references, after ## References)
      Everything else → body paragraph
    """
    mb = ManuscriptBuilder()
    in_refs = False
    with open(md_path) as f:
        for raw in f:
            line = raw.strip()
            if not line:
                continue
            if line.startswith('# ') and not line.startswith('## '):
                mb.title(line[2:])
            elif line.lower().startswith('running title:'):
                mb.running_title(line)
            elif line.startswith('## '):
                heading = line[3:]
                if 'reference' in heading.lower():
                    in_refs = True
                mb.section(heading)
            elif line.startswith('### '):
                mb.subsection(line[4:])
            elif in_refs and re.match(r'^\d+\.', line):
                mb.reference_list([line])
            elif line.startswith('ΔYLDs'):
                mb.formula(line)
            elif re.match(r'^\*\*\w[^*]+:\*\*', line):
                m = re.match(r'^\*\*([^*]+):\*\*\s*(.*)', line)
                if m:
                    mb.abstract_label(m.group(1), m.group(2))
                else:
                    mb.body(line)
            else:
                mb.body(line)
    mb.save(out_path)


if __name__ == '__main__':
    import sys
    if len(sys.argv) == 3:
        build_from_markdown(sys.argv[1], sys.argv[2])
    else:
        print("Usage: docx_builder.py <input.md> <output.docx>")
canvas-designanthropics/skillsCreate beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
docxanthropics/skillsUse this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', '.dotx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx or .dotx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
pdfanthropics/skillsUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
pptxanthropics/skillsUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions "deck," "slides," "presentation," or references a .pptx or .potx filename, regardless of what they plan to do with the content afterward. If a .pptx or .potx file needs to be opened, created, or touched, use this skill.Stars: 198kUpdated Claude CodeCodexVerifiedInstall