<!-- carta:plugin-version -->
<carta-plugin>carta-cap-table:6.122.11</carta-plugin>
Excel Export
Context expected from the calling skill (must be in session before this skill is invoked):
user_report_pk— needed to check for the cached report file and to fetch a fresh download URL if the file is absent_carta_prefix— the confirmedmcp__<segment>__of the Carta connectorcorporation_id— needed forread_tool({"name": "reporting__get__download_url", ...})- Column config — either parsed from the artifact prompt bar payload (ARTIFACT mode,
Artifacttool available) or confirmed during the Customization Checkpoint incarta-reporting-markdown(MARKDOWN mode,Artifacttool not available) - Corporation legal name,
as_of_date, user full name — used as--title,--as-of-date,--generated-byargs toexcel_exporter.py
Send _instrumentation_v2: {"surface": "<surface>"} with every Carta tool call, as a parameter
of the tool next to name and arguments, never in arguments. <surface> is the closest of
chat, cowork, code-terminal, code-desktop, code-remote, excel, sdk-cli,
sdk-typescript and sdk-python, else other. Run no shell command for this or any other
_instrumentation_v2 field: send session_id only when your system prompt already shows it.
Column source (ARTIFACT mode — artifact prompt bar)
When the user pastes an artifact prompt bar payload, it arrives as a complete instruction starting with Generate Carta Excel —:
Generate Carta Excel —
Corporation: Meetly, Inc. (ID: 7)
As of: 2024-01-15
Environment: Sandbox
Reports:
Equity Grants: user_report_pk 4812; corporation_id 7; source sheet: Equity Grants
Vesting Schedule: user_report_pk 4812; corporation_id 7; source sheet: Vesting Schedule
Columns:
Equity Grants: columns: Grant ID, Award Type, Exercise Price; sorted by: Grant Date desc
Vesting Schedule: columns: Grant ID, Vest Date, Shares Vested; totals: Shares Vested sum
Use the Corporation: line to confirm which company the export is for, and As of: as as_of_date. The optional Environment: line names the Carta environment that built the report; carta-reporting gate 0b has already used it to set _carta_prefix. Each Reports: line gives the report behind that sheet: use its user_report_pk and corporation_id for the cached file and download URL, and its source sheet as the sheet name in report_processor.py (a multi-corporation page names sheets Corp — Sheet, which matches no single report's own sheet). Sheets from different corporations come from different reports, so run steps 1-4 below once per user_report_pk, each with its own --out and --output. Each indented line under Columns: is one sheet tab. This is always one Excel file per report (one per corporation), with one tab per sheet. Parse the sheet lines of one report and pass its sheets to report_processor.py in a single run using the per-sheet sheets dict format. No further questions needed.
The column list from the artifact is authoritative; do not merge with or override it from the earlier conversation.
Parsing segment fields into report_processor.py config:
| Prompt bar field | report_processor.py per-sheet key |
|---|---|
| columns: A, B, C | "columns": ["A", "B", "C"] |
| sorted by: Col asc | "sort": [{"column": "Col", "direction": "asc"}] |
| totals: Col sum, Col2 avg | "aggregations": {"type": "summary", "columns": {"Col": "sum", "Col2": "avg"}} |
totals: must become aggregations — this is the only way Excel formulas (=SUM(...), =AVERAGE(...)) are generated. If aggregations is omitted, any total rows in the output are hardcoded API values, not live formulas.
If the user asks for Excel without pasting a payload, ask: "Click the Excel export bar at the bottom of the artifact to select it, copy and paste it here — I'll generate the Excel with exactly those columns."
No scope context on this path. Entering fresh from the prompt bar, this skill cannot know
whether the account is share-class-scoped, so it cannot label a percentage column for the scope or
name the in-scope classes — the same limitation as label_overrides. The numbers are correct and
already scoped; only the labelling is generic. Do not describe any total as company-wide.
Column source (MARKDOWN mode)
Use the column list confirmed during the Customization Checkpoint (resolved in carta-reporting-markdown).
Preflight access check (ARTIFACT mode)
A prompt bar payload can be pasted into a session other than the one that built it: another user, firm or environment. That session may have no access to the payload's company, and a user_report_pk belongs to the user who generated it. Before reading any report data, confirm this session can reach each payload corporation_id.
Confirm access once per distinct corporation_id on the Reports: lines, using only the ID: no company name is needed, and a name search cannot confirm a comma-joined Corporation: line or a payload with no name. For each one, make the same first read carta-reporting step 1a makes, on _carta_prefix:
read_tool({"name": "cap_table__list__cbus", "arguments": { corporation_id, detail: "minimal", page_size: 1 }})
- Success: that company is accessible, whatever
data.resultsholds. Once every ID succeeds, go on with the export. If the report is then expired orreport_statusreturnsnot_found, follow the Error Handling table: that is a stale report, not an access problem. - Company error (as
${CLAUDE_PLUGIN_ROOT}/references/find-the-company.mdCompany errors defines it): that company is not accessible. Read every ID first, then stop. Do not fall back to DWH or other reads to find the data, and do not write a file. Tell the user this export request was created in a session with different Carta access, so this session cannot see each unreachable company. Name each one as<label> (ID <corporation_id>), taking the label from theCorporation — Sheetsheet name or theCorporation:line. Ask them to sign in to Carta with the account that generated the report, or to request cap table access to those companies, then regenerate the report and copy a fresh Excel prompt. - Any other error: follow the Error Handling table. Do not give the access explanation.
Running the export
Hand the user the generated .xlsx file itself. Never give them a Carta web link to the report: it makes them sign in to Carta. If the file cannot be delivered, the presigned download_url works without signing in but expires, so say so.
Make every Carta call (read_tool, call_tool) through _carta_prefix, in both modes.
Check if carta-reporting/carta_report_<user_report_pk>.json is available (use the current user_report_pk from this session: a recreated report's pk replaces the original):
- File ready → pass it as
"local_file"toreport_processor.py. - Not ready → call
read_tool({"name": "reporting__get__report_status", "arguments": { user_report_pk }})first (nocorporation_id). Only when it iscomplete, callread_tool({"name": "reporting__get__download_url", "arguments": { user_report_pk, corporation_id }})to get a fresh presigned URL and pass it as"download_url"instead. While it ispending, poll every 5 s up to 20 attempts. Onerrororfailed, tell the user the report failed. Onnot_foundor a timeout, say the report is not available and offer to regenerate it. Ifdownload_urlitself returnsnot_found, checkreport_statusonce more: ifcomplete, calldownload_urlonce more; ifpending, resume polling within the attempts left. Never calldownload_urlmore than twice; if the second call fails, say the report is not available and offer to regenerate it. Never give the user theurlthatreport_statusreturns: it is a Carta web page that needs a sign-in.
Always run report_processor.py then excel_exporter.py, regardless of data size or complexity. Never write Excel files directly with openpyxl or any other library — the scripts handle Carta branding (logo, header, fonts, number formats) that will be missing from any ad-hoc implementation. This applies even when the dataset is small (e.g. 3 rows) or when sheets need to be combined.
For combining sheets into one tab, use merge_sheets in the report_processor.py call.
Pass all of one report's sheets in one run using the sheets dict; with several reports, repeat steps 1-4 for each user_report_pk (file names below use <user_report_pk>). Two commands, each run on its own, on one line: a heredoc, a pipe or a chained command needs approval every time. Never search for the scripts.
Writecarta-reporting/config.json(in the working directory) with the config:
{
"local_file": "<path or use download_url if file not ready>",
"sheets": {
"Equity Grants": {"columns": ["Grant ID", "Award Type", "Exercise Price"],
"aggregations": {"type": "summary", "columns": {"Exercise Price": "sum"}}},
"Vesting Schedule": {"columns": ["Grant ID", "Vest Date", "Shares Vested"],
"sort": [{"column": "Vest Date", "direction": "asc"}]}
}
}
- Process it into
carta-reporting/result-<user_report_pk>.json:
UV_PYTHON_DOWNLOADS=never uv run "${CLAUDE_PLUGIN_ROOT}/skills/carta-reporting/scripts/report_processor.py" --config "carta-reporting/config.json" --out "carta-reporting/result-<user_report_pk>.json"
- Check
carta-reporting/result-<user_report_pk>.jsonbefore exporting: if itswarningsis non-empty, or any sheet'sstatshasschema_warnings, tell the user which sheet was left out and why (wording: thewarnings.*rows of the Error Handling table incarta-reporting), then export what is there. For each sheet inwarnings.unknown_sheets.requested, or a payload sheet that the report does not have, write thewarnings.unknown_sheetsrow's sentence word for word. Never present a workbook with a missing sheet or merged rows as complete.
- Export the workbook:
UV_PYTHON_DOWNLOADS=never uv run "${CLAUDE_PLUGIN_ROOT}/skills/carta-reporting-excel/scripts/excel_exporter.py" --input "carta-reporting/result-<user_report_pk>.json" --title "Securities Ledger Report" --as-of-date "2024-01-15" --generated-by "Jane Doe" --output "./{corporation-slug}-{report-slug}.xlsx"
excel_exporter.py prints the absolute output path on success. Present it as a clickable link: computer://<absolute-path> (e.g. computer:///Users/jane/meetly-equity-grants.xlsx). Tell the user their file is ready to open (with several reports, list one link per file, naming the corporation each is for), then offer next steps:
- Run another report — for a different company or report type
- Customize this export — adjust filters, columns, or formulas
- Change the date range or filters — re-run with different parameters
Gates
Required inputs: user_report_pk, corporation_id and the column list, from the calling skill or the Generate Carta Excel — payload. Without a payload or a report in this session, ask for the payload as "Column source" says.
AI computation: No — the scripts format Carta report data. Totals are Excel formulas from aggregations.
Error Handling
| Situation | What to do |
|---|---|
| report_status or download_url returns not_found | The report expired or belongs to another session. Follow the retry rule in "Running the export", then say the report is not available and offer to regenerate it with carta-reporting. If the preflight access check found the company, give this advice, not the access explanation. |
| A script does not run (for example uv not found, or the Bash call is blocked) | Do not write the file with another library. Say the Excel file cannot be built here. Show the data as a table, or give the presigned download_url and say it expires. |
| excel_exporter.py stops with as_of_date must be in YYYY-MM-DD format | Run it once more with --as-of-date as YYYY-MM-DD. |
| unknown_param or invalid_argument on a cap_table__* command | This skill reads only the report file. Do not pull rows with other commands: build the report with carta-reporting. |
| 403, role_required or access denied | Say the user's role cannot run Carta reports for this company. Do not retry and do not look for the data elsewhere. |
| Company error | Follow Company errors in ${CLAUDE_PLUGIN_ROOT}/references/find-the-company.md. |
Carta Excel Formatting Conventions
| Element | Value |
|---|---|
| Header background | #c6ebf4 |
| Header font | Arial 12pt bold, #2f3943 |
| Logo | <skill_base_dir>/assets/Carta_Logo.png, cell A2, 120×50px |
| Title | Cell B2, Arial 16pt bold |
| Subtitle | Cell B3, Arial 10pt, #666666 — "As of MMM d, yyyy • Generated with Claude AI by {user} at MMM d, yyyy h:mm:ss AM/PM TZ • Date format: MMM D, YYYY" |
| Header row | Row 5 with auto-filter; freeze panes at A6; data starts at row 6 |
Column type → number format: money → the row's currency symbol quoted before #,##0.00####, set per cell by the exporter (no symbol when the data names none) · percentage → 0.00% · integer → #,##0 · date → mmm d, yyyy · decimal → #,##0.0#####
Column widths: string/date → 35, number types → 18.