docxjavascriptverified

docx landscape skill

docx-js helpers for a portrait section followed by a landscape section with a page header and an item/count table.

rec_736f315f7e66499687c6e726824d2949 · banked 2026-09-04 · by neruva
SKILL.md
Certificate

A program checked this on cases it had never seen. You can run it.

Download the checker
Model alone
25%
With this skill
100%
Near-misses it rejects
6/6
Signed
ed25519
What was checked
  • Output built to the specification is accepted.
  • Each of these deliberate breaks is rejected: portrait_second_section, percentage_table_width, header_text_wrong, missing_cell_width, wrong_body_paragraph, only_one_section.
  • An empty file is rejected.
What was not
  • Anything a person would call taste: layout, tone, whether it looks good. No program can check that, and this one does not claim to.
  • Behaviour outside the specification's clauses.
  • Inputs the checker was never given. See the evidence line for the corpus.
Scorecard

A Word document with a portrait section, then a landscape section carrying a page header and a table.

The model on its own
25%16 unseen cases
The same model with this skill
100%deepseek-chat
A frontier model on its own
88%same cases
Cost per task with the skill
0.153 cents27.6x cheaper than the frontier model
Smallest model measured
not measured below DeepSeek-chat yet
Cost to build it once
$0.13
Checked by
hand-written, opens the document with docx-js and measures the page
Where it does not apply
  • Sections beyond the two the rung builds are untested.
  • Word-specific styling outside the header and table is left to the model.

Every figure comes from one run, kept in the repository as probe6b_result.json.

Evidence

  • held-out 16 landscape documents: deepseek-chat cold 0.25 -> 1.00 with rung (CI +0.56..+0.94), 0.15c/doc vs Sonnet cold 0.875 at 4.23c; forged by Sonnet for $0.13

Use it

# in Claude Code (MCP tools from neruva-mcp)
rung_search(q="docx_landscape_rungs")
rung_install(id="rec_736f315f7e66499687c6e726824d2949", dir="~/.claude/skills")
# the skill folder is now loaded like any other skill

Usage guide

What the model reads to call the skill. This is the whole interface.

Show the guide
HELPER REFERENCE
================

1) createHeading(text, level)
   Params: text (string) - exact heading text; level (docx.HeadingLevel.*, optional, defaults to HEADING_1)
   Returns: docx.Paragraph configured as a heading (so it is TOC/outline-visible)
   Example: createHeading("Vendor Onboarding Notes", docx.HeadingLevel.HEADING_1)

2) createParagraph(text)
   Params: text (string) - exact paragraph text
   Returns: docx.Paragraph with a single plain TextRun
   Example: createParagraph("Please submit expense forms by the fifth business day of each month.")

3) createHeader(text)
   Params: text (string) - exact header text
   Returns: docx.Header instance containing one paragraph with that text; pass into createDocumentSection's headerText option (that option calls this internally) or use directly as section.headers.default
   Example: const hdr = createHeader("Vendor Onboarding Notes - Appendix");

4) createTableCell(text, widthDxa, opts)
   Params: text (string|number), widthDxa (number, DXA width for this cell), opts (optional {bold: boolean, shade: hex-string-without-#})
   Returns: docx.TableCell with width set in DXA and a single paragraph/run
   Example: createTableCell("Item", 6000, { bold: true, shade: "D9D9D9" })

5) createItemCountTable(headerRow, rows, columnWidths)
   Params: headerRow (array of 2 strings, e.g. ["Item","Count"]); rows (array of arrays, each [itemText, countText]); columnWidths (array of 2 numbers in DXA, must sum to table width)
   Returns: docx.Table with columnWidths set on the table and matching DXA widths on every cell (header row shaded/bold, tableHeader:true so it repeats)
   Example: createItemCountTable(["Item","Count"], [["Hi-vis vests","13"],["Fall arrest harness","13"]], [6000,3000])

6) createDocumentSection(children, options)
   Params: children (array of Paragraph/Table elements for this section's body); options (optional object):
     - orientation: docx.PageOrientation.PORTRAIT (default) or docx.PageOrientation.LANDSCAPE
     - pageWidth / pageHeight: DXA numbers, default US Letter portrait dims 12240 x 15840 (pass these same portrait numbers even for landscape; docx-js swaps them when orientation is LANDSCAPE)
     - headerText: string, if provided a page header with exactly that text is attached to this section
   Returns: a plain object suitable for inclusion in the `sections` array passed to `new docx.Document({ sections: [...] })`
   Example: createDocumentSection([createHeading("Title"), createParagraph("Body")], { orientation: docx.PageOrientation.LANDSCAPE, headerText: "Appendix" })

TYPICAL USAGE PATTERN (portrait section + heading/paragraph, then landscape section + header/table):

  const section1 = createDocumentSection(
    [ createHeading("Title Text"), createParagraph("Body text.") ],
    { orientation: docx.PageOrientation.PORTRAIT }
  );

  const table = createItemCountTable(
    ["Item", "Count"],
    [["A","1"], ["B","2"]],
    [6000, 3000]
  );

  const section2 = createDocumentSection(
    [ table ],
    { orientation: docx.PageOrientation.LANDSCAPE, headerText: "Appendix Header" }
  );

  const doc = new docx.Document({ sections: [section1, section2] });

Code

91 lines of javascript, hashed and signed below.

Show the code
function createHeading(text, level) {
  const HeadingLevel = docx.HeadingLevel;
  return new docx.Paragraph({
    heading: level || HeadingLevel.HEADING_1,
    children: [new docx.TextRun({ text: text })]
  });
}

function createParagraph(text) {
  return new docx.Paragraph({
    children: [new docx.TextRun({ text: text })]
  });
}

function createHeader(text) {
  return new docx.Header({
    children: [
      new docx.Paragraph({
        children: [new docx.TextRun({ text: text })]
      })
    ]
  });
}

function createTableCell(text, widthDxa, opts) {
  opts = opts || {};
  const runProps = {};
  if (opts.bold) runProps.bold = true;
  const paragraph = new docx.Paragraph({
    children: [new docx.TextRun(Object.assign({ text: String(text) }, runProps))]
  });
  const cellConfig = {
    width: { size: widthDxa, type: docx.WidthType.DXA },
    children: [paragraph]
  };
  if (opts.shade) {
    cellConfig.shading = {
      type: docx.ShadingType.CLEAR,
      fill: opts.shade,
      color: 'auto'
    };
  }
  return new docx.TableCell(cellConfig);
}

function createItemCountTable(headerRow, rows, columnWidths) {
  const totalWidth = columnWidths.reduce((a, b) => a + b, 0);

  const headerCells = headerRow.map((h, i) =>
    createTableCell(h, columnWidths[i], { bold: true, shade: 'D9D9D9' })
  );
  const headerTableRow = new docx.TableRow({ children: headerCells, tableHeader: true });

  const bodyRows = rows.map((row) => {
    const cells = row.map((val, i) => createTableCell(val, columnWidths[i]));
    return new docx.TableRow({ children: cells });
  });

  return new docx.Table({
    width: { size: totalWidth, type: docx.WidthType.DXA },
    columnWidths: columnWidths,
    rows: [headerTableRow, ...bodyRows]
  });
}

function createDocumentSection(children, options) {
  options = options || {};
  const orientation = options.orientation || docx.PageOrientation.PORTRAIT;
  const pageWidth = options.pageWidth || 12240;
  const pageHeight = options.pageHeight || 15840;

  const section = {
    properties: {
      page: {
        size: {
          width: pageWidth,
          height: pageHeight,
          orientation: orientation
        }
      }
    },
    children: children
  };

  if (options.headerText) {
    section.headers = { default: createHeader(options.headerText) };
  }

  return section;
}

Certificate

Code sha256 aa146f4bedba054ef162c37a3be7286341d911c78b33f17835a77c84f830c063
Signature ed25519, present
Last re-checked
passing

Re-checked today. The signature was recomputed from the code served by the API, and the certificate matched.

A certificate proves the code has not changed. Re-running the check proves it still works today, on today's libraries.