Requirements for Outputs
🎯 Load Full PAI Context
Before starting any task with this skill, load complete PAI context:
read ~/.claude/skills/PAI/SKILL.md
This provides access to:
- Complete contact list (Angela, Bunny, Saša, Greg, team members)
- Stack preferences (TypeScript>Python, bun>npm, uv>pip)
- Security rules and repository safety protocols
- Response format requirements (structured emoji format)
- Voice IDs for agent routing (ElevenLabs)
- Personal preferences and operating instructions
🔀 When to Use This Sub-Skill
This sub-skill activates when the user's request involves Excel spreadsheets (.xlsx, .xlsm, .csv, .tsv).
Explicit Triggers
- User mentions "create spreadsheet", "new Excel file", "Excel workbook"
- User requests "formulas", "financial model", "financial modeling"
- User wants to "recalculate" or "recalculate formulas"
- User says "analyze data in Excel", "read Excel", "Excel data analysis"
- User mentions .xlsx, .xlsm, .csv, or .tsv files
Contextual Triggers
- User provides path to .xlsx/.xlsm file
- User discusses calculations, projections, or financial data
- User mentions financial projections, revenue models, or valuations
- User wants to work with spreadsheet formulas or data
Workflow Routing
Creation Workflow (openpyxl):
- "Create spreadsheet", "new Excel file", "build financial model"
- User wants to create new .xlsx files with formulas and formatting
- Use openpyxl for formula support and Excel-specific features
Editing Workflow (openpyxl):
- "Edit spreadsheet", "modify Excel", "update cells"
- User wants to modify existing .xlsx files while preserving formulas
- Use
load_workbook() to preserve existing formatting and formulas
Data Analysis Workflow (pandas):
- "Analyze data", "read Excel", "data visualization"
- User wants to analyze or visualize data from Excel files
- Use pandas for powerful data manipulation and analysis
Financial Modeling Workflow:
- "Financial model", "revenue projections", "valuation model"
- User wants professional financial models with color coding
- Follow financial model standards (blue inputs, black formulas, green links)
Recalculation Workflow:
- "Recalculate", "update formula values", "calculate formulas"
- After creating/editing files with formulas
- MANDATORY step after using formulas - run
recalc.py script
All Excel files
Zero Formula Errors
- Every Excel model MUST be delivered with ZERO formula errors (#REF!, #DIV/0!, #VALUE!, #N/A, #NAME?)
Preserve Existing Templates (when updating templates)
- Study and EXACTLY match existing format, style, and conventions when modifying files
- Never impose standardized formatting on files with established patterns
- Existing template conventions ALWAYS override these guidelines
Financial models
Color Coding Standards
Unless otherwise stated by the user or existing template
Industry-Standard Color Conventions
- Blue text (RGB: 0,0,255): Hardcoded inputs, and numbers users will change for scenarios
- Black text (RGB: 0,0,0): ALL formulas and calculations
- Green text (RGB: 0,128,0): Links pulling from other worksheets within same workbook
- Red text (RGB: 255,0,0): External links to other files
- Yellow background (RGB: 255,255,0): Key assumptions needing attention or cells that need to be updated
Number Formatting Standards
Required Format Rules
- Years: Format as text strings (e.g., "2024" not "2,024")
- Currency: Use $#,##0 format; ALWAYS specify units in headers ("Revenue ($mm)")
- Zeros: Use number formatting to make all zeros "-", including percentages (e.g., "$#,##0;($#,##0);-")
- Percentages: Default to 0.0% format (one decimal)
- Multiples: Format as 0.0x for valuation multiples (EV/EBITDA, P/E)
- Negative numbers: Use parentheses (123) not minus -123
Formula Construction Rules
Assumptions Placement
- Place ALL assumptions (growth rates, margins, multiples, etc.) in separate assumption cells
- Use cell references instead of hardcoded values in formulas
- Example: Use =B5*(1+$B$6) instead of =B5*1.05
Formula Error Prevention
- Verify all cell references are correct
- Check for off-by-one errors in ranges
- Ensure consistent formulas across all projection periods
- Test with edge cases (zero values, negative numbers)
- Verify no unintended circular references
Documentation Requirements for Hardcodes
- Comment or in cells beside (if end of table). Format: "Source: [System/Document], [Date], [Specific Reference], [URL if applicable]"
- Examples:
- "Source: Company 10-K, FY2024, Page 45, Revenue Note, [SEC EDGAR URL]"
- "Source: Company 10-Q, Q2 2025, Exhibit 99.1, [SEC EDGAR URL]"
- "Source: Bloomberg Terminal, 8/15/2025, AAPL US Equity"
- "Source: FactSet, 8/20/2025, Consensus Estimates Screen"
XLSX creation, editing, and analysis
Overview
A user may ask you to create, edit, or analyze the contents of an .xlsx file. You have different tools and workflows available for different tasks.
Important Requirements
LibreOffice Required for Formula Recalculation: You can assume LibreOffice is installed for recalculating formula values using the recalc.py script. The script automatically configures LibreOffice on first run
Reading and analyzing data
Data analysis with pandas
For data analysis, visualization, and basic operations, use pandas which provides powerful data manipulation capabilities:
import pandas as pd
# Read Excel
df = pd.read_excel('file.xlsx') # Default: first sheet
all_sheets = pd.read_excel('file.xlsx', sheet_name=None) # All sheets as dict
# Analyze
df.head() # Preview data
df.info() # Column info
df.describe() # Statistics
# Write Excel
df.to_excel('output.xlsx', index=False)
Excel File Workflows
CRITICAL: Use Formulas, Not Hardcoded Values
Always use Excel formulas instead of calculating values in Python and hardcoding them. This ensures the spreadsheet remains dynamic and updateable.
❌ WRONG - Hardcoding Calculated Values
# Bad: Calculating in Python and hardcoding result
total = df['Sales'].sum()
sheet['B10'] = total # Hardcodes 5000
# Bad: Computing growth rate in Python
growth = (df.iloc[-1]['Revenue'] - df.iloc[0]['Revenue']) / df.iloc[0]['Revenue']
sheet['C5'] = growth # Hardcodes 0.15
# Bad: Python calculation for average
avg = sum(values) / len(values)
sheet['D20'] = avg # Hardcodes 42.5
✅ CORRECT - Using Excel Formulas
# Good: Let Excel calculate the sum
sheet['B10'] = '=SUM(B2:B9)'
# Good: Growth rate as Excel formula
sheet['C5'] = '=(C4-C2)/C2'
# Good: Average using Excel function
sheet['D20'] = '=AVERAGE(D2:D19)'
This applies to ALL calculations - totals, percentages, ratios, differences, etc. The spreadsheet should be able to recalculate when source data changes.
Common Workflow
- Choose tool: pandas for data, openpyxl for formulas/formatting
- Create/Load: Create new workbook or load existing file
- Modify: Add/edit data, formulas, and formatting
- Save: Write to file
- Recalculate formulas (MANDATORY IF USING FORMULAS): Use the recalc.py script
python recalc.py output.xlsx
- Verify and fix any errors:
- The script returns JSON with error details
- If
status is errors_found, check error_summary for specific error types and locations
- Fix the identified errors and recalculate again
- Common errors to fix:
#REF!: Invalid cell references
#DIV/0!: Division by zero
#VALUE!: Wrong data type in formula
#NAME?: Unrecognized formula name
Creating new Excel files
# Using openpyxl for formulas and formatting
from openpyxl import Workbook
from openpyxl.styles import Font, PatternFill, Alignment
wb = Workbook()
sheet = wb.active
# Add data
sheet['A1'] = 'Hello'
sheet['B1'] = 'World'
sheet.append(['Row', 'of', 'data'])
# Add formula
sheet['B2'] = '=SUM(A1:A10)'
# Formatting
sheet['A1'].font = Font(bold=True, color='FF0000')
sheet['A1'].fill = PatternFill('solid', start_color='FFFF00')
sheet['A1'].alignment = Alignment(horizontal='center')
# Column width
sheet.column_dimensions['A'].width = 20
wb.save('output.xlsx')
Editing existing Excel files
# Using openpyxl to preserve formulas and formatting
from openpyxl import load_workbook
# Load existing file
wb = load_workbook('existing.xlsx')
sheet = wb.active # or wb['SheetName'] for specific sheet
# Working with multiple sheets
for sheet_name in wb.sheetnames:
sheet = wb[sheet_name]
print(f"Sheet: {sheet_name}")
# Modify cells
sheet['A1'] = 'New Value'
sheet.insert_rows(2) # Insert row at position 2
sheet.delete_cols(3) # Delete column 3
# Add new sheet
new_sheet = wb.create_sheet('NewSheet')
new_sheet['A1'] = 'Data'
wb.save('modified.xlsx')
Recalculating formulas
Excel files created or modified by openpyxl contain formulas as strings but not calculated values. Use the provided recalc.py script to recalculate formulas:
python recalc.py <excel_file> [timeout_seconds]
Example:
python recalc.py output.xlsx 30
The script:
- Automatically sets up LibreOffice macro on first run
- Recalculates all formulas in all sheets
- Scans ALL cells for Excel errors (#REF!, #DIV/0!, etc.)
- Returns JSON with detailed error locations and counts
- Works on both Linux and macOS
Formula Verification Checklist
Quick checks to ensure formulas work correctly:
Essential Verification
Common Pitfalls
Formula Testing Strategy
Interpreting recalc.py Output
The script returns JSON with error details:
{
"status": "success", // or "errors_found"
"total_errors": 0, // Total error count
"total_formulas": 42, // Number of formulas in file
"error_summary": { // Only present if errors found
"#REF!": {
"count": 2,
"locations": ["Sheet1!B5", "Sheet1!C10"]
}
}
}
Best Practices
Library Selection
- pandas: Best for data analysis, bulk operations, and simple data export
- openpyxl: Best for complex formatting, formulas, and Excel-specific features
Working with openpyxl
- Cell indices are 1-based (row=1, column=1 refers to cell A1)
- Use
data_only=True to read calculated values: load_workbook('file.xlsx', data_only=True)
- Warning: If opened with
data_only=True and saved, formulas are replaced with values and permanently lost
- For large files: Use
read_only=True for reading or write_only=True for writing
- Formulas are preserved but not evaluated - use recalc.py to update values
Working with pandas
- Specify data types to avoid inference issues:
pd.read_excel('file.xlsx', dtype={'id': str})
- For large files, read specific columns:
pd.read_excel('file.xlsx', usecols=['A', 'C', 'E'])
- Handle dates properly:
pd.read_excel('file.xlsx', parse_dates=['date_column'])
Code Style Guidelines
IMPORTANT: When generating Python code for Excel operations:
- Write minimal, concise Python code without unnecessary comments
- Avoid verbose variable names and redundant operations
- Avoid unnecessary print statements
For Excel files themselves:
- Add comments to cells with complex formulas or important assumptions
- Document data sources for hardcoded values
- Include notes for key calculations and model sections
Examples
Example 1: Build a financial model
User: "Create a revenue projection model for the next 5 years"
→ Creates workbook with assumptions sheet + projections
→ Uses Excel formulas (=SUM, growth rates) not hardcoded values
→ Applies color coding (blue inputs, black formulas), runs recalc.py
Example 2: Analyze data from Excel file
User: "What are the top 10 customers by revenue in this spreadsheet?"
→ Reads Excel with pandas
→ Groups, sorts, and filters data
→ Returns summary with statistics
Example 3: Update existing spreadsheet
User: "Add a new column with profit margin calculations"
→ Loads workbook preserving existing formulas
→ Adds new column with margin formula referencing existing cells
→ Saves and recalculates to verify no errors
1---2name: xlsx3description: Excel file processing. USE WHEN xlsx, Excel, spreadsheet. SkillSearch('xlsx') for docs.4---56# Requirements for Outputs78## 🎯 Load Full PAI Context910**Before starting any task with this skill, load complete PAI context:**1112`read ~/.claude/skills/PAI/SKILL.md`1314This provides access to:15- Complete contact list (Angela, Bunny, Saša, Greg, team members)16- Stack preferences (TypeScript>Python, bun>npm, uv>pip)17- Security rules and repository safety protocols18- Response format requirements (structured emoji format)19- Voice IDs for agent routing (ElevenLabs)20- Personal preferences and operating instructions2122## 🔀 When to Use This Sub-Skill2324This sub-skill activates when the user's request involves Excel spreadsheets (.xlsx, .xlsm, .csv, .tsv).2526### Explicit Triggers27- User mentions "create spreadsheet", "new Excel file", "Excel workbook"28- User requests "formulas", "financial model", "financial modeling"29- User wants to "recalculate" or "recalculate formulas"30- User says "analyze data in Excel", "read Excel", "Excel data analysis"31- User mentions .xlsx, .xlsm, .csv, or .tsv files3233### Contextual Triggers34- User provides path to .xlsx/.xlsm file35- User discusses calculations, projections, or financial data36- User mentions financial projections, revenue models, or valuations37- User wants to work with spreadsheet formulas or data3839### Workflow Routing4041**Creation Workflow (openpyxl):**42- "Create spreadsheet", "new Excel file", "build financial model"43- User wants to create new .xlsx files with formulas and formatting44- Use openpyxl for formula support and Excel-specific features4546**Editing Workflow (openpyxl):**47- "Edit spreadsheet", "modify Excel", "update cells"48- User wants to modify existing .xlsx files while preserving formulas49- Use `load_workbook()` to preserve existing formatting and formulas5051**Data Analysis Workflow (pandas):**52- "Analyze data", "read Excel", "data visualization"53- User wants to analyze or visualize data from Excel files54- Use pandas for powerful data manipulation and analysis5556**Financial Modeling Workflow:**57- "Financial model", "revenue projections", "valuation model"58- User wants professional financial models with color coding59- Follow financial model standards (blue inputs, black formulas, green links)6061**Recalculation Workflow:**62- "Recalculate", "update formula values", "calculate formulas"63- After creating/editing files with formulas64- MANDATORY step after using formulas - run `recalc.py` script6566## All Excel files6768### Zero Formula Errors69- Every Excel model MUST be delivered with ZERO formula errors (#REF!, #DIV/0!, #VALUE!, #N/A, #NAME?)7071### Preserve Existing Templates (when updating templates)72- Study and EXACTLY match existing format, style, and conventions when modifying files73- Never impose standardized formatting on files with established patterns74- Existing template conventions ALWAYS override these guidelines7576## Financial models7778### Color Coding Standards79Unless otherwise stated by the user or existing template8081#### Industry-Standard Color Conventions82- **Blue text (RGB: 0,0,255)**: Hardcoded inputs, and numbers users will change for scenarios83- **Black text (RGB: 0,0,0)**: ALL formulas and calculations84- **Green text (RGB: 0,128,0)**: Links pulling from other worksheets within same workbook85- **Red text (RGB: 255,0,0)**: External links to other files86- **Yellow background (RGB: 255,255,0)**: Key assumptions needing attention or cells that need to be updated8788### Number Formatting Standards8990#### Required Format Rules91- **Years**: Format as text strings (e.g., "2024" not "2,024")92- **Currency**: Use $#,##0 format; ALWAYS specify units in headers ("Revenue ($mm)")93- **Zeros**: Use number formatting to make all zeros "-", including percentages (e.g., "$#,##0;($#,##0);-")94- **Percentages**: Default to 0.0% format (one decimal)95- **Multiples**: Format as 0.0x for valuation multiples (EV/EBITDA, P/E)96- **Negative numbers**: Use parentheses (123) not minus -1239798### Formula Construction Rules99100#### Assumptions Placement101- Place ALL assumptions (growth rates, margins, multiples, etc.) in separate assumption cells102- Use cell references instead of hardcoded values in formulas103- Example: Use =B5*(1+$B$6) instead of =B5*1.05104105#### Formula Error Prevention106- Verify all cell references are correct107- Check for off-by-one errors in ranges108- Ensure consistent formulas across all projection periods109- Test with edge cases (zero values, negative numbers)110- Verify no unintended circular references111112#### Documentation Requirements for Hardcodes113- Comment or in cells beside (if end of table). Format: "Source: [System/Document], [Date], [Specific Reference], [URL if applicable]"114- Examples:115 - "Source: Company 10-K, FY2024, Page 45, Revenue Note, [SEC EDGAR URL]"116 - "Source: Company 10-Q, Q2 2025, Exhibit 99.1, [SEC EDGAR URL]"117 - "Source: Bloomberg Terminal, 8/15/2025, AAPL US Equity"118 - "Source: FactSet, 8/20/2025, Consensus Estimates Screen"119120# XLSX creation, editing, and analysis121122## Overview123124A user may ask you to create, edit, or analyze the contents of an .xlsx file. You have different tools and workflows available for different tasks.125126## Important Requirements127128**LibreOffice Required for Formula Recalculation**: You can assume LibreOffice is installed for recalculating formula values using the `recalc.py` script. The script automatically configures LibreOffice on first run129130## Reading and analyzing data131132### Data analysis with pandas133For data analysis, visualization, and basic operations, use **pandas** which provides powerful data manipulation capabilities:134135```python136import pandas as pd137138# Read Excel139df = pd.read_excel('file.xlsx') # Default: first sheet140all_sheets = pd.read_excel('file.xlsx', sheet_name=None) # All sheets as dict141142# Analyze143df.head() # Preview data144df.info() # Column info145df.describe() # Statistics146147# Write Excel148df.to_excel('output.xlsx', index=False)149```150151## Excel File Workflows152153## CRITICAL: Use Formulas, Not Hardcoded Values154155**Always use Excel formulas instead of calculating values in Python and hardcoding them.** This ensures the spreadsheet remains dynamic and updateable.156157### ❌ WRONG - Hardcoding Calculated Values158```python159# Bad: Calculating in Python and hardcoding result160total = df['Sales'].sum()161sheet['B10'] = total # Hardcodes 5000162163# Bad: Computing growth rate in Python164growth = (df.iloc[-1]['Revenue'] - df.iloc[0]['Revenue']) / df.iloc[0]['Revenue']165sheet['C5'] = growth # Hardcodes 0.15166167# Bad: Python calculation for average168avg = sum(values) / len(values)169sheet['D20'] = avg # Hardcodes 42.5170```171172### ✅ CORRECT - Using Excel Formulas173```python174# Good: Let Excel calculate the sum175sheet['B10'] = '=SUM(B2:B9)'176177# Good: Growth rate as Excel formula178sheet['C5'] = '=(C4-C2)/C2'179180# Good: Average using Excel function181sheet['D20'] = '=AVERAGE(D2:D19)'182```183184This applies to ALL calculations - totals, percentages, ratios, differences, etc. The spreadsheet should be able to recalculate when source data changes.185186## Common Workflow1871. **Choose tool**: pandas for data, openpyxl for formulas/formatting1882. **Create/Load**: Create new workbook or load existing file1893. **Modify**: Add/edit data, formulas, and formatting1904. **Save**: Write to file1915. **Recalculate formulas (MANDATORY IF USING FORMULAS)**: Use the recalc.py script192 ```bash193 python recalc.py output.xlsx194 ```1956. **Verify and fix any errors**: 196 - The script returns JSON with error details197 - If `status` is `errors_found`, check `error_summary` for specific error types and locations198 - Fix the identified errors and recalculate again199 - Common errors to fix:200 - `#REF!`: Invalid cell references201 - `#DIV/0!`: Division by zero202 - `#VALUE!`: Wrong data type in formula203 - `#NAME?`: Unrecognized formula name204205### Creating new Excel files206207```python208# Using openpyxl for formulas and formatting209from openpyxl import Workbook210from openpyxl.styles import Font, PatternFill, Alignment211212wb = Workbook()213sheet = wb.active214215# Add data216sheet['A1'] = 'Hello'217sheet['B1'] = 'World'218sheet.append(['Row', 'of', 'data'])219220# Add formula221sheet['B2'] = '=SUM(A1:A10)'222223# Formatting224sheet['A1'].font = Font(bold=True, color='FF0000')225sheet['A1'].fill = PatternFill('solid', start_color='FFFF00')226sheet['A1'].alignment = Alignment(horizontal='center')227228# Column width229sheet.column_dimensions['A'].width = 20230231wb.save('output.xlsx')232```233234### Editing existing Excel files235236```python237# Using openpyxl to preserve formulas and formatting238from openpyxl import load_workbook239240# Load existing file241wb = load_workbook('existing.xlsx')242sheet = wb.active # or wb['SheetName'] for specific sheet243244# Working with multiple sheets245for sheet_name in wb.sheetnames:246 sheet = wb[sheet_name]247 print(f"Sheet: {sheet_name}")248249# Modify cells250sheet['A1'] = 'New Value'251sheet.insert_rows(2) # Insert row at position 2252sheet.delete_cols(3) # Delete column 3253254# Add new sheet255new_sheet = wb.create_sheet('NewSheet')256new_sheet['A1'] = 'Data'257258wb.save('modified.xlsx')259```260261## Recalculating formulas262263Excel files created or modified by openpyxl contain formulas as strings but not calculated values. Use the provided `recalc.py` script to recalculate formulas:264265```bash266python recalc.py <excel_file> [timeout_seconds]267```268269Example:270```bash271python recalc.py output.xlsx 30272```273274The script:275- Automatically sets up LibreOffice macro on first run276- Recalculates all formulas in all sheets277- Scans ALL cells for Excel errors (#REF!, #DIV/0!, etc.)278- Returns JSON with detailed error locations and counts279- Works on both Linux and macOS280281## Formula Verification Checklist282283Quick checks to ensure formulas work correctly:284285### Essential Verification286- [ ] **Test 2-3 sample references**: Verify they pull correct values before building full model287- [ ] **Column mapping**: Confirm Excel columns match (e.g., column 64 = BL, not BK)288- [ ] **Row offset**: Remember Excel rows are 1-indexed (DataFrame row 5 = Excel row 6)289290### Common Pitfalls291- [ ] **NaN handling**: Check for null values with `pd.notna()`292- [ ] **Far-right columns**: FY data often in columns 50+ 293- [ ] **Multiple matches**: Search all occurrences, not just first294- [ ] **Division by zero**: Check denominators before using `/` in formulas (#DIV/0!)295- [ ] **Wrong references**: Verify all cell references point to intended cells (#REF!)296- [ ] **Cross-sheet references**: Use correct format (Sheet1!A1) for linking sheets297298### Formula Testing Strategy299- [ ] **Start small**: Test formulas on 2-3 cells before applying broadly300- [ ] **Verify dependencies**: Check all cells referenced in formulas exist301- [ ] **Test edge cases**: Include zero, negative, and very large values302303### Interpreting recalc.py Output304The script returns JSON with error details:305```json306{307 "status": "success", // or "errors_found"308 "total_errors": 0, // Total error count309 "total_formulas": 42, // Number of formulas in file310 "error_summary": { // Only present if errors found311 "#REF!": {312 "count": 2,313 "locations": ["Sheet1!B5", "Sheet1!C10"]314 }315 }316}317```318319## Best Practices320321### Library Selection322- **pandas**: Best for data analysis, bulk operations, and simple data export323- **openpyxl**: Best for complex formatting, formulas, and Excel-specific features324325### Working with openpyxl326- Cell indices are 1-based (row=1, column=1 refers to cell A1)327- Use `data_only=True` to read calculated values: `load_workbook('file.xlsx', data_only=True)`328- **Warning**: If opened with `data_only=True` and saved, formulas are replaced with values and permanently lost329- For large files: Use `read_only=True` for reading or `write_only=True` for writing330- Formulas are preserved but not evaluated - use recalc.py to update values331332### Working with pandas333- Specify data types to avoid inference issues: `pd.read_excel('file.xlsx', dtype={'id': str})`334- For large files, read specific columns: `pd.read_excel('file.xlsx', usecols=['A', 'C', 'E'])`335- Handle dates properly: `pd.read_excel('file.xlsx', parse_dates=['date_column'])`336337## Code Style Guidelines338**IMPORTANT**: When generating Python code for Excel operations:339- Write minimal, concise Python code without unnecessary comments340- Avoid verbose variable names and redundant operations341- Avoid unnecessary print statements342343**For Excel files themselves**:344- Add comments to cells with complex formulas or important assumptions345- Document data sources for hardcoded values346- Include notes for key calculations and model sections347348## Examples349350**Example 1: Build a financial model**351```352User: "Create a revenue projection model for the next 5 years"353→ Creates workbook with assumptions sheet + projections354→ Uses Excel formulas (=SUM, growth rates) not hardcoded values355→ Applies color coding (blue inputs, black formulas), runs recalc.py356```357358**Example 2: Analyze data from Excel file**359```360User: "What are the top 10 customers by revenue in this spreadsheet?"361→ Reads Excel with pandas362→ Groups, sorts, and filters data363→ Returns summary with statistics364```365366**Example 3: Update existing spreadsheet**367```368User: "Add a new column with profit margin calculations"369→ Loads workbook preserving existing formulas370→ Adds new column with margin formula referencing existing cells371→ Saves and recalculates to verify no errors372```