Claude Office Skills

repository·main·Indexed 21 days ago

https://github.com/tfriedel/claude-office-skills

A collection of professional Office document creation and editing workflows for Claude Code (CLI). It enables automated manipulation of PPTX, DOCX, XLSX, and PDF files, featuring HTML-to-PPTX conversion, Word redlining, Excel financial modeling, and PDF form filling. Includes utility scripts for PowerPoint thumbnail generation, slide rearrangement, and text replacement, as well as detailed implementation guides for the docx JavaScript library.

Tokens
35.1K
Snippets
82
Records
106
Agent score
24%

What's inside office-skills

  1. Supported Document Formats and Capabilities

    main

    The repository provides specialized capabilities for the following formats:

    • PowerPoint (PPTX): HTML-to-PPTX conversion, template-based creation (rearranging slides, JSON text replacement), visual validation via thumbnails, and direct OOXML editing.
    • Word (DOCX): Tracked changes (redlining), OOXML manipulation (comments, structure), and text extraction with changes preserved.
    • Excel (XLSX): Formula-based modeling, professional formatting (color-coding, custom number formats), and data validation.
    • PDF: Form filling, document merging, format conversion (PPTX to PDF, PDF to images), and data extraction from forms.
  2. Configure Styles and Professional Formatting

    main

    For professional documents, use the styles property in the Document constructor rather than relying solely on inline formatting.

    Key Principles:

    • Override built-in styles: To override Word's default heading styles, use their exact IDs: "Heading1", "Heading2", etc. This ensures compatibility with features like the Table of Contents.
    • Heading Levels: Use HeadingLevel.HEADING_1 to apply the "Heading1" style.
    • TOC Support: When defining heading styles, you must include outlineLevel (e.g., outlineLevel: 0 for H1, outlineLevel: 1 for H2) so the Table of Contents can identify them.
    • Default Font: Set a global default font using styles.default.document.run.font (e.g., "Arial").
    • Custom Styles: Define your own styles in paragraphStyles or characterStyles using unique IDs.

    Example Configuration:

    const doc = new Document({
      styles: {
        default: { document: { run: { font: "Arial", size: 24 } } },
        paragraphStyles: [
          { id: "Title", name: "Title", basedOn: "Normal",
            run: { size: 56, bold: true, color: "000000", font: "Arial" },
            paragraph: { spacing: { before: 240, after: 120 }, alignment: AlignmentType.CENTER } },
          { id: "Heading1", name: "Heading 1", basedOn: "Normal", next: "Normal", quickFormat: true,
            run: { size: 32, bold: true, color: "000000", font: "Arial" },
            paragraph: { spacing: { before: 240, after: 240 }, outlineLevel: 0 } },
          { id: "Heading2", name: "Heading 2", basedOn: "Normal", next: "Normal", quickFormat: true,
            run: { size: 28, bold: true, color: "000000", font: "Arial" },
            paragraph: { spacing: { before: 180, after: 180 }, outlineLevel: 1 } }
        ],
        characterStyles: [{ id: "myCharStyle", name: "My Char Style",
          run: { color: "FF0000", bold: true, underline: { type: UnderlineType.SINGLE } } }]
      },
      sections: [{
        properties: { page: { margin: { top: 1440, right: 1440, bottom: 1440, left: 1440 } } },
        children: [
          new Paragraph({ heading: HeadingLevel.TITLE, children: [new TextRun("Document Title")] }),
          new Paragraph({ heading: HeadingLevel.HEADING_1, children: [new TextRun("Heading 1")] }),
          new Paragraph({ style: "myCharStyle", children: [new TextRun("Custom style")] })
        ]
      }]
    });
  3. Implement Headings, Lists, and Tables in OOXML

    main

    Use the following XML patterns to structure document content:

    Headings and Styles

    Apply styles via <w:pStyle> within the paragraph properties <w:pPr>.

    Lists

    • Numbered Lists: Use <w:numPr> with <w:ilvl> (indentation level) and <w:numId>. To restart a list at 1, use a different numId.
    • Bullet Lists: Use <w:numPr> with <w:ilvl> and <w:ind> for indentation.

    Tables

    Tables require a <w:tbl> container, a <w:tblGrid> defining column widths, and <w:tr> (rows) containing <w:tc> (cells). Each cell should contain its own paragraph <w:p> for text content.

    <!-- Numbered list example -->
    <w:p>
      <w:pPr>
        <w:pStyle w:val="ListParagraph"/>
        <w:numPr><w:ilvl w:val="0"/><w:numId w:val="1"/></w:numPr>
        <w:spacing w:before="240"/>
      </w:pPr>
      <w:r><w:t>First item</w:t></w:r>
    </w:p>
    
    <!-- Table example -->
    <w:tbl>
      <w:tblPr>
        <w:tblStyle w:val="TableGrid"/>
        <w:tblW w:w="0" w:type="auto"/>
      </w:tblPr>
      <w:tblGrid>
        <w:gridCol w:w="4675"/><w:gridCol w:w="4675"/>
      </w:tblGrid>
      <w:tr>
        <w:tc>
          <w:tcPr><w:tcW w:w="4675" w:type="dxa"/></w:tcPr>
          <w:p><w:r><w:t>Cell 1</w:t></w:r></w:p>
        </w:tc>
        <w:tc>
          <w:tcPr><w:tcW w:w="4675" w:type="dxa"/></w:tcPr>
          <w:p><w:r><w:t>Cell 2</w:t></w:r></w:p>
        </w:tc>
      </w:tr>
    </w:tbl>
  4. How the Skills System works in Claude Code

    main

    The project uses a structured workflow pattern where each document format (PPTX, DOCX, XLSX, PDF) has a dedicated directory in public/ containing a SKILL.md file.

    When a user requests a task, Claude Code follows this lifecycle:

    1. Skill Detection: Checks if a skill exists for the requested task.
    2. Workflow Loading: Reads the complete step-by-step instructions from the format's SKILL.md.
    3. Execution: Executes each step (e.g., running Python scripts, manipulating XML).
    4. Validation: Runs validation scripts (such as OOXML format checks) to ensure output integrity.
    5. Organization: Saves all generated files into a specific subdirectory under outputs/<document-name>/.
  5. Add Bar, Line, and Pie charts

    main

    When adding charts via slide.addChart, follow these data and configuration rules:

    General Chart Rules

    • Axis Labels: For most charts, you must provide showCatAxisTitle: true and catAxisTitle (category) along with showValAxisTitle: true and valAxisTitle (value).
    • Colors: Use hex colors without the # prefix. Use chartColors array to define the palette.
    • Time Series Granularity:
      • < 30 days: Use daily grouping.
      • 30-365 days: Use monthly grouping.
      • > 365 days: Use yearly grouping.

    Chart Types

    Bar/Line Charts

    Use a single series with a labels array for simple charts. For multiple series, provide an array of objects, each with its own name, labels, and values.

    Pie Charts

    CRITICAL: Pie charts require a single data series. All categories must be in one labels array and all values in one values array.

    Scatter Charts

    IMPORTANT: The data format is unique. The first series must contain the X-axis values. Subsequent series contain only the Y-values.

    // CORRECT: Single series Bar Chart
    slide.addChart(pptx.charts.BAR, [{
        name: "Sales 2024",
        labels: ["Q1", "Q2", "Q3", "Q4"],
        values: [4500, 5500, 6200, 7100]
    }], {
        ...placeholders[0],
        barDir: 'col',
        showTitle: true,
        title: 'Quarterly Sales',
        showLegend: false,
        showCatAxisTitle: true,
        catAxisTitle: 'Quarter',
        showValAxisTitle: true,
        valAxisTitle: 'Sales ($000s)',
        chartColors: ["4472C4"]
    });
    
    // Scatter Chart Data Format
    const data1 = [{ x: 10, y: 20 }, { x: 15, y: 25 }];
    const allXValues = [10, 15];
    slide.addChart(pptx.charts.SCATTER, [
        { name: 'X-Axis', values: allXValues },
        { name: 'Series 1', values: [20, 25] }
    ], { x: 1, y: 1, w: 8, h: 4 });
    
    // Pie Chart (Single Series Required)
    slide.addChart(pptx.charts.PIE, [{
        name: "Market Share",
        labels: ["Product A", "Product B", "Other"],
        values: [35, 45, 20]
    }], {
        x: 2, y: 1, w: 6, h: 4,
        showPercent: true
    });
  6. Manage file locations and access

    main

    The system uses a specific directory structure for handling user data and workspace files. Understanding these locations is critical for correct file operations.

    DirectoryPurposeUsage
    /mnt/user-data/uploadsUser Uploads: Files provided by the user in the conversation context.Use view /mnt/user-data/uploads to list available files.
    /home/claudeClaude's Workspace: The primary working directory for all tasks.Create all new files here first.
    /mnt/user-data/outputsFinal Deliverables: The location for files intended to be shared with the user.Copy completed files here using computer:// links.

    Note on Simple Tasks: If a task is simple (a single file under 100 lines), you may write directly to /mnt/user-data/outputs/.

  7. Formula Construction and Documentation Rules

    main

    To ensure robust and auditable Excel models, follow these rules:

    Assumption Placement

    • Place all assumptions (growth rates, margins, etc.) in separate assumption cells.
    • Use cell references in formulas instead of hardcoded values (e.g., use =B5*(1+$B$6) instead of =B5*1.05).

    Error Prevention

    • Verify all cell references and check for off-by-one errors in ranges.
    • Ensure formula consistency across all projection periods.
    • Test with edge cases like zero or negative values.
    • Avoid unintended circular references.

    Documentation of Hardcodes

    If a hardcoded value is necessary, document its source in a cell beside it (or at the end of a table) using the format: Source: [System/Document], [Date], [Specific Reference], [URL if applicable].

    Examples:

    • Source: Company 10-K, FY2024, Page 45, Revenue Note, [SEC EDGAR URL]
    • Source: Bloomberg Terminal, 8/15/2025, AAPL US Equity
  8. Understand the Mandatory Skills Check workflow

    main

    Before performing any task involving file creation, code writing, or computer tool usage, you must check if a specialized skill exists in <available_skills>.

    Workflow:

    1. Check for Skill: Determine if the task (e.g., creating a .pptx, editing a .docx, or analyzing an .xlsx) matches an available skill.
    2. Use Skill if Available: If a skill exists, you must immediately use it by reading its specific instruction file (e.g., /mnt/skills/public/docx/SKILL.md) and following it exactly. Do not write custom code from scratch if a skill is available.
    3. Custom Code: Only proceed with custom code if no specialized skill exists for the task.
  9. Basic Slide and Shape Structure in OOXML

    main

    PowerPoint slides are composed of a slide structure containing a shape tree (<p:spTree>). Shapes can be text boxes or geometric objects.

    Basic Slide XML Structure

    <!-- ppt/slides/slide1.xml -->
    <p:sld>
      <p:cSld>
        <p:spTree>
          <p:nvGrpSpPr>...</p:nvGrpSpPr>
          <p:grpSpPr>...</p:grpSpPr>
          <!-- Shapes go here -->
        </p:spTree>
      </p:cSld>
    </p:sld>

    Text Box / Shape with Text

    To create a shape containing text, use the <p:sp> element with a <p:txBody>:

    <p:sp>
      <p:nvSpPr>
        <p:cNvPr id="2" name="Title"/>
        <p:cNvSpPr>
          <a:spLocks noGrp="1"/>
        </p:cNvSpPr>
        <p:nvPr>
          <p:ph type="ctrTitle"/>
        </p:nvPr>
      </p:nvSpPr>
      <p:spPr>
        <a:xfrm>
          <a:off x="838200" y="365125"/>
          <a:ext cx="7772400" cy="1470025"/>
        </a:xfrm>
      </p:spPr>
      <p:txBody>
        <a:bodyPr/>
        <a:lstStyle/>
        <a:p>
          <a:r>
            <a:t>Slide Title</a:t>
          </a:r>
        </a:p>
      </p:txBody>
    </p:sp>
    <p:sp>
      <p:nvSpPr>
        <p:cNvPr id="2" name="Title"/>
        <p:cNvSpPr>
          <a:spLocks noGrp="1"/>
        </p:cNvSpPr>
        <p:nvPr>
          <p:ph type="ctrTitle"/>
        </p:nvPr>
      </p:nvSpPr>
      <p:spPr>
        <a:xfrm>
          <a:off x="838200" y="365125"/>
          <a:ext cx="7772400" cy="1470025"/>
        </a:xfrm>
      </p:spPr>
      <p:txBody>
        <a:bodyPr/>
        <a:lstStyle/>
        <a:p>
          <a:r>
            <a:t>Slide Title</a:t>
          </a:r>
        </a:p>
      </p:txBody>
    </p:sp>
  10. Requirements for Excel Output Quality

    main

    When generating or modifying Excel files, adhere to these strict quality standards:

    Formula Integrity

    • Zero Formula Errors: Every model MUST be delivered with zero errors (e.g., #REF!, #DIV/0!, #VALUE!, #N/A, #NAME?).
    • Dynamic Formulas: Always use Excel formulas instead of calculating values in Python and hardcoding them. This ensures the spreadsheet remains dynamic.

    Template Preservation

    • When updating existing files, study and exactly match the existing format, style, and conventions. Existing template conventions always override general guidelines.

    Financial Model Standards

    Color Coding (unless specified otherwise)

    • Blue text (RGB: 0,0,255): Hardcoded inputs and user-changeable scenario numbers.
    • Black text (RGB: 0,0,0): All formulas and calculations.
    • Green text (RGB: 0,128,0): Links to other worksheets within the same workbook.
    • Red text (RGB: 255,0,0): External links to other files.
    • Yellow background (RGB: 255,255,0): Key assumptions or cells requiring attention.

    Number Formatting

    • Years: Format as text strings (e.g., "2024").
    • Currency: Use $#,##0 format; specify units in headers (e.g., "Revenue ($mm)").
    • Zeros: Use number formatting to display zeros as "-" (e.g., $#,##0;($#,##0);-).
    • Percentages: Default to 0.0% (one decimal).
    • Multiples: Format as 0.0x (e.g., EV/EBITDA).
    • Negative numbers: Use parentheses (123) instead of a minus sign -123.
  11. Create a PowerPoint presentation using a template

    main

    To create a presentation that follows an existing template's design, follow this multi-step workflow:

    1. Extract template content and visuals:
      • Extract text: python -m markitdown template.pptx > template-content.md (Read the entire file without range limits).
      • Create thumbnails: python scripts/thumbnail.py template.pptx.
    2. Analyze and inventory the template:
      • Review thumbnails to understand layouts and design patterns.
      • Create a template-inventory.md file listing every slide by its 0-based index, its layout code, and its purpose.
    3. Create a presentation outline:
      • Map your content to specific template slide indices in an outline.md file.
      • Critical: Match layout structure to content (e.g., use two-column layouts only for exactly 2 items; use quote layouts only for actual quotes).
    4. Rearrange slides:
      • Use rearrange.py to create a new working file by duplicating, reordering, or deleting slides from the template.
    5. Extract text inventory:
      • Run python scripts/inventory.py working.pptx text-inventory.json to get a detailed JSON of all shapes and their properties.
    6. Generate replacement text:
      • Create a replacement-text.json file.
      • Important: Shapes not included in this JSON will be cleared from the presentation.
      • Use the paragraphs key to provide new content and formatting properties.
    7. Apply replacements:
      • Run python scripts/replace.py working.pptx replacement-text.json output.pptx to generate the final presentation.
    # 1. Extract text
    python -m markitdown template.pptx > template-content.md
    
    # 1. Create thumbnails
    python scripts/thumbnail.py template.pptx
    
    # 4. Rearrange slides (example: using slides 0, 34, 34, 50, 52 from template)
    python scripts/rearrange.py template.pptx working.pptx 0,34,34,50,52
    
    # 5. Extract inventory
    python scripts/inventory.py working.pptx text-inventory.json
    
    # 7. Apply replacements
    python scripts/replace.py working.pptx replacement-text.json output.pptx