---
TEMPLATE REQUIREMENT
**This skill uses templates for LBO models. Always check for an attached template file first.**
Before starting any LBO model:
- **If a template file is attached/provided**: Use that template's structure exactly - copy it and populate with the user's data
- **If no template is attached**: Ask the user: *"Do you have a specific LBO template you'd like me to use? If not, I can use the standard template which includes Sources & Uses, Operating Model, Debt Schedule, and Returns Analysis."*
- **If using the standard template**: Copy `examples/LBO_Model.xlsx` as your starting point and populate it with the user's assumptions
**IMPORTANT**: When a file like `LBO_Model.xlsx` is attached, you MUST use it as your template - do not build from scratch. Even if the template seems complex or has more features than needed, copy it and adapt it to the user's requirements. Never decide to "build from scratch" when a template is provided.
---
CRITICAL INSTRUCTIONS FOR CLAUDE - READ FIRST
Environment: Office JS vs Python
**If running inside Excel (Office Add-in / Office JS environment):**
- Use Office JS (`Excel.run(async (context) => {...})`) directly — do NOT use Python/openpyxl
- Write formulas via `range.formulas = [["=B5*B6"]]` — Office JS formulas recalculate natively in the live workbook
- The same formulas-over-hardcodes rule applies: set `range.formulas`, never `range.values` for anything that should be a calculation
- Use `range.format.font.color` / `range.format.fill.color` for the blue/black/purple/green convention
- No separate recalc step needed — Excel handles calculation natively
- **Merged cell pitfall:** Do NOT call `.merge()` then set `.values` on the merged range (throws `InvalidArgument` — range still reports original dimensions). Instead: write value to top-left cell alone (`ws.getRange("A7").values = [["SOURCES & USES"]]`), then merge + format the full range (`ws.getRange("A7:F7").merge(); ws.getRange("A7:F7").format.fill.color = "#1F4E79";`)
**If generating a standalone .xlsx file (no live Excel session):**
- Use Python/openpyxl as described below
- Write formula strings (`ws["D20"] = "=B5*B6"`), then run `recalc.py` before delivery
The rest of this skill is written with openpyxl examples, but the same principles apply to Office JS — just translate the API calls.
Core Principles
- **Every calculation must be an Excel formula** - NEVER compute values in Python and hardcode results into cells. When using openpyxl, write `cell.value = "=B5*B6"` (formula string), NOT `cell.value = 1250` (computed result). The model must be dynamic and update when inputs change.
- **Use the template structure** - Follow the organization in `examples/LBO_Model.xlsx` or the user's provided template. Do not invent your own layout.
- **Use proper cell references** - All formulas should reference the appropriate cells. Never type numbers that should come from other cells.
- **Maintain sign convention consistency** - Follow whatever sign convention the template uses (some use negative for outflows, some use positive). Be consistent throughout.
- **Work section by section, verify with user at each step** - Complete one section fully, show the user what was built, run the section's verification checks, and get confirmation BEFORE moving to the next section. Do NOT build the entire model end-to-end and then present it — later sections depend on earlier ones, so catching a mistake in Sources & Uses after the returns are already built means rework everywhere.
Formula Color Conventions
- **Blue (0000FF)**: Hardcoded inputs - typed numbers that don't re
<!-- truncated -->