---
name: table-of-authorities-builder
description: "Builds a table of contents and a table of authorities for a Word (.docx) document the user has already written, copying the user's own headings and citations exactly as written and saving the result as a new file; use it when the user asks for these tables, and do not use it to write, edit, check, or correct headings, citations, or any legal content."
---

## Scope: collecting only
This skill builds a table of contents and a table of authorities from a document the user has already written. It
copies the user's own headings and citations exactly as written. It adds only the table titles, group labels, and
page numbers.
- Do not write, draft, complete, rewrite, summarize, or suggest any legal content. That includes headings, arguments,
  citations, and authorities.
- Do not check, correct, normalize, complete, or comment on any citation, including its format, its accuracy, or
  whether the authority exists or is still good law. Copy each one exactly as written.
- If the script cannot sort a citation, or two entries may be the same authority, list them for the user to decide.
  Never guess. Never drop an entry.
- Do not change the user's text or layout. Save the result as a new file and leave the original unchanged.
- If the user asks for legal advice, drafting, a review of their document, deadlines, page limits, or which rules
  apply, say that this skill only builds tables from the user's own text and that they should talk with a lawyer
  licensed in California. Then stop using this skill for that request.
- The user should check the finished tables against the document, and check the filing court's instructions,
  before filing.
- This skill is general information and a formatting aid. It is not legal advice, and using it does not create an
  attorney-client relationship. It was published by SentryHall, a legal-information site run by a law student who
  is not a lawyer.

## How to run it
1. Ask the user for their finished .docx. The script works on a copy and never changes the original.
2. Run:
   ```
   pip install python-docx==1.1.2
   python3 scripts/build_tables.py --in their-file.docx --out their-file-with-tables.docx --report review.txt
   ```
   The table of contents lists paragraphs in Word heading styles. If the user's headings use another style, add
   `--heading-style "Style Name"` for each style the user names. Do not decide for the user which lines are headings.
3. Give the user the new file and tell them: "The new file contains hidden Word field codes that mark each entry.
   Update the fields in Word to fill in the page numbers." Word offers to update the fields when the file opens; the
   user can also select all and press F9. Google Docs and LibreOffice may not rebuild these fields.
4. Show the user every line of the review report exactly as written. Do not add, sort, or merge those items yourself.

## Files
- `scripts/build_tables.py`: the script (python-docx).
- `references/patterns.md`: the patterns the script uses to collect and sort citations, and what goes on the review list.
