@mclawnet/agent 0.5.9 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/cli.js +168 -61
  2. package/dist/__tests__/cli.test.d.ts +2 -0
  3. package/dist/__tests__/cli.test.d.ts.map +1 -0
  4. package/dist/__tests__/service-config.test.d.ts +2 -0
  5. package/dist/__tests__/service-config.test.d.ts.map +1 -0
  6. package/dist/__tests__/service-linux.test.d.ts +2 -0
  7. package/dist/__tests__/service-linux.test.d.ts.map +1 -0
  8. package/dist/__tests__/service-macos.test.d.ts +2 -0
  9. package/dist/__tests__/service-macos.test.d.ts.map +1 -0
  10. package/dist/__tests__/service-windows.test.d.ts +2 -0
  11. package/dist/__tests__/service-windows.test.d.ts.map +1 -0
  12. package/dist/backend-adapter.d.ts +2 -0
  13. package/dist/backend-adapter.d.ts.map +1 -1
  14. package/dist/{chunk-KHPEQTWF.js → chunk-KITKMSBE.js} +166 -90
  15. package/dist/chunk-KITKMSBE.js.map +1 -0
  16. package/dist/chunk-W3LSW4XY.js +95 -0
  17. package/dist/chunk-W3LSW4XY.js.map +1 -0
  18. package/dist/hub-connection.d.ts.map +1 -1
  19. package/dist/index.js +1 -1
  20. package/dist/linux-5KQ4SCAA.js +175 -0
  21. package/dist/linux-5KQ4SCAA.js.map +1 -0
  22. package/dist/macos-FGY546NC.js +173 -0
  23. package/dist/macos-FGY546NC.js.map +1 -0
  24. package/dist/service/config.d.ts +19 -0
  25. package/dist/service/config.d.ts.map +1 -0
  26. package/dist/service/index.d.ts +6 -0
  27. package/dist/service/index.d.ts.map +1 -0
  28. package/dist/service/index.js +46 -0
  29. package/dist/service/index.js.map +1 -0
  30. package/dist/service/linux.d.ts +18 -0
  31. package/dist/service/linux.d.ts.map +1 -0
  32. package/dist/service/macos.d.ts +18 -0
  33. package/dist/service/macos.d.ts.map +1 -0
  34. package/dist/service/types.d.ts +19 -0
  35. package/dist/service/types.d.ts.map +1 -0
  36. package/dist/service/windows.d.ts +18 -0
  37. package/dist/service/windows.d.ts.map +1 -0
  38. package/dist/session-manager.d.ts +4 -7
  39. package/dist/session-manager.d.ts.map +1 -1
  40. package/dist/skill-loader.d.ts +8 -0
  41. package/dist/skill-loader.d.ts.map +1 -0
  42. package/dist/start.d.ts.map +1 -1
  43. package/dist/start.js +1 -1
  44. package/dist/windows-PIJ4CMWX.js +164 -0
  45. package/dist/windows-PIJ4CMWX.js.map +1 -0
  46. package/package.json +8 -6
  47. package/skills/academic-search/SKILL.md +147 -0
  48. package/skills/architecture/SKILL.md +294 -0
  49. package/skills/changelog-generator/SKILL.md +112 -0
  50. package/skills/chart-visualization/SKILL.md +183 -0
  51. package/skills/code-review/SKILL.md +304 -0
  52. package/skills/codebase-health/SKILL.md +281 -0
  53. package/skills/consulting-analysis/SKILL.md +584 -0
  54. package/skills/content-research-writer/SKILL.md +546 -0
  55. package/skills/data-analysis/SKILL.md +194 -0
  56. package/skills/deep-research/SKILL.md +198 -0
  57. package/skills/docx/SKILL.md +211 -0
  58. package/skills/github-deep-research/SKILL.md +207 -0
  59. package/skills/image-generation/SKILL.md +209 -0
  60. package/skills/lead-research-assistant/SKILL.md +207 -0
  61. package/skills/mcp-builder/SKILL.md +304 -0
  62. package/skills/meeting-insights-analyzer/SKILL.md +335 -0
  63. package/skills/pair-programming/SKILL.md +196 -0
  64. package/skills/pdf/SKILL.md +309 -0
  65. package/skills/performance-analysis/SKILL.md +261 -0
  66. package/skills/podcast-generation/SKILL.md +224 -0
  67. package/skills/pptx/SKILL.md +497 -0
  68. package/skills/project-learnings/SKILL.md +280 -0
  69. package/skills/security-audit/SKILL.md +211 -0
  70. package/skills/skill-creator/SKILL.md +200 -0
  71. package/skills/technical-writing/SKILL.md +286 -0
  72. package/skills/testing/SKILL.md +363 -0
  73. package/skills/video-generation/SKILL.md +247 -0
  74. package/skills/web-design-guidelines/SKILL.md +203 -0
  75. package/skills/webapp-testing/SKILL.md +162 -0
  76. package/skills/workflow-automation/SKILL.md +299 -0
  77. package/skills/xlsx/SKILL.md +305 -0
  78. package/dist/chunk-KHPEQTWF.js.map +0 -1
@@ -0,0 +1,299 @@
1
+ ---
2
+ name: workflow-automation
3
+ description: Design and implement automated multi-step workflows for software development processes. Use when automating CI/CD pipelines, release processes, deployment workflows, or any repeatable multi-step task orchestration.
4
+ disable-model-invocation: true
5
+ ---
6
+
7
+ # Workflow Automation
8
+
9
+ Design and implement automated workflows that orchestrate multi-step software development processes — from CI/CD pipelines to release management, deployment, and custom development workflows.
10
+
11
+ ## Overview
12
+
13
+ This skill helps you break down complex processes into automated, repeatable workflows. Every workflow should be reliable (handles failures gracefully), observable (you can see what happened and why), and maintainable (easy to modify when requirements change).
14
+
15
+ ## When to Use
16
+
17
+ - Setting up CI/CD pipelines for a project
18
+ - Automating release and deployment processes
19
+ - Creating repeatable multi-step task sequences
20
+ - Designing build, test, and deploy workflows
21
+ - Automating code quality gates and review processes
22
+ - Creating custom development automation scripts
23
+
24
+ ## When NOT to Use
25
+
26
+ - **One-off tasks** — just run the commands directly
27
+ - **Simple single-step operations** — automation overhead isn't worth it
28
+ - **Tasks requiring human judgment at every step** — workflows should have clear automation points
29
+
30
+ ## Workflow Design Process
31
+
32
+ ### Step 1: Map the Process
33
+
34
+ Before automating, document the current manual process:
35
+
36
+ 1. List every step in order
37
+ 2. Identify which steps can run in parallel
38
+ 3. Mark decision points (conditions that change the flow)
39
+ 4. Identify failure modes for each step
40
+ 5. Note which steps need human approval
41
+
42
+ ### Step 2: Define the Workflow Structure
43
+
44
+ ```yaml
45
+ name: example-workflow
46
+ trigger: [push, pull_request, manual]
47
+
48
+ steps:
49
+ - name: validate
50
+ run: lint + type-check
51
+ on_failure: stop
52
+
53
+ - name: test
54
+ run: unit tests + integration tests
55
+ parallel: true
56
+ on_failure: stop
57
+
58
+ - name: build
59
+ depends_on: [validate, test]
60
+ run: compile + bundle
61
+ on_failure: notify
62
+
63
+ - name: deploy
64
+ depends_on: [build]
65
+ requires_approval: true
66
+ run: deploy to staging
67
+ on_failure: rollback
68
+ ```
69
+
70
+ ### Step 3: Implement with Proper Error Handling
71
+
72
+ Every step should:
73
+ - Have a clear success/failure signal (exit code, output check)
74
+ - Log what it's doing (for debugging failed runs)
75
+ - Clean up after itself (temp files, processes)
76
+ - Support retry for transient failures (network, rate limits)
77
+
78
+ ## Common Workflow Patterns
79
+
80
+ ### CI Pipeline
81
+
82
+ ```yaml
83
+ # .github/workflows/ci.yml
84
+ name: CI
85
+ on: [push, pull_request]
86
+
87
+ jobs:
88
+ lint:
89
+ runs-on: ubuntu-latest
90
+ steps:
91
+ - uses: actions/checkout@v4
92
+ - run: npm ci
93
+ - run: npm run lint
94
+
95
+ test:
96
+ runs-on: ubuntu-latest
97
+ steps:
98
+ - uses: actions/checkout@v4
99
+ - run: npm ci
100
+ - run: npm test -- --coverage
101
+ - uses: actions/upload-artifact@v4
102
+ with:
103
+ name: coverage
104
+ path: coverage/
105
+
106
+ build:
107
+ needs: [lint, test]
108
+ runs-on: ubuntu-latest
109
+ steps:
110
+ - uses: actions/checkout@v4
111
+ - run: npm ci
112
+ - run: npm run build
113
+ ```
114
+
115
+ ### Release Workflow
116
+
117
+ ```yaml
118
+ name: Release
119
+ on:
120
+ push:
121
+ tags: ['v*']
122
+
123
+ jobs:
124
+ release:
125
+ runs-on: ubuntu-latest
126
+ steps:
127
+ - uses: actions/checkout@v4
128
+ - run: npm ci
129
+ - run: npm test
130
+ - run: npm run build
131
+ - run: npm publish
132
+ env:
133
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
134
+ - uses: softprops/action-gh-release@v1
135
+ with:
136
+ generate_release_notes: true
137
+ ```
138
+
139
+ ### Deployment Pipeline
140
+
141
+ ```yaml
142
+ name: Deploy
143
+ on:
144
+ workflow_dispatch:
145
+ inputs:
146
+ environment:
147
+ type: choice
148
+ options: [staging, production]
149
+
150
+ jobs:
151
+ deploy:
152
+ runs-on: ubuntu-latest
153
+ environment: ${{ inputs.environment }}
154
+ steps:
155
+ - uses: actions/checkout@v4
156
+ - run: npm ci && npm run build
157
+ - run: ./scripts/deploy.sh ${{ inputs.environment }}
158
+ - run: ./scripts/health-check.sh ${{ inputs.environment }}
159
+ ```
160
+
161
+ ## Shell Script Automation
162
+
163
+ For custom workflows that don't fit CI/CD platforms:
164
+
165
+ ### Task Runner Pattern
166
+
167
+ ```bash
168
+ #!/bin/bash
169
+ set -euo pipefail
170
+
171
+ # Colors for output
172
+ RED='\033[0;31m'
173
+ GREEN='\033[0;32m'
174
+ NC='\033[0m'
175
+
176
+ step() { echo -e "\n${GREEN}==>${NC} $1"; }
177
+ fail() { echo -e "${RED}FAILED:${NC} $1"; exit 1; }
178
+
179
+ step "Linting..."
180
+ npm run lint || fail "Lint errors found"
181
+
182
+ step "Running tests..."
183
+ npm test || fail "Tests failed"
184
+
185
+ step "Building..."
186
+ npm run build || fail "Build failed"
187
+
188
+ step "All checks passed!"
189
+ ```
190
+
191
+ ### Retry Pattern
192
+
193
+ ```bash
194
+ retry() {
195
+ local max_attempts=$1; shift
196
+ local delay=$1; shift
197
+ local attempt=1
198
+
199
+ while [ $attempt -le $max_attempts ]; do
200
+ if "$@"; then
201
+ return 0
202
+ fi
203
+ echo "Attempt $attempt/$max_attempts failed. Retrying in ${delay}s..."
204
+ sleep $delay
205
+ attempt=$((attempt + 1))
206
+ done
207
+ return 1
208
+ }
209
+
210
+ # Usage: retry 3 5 curl -f https://api.example.com/health
211
+ ```
212
+
213
+ ### Parallel Execution
214
+
215
+ ```bash
216
+ # Run independent tasks in parallel
217
+ lint_pid=""
218
+ test_pid=""
219
+
220
+ npm run lint &
221
+ lint_pid=$!
222
+
223
+ npm test &
224
+ test_pid=$!
225
+
226
+ # Wait and check results
227
+ wait $lint_pid || fail "Lint failed"
228
+ wait $test_pid || fail "Tests failed"
229
+ ```
230
+
231
+ ## Makefile Workflows
232
+
233
+ For project-level task automation:
234
+
235
+ ```makefile
236
+ .PHONY: all lint test build deploy clean
237
+
238
+ all: lint test build
239
+
240
+ lint:
241
+ npm run lint
242
+ npm run typecheck
243
+
244
+ test:
245
+ npm test -- --coverage
246
+
247
+ build: lint test
248
+ npm run build
249
+
250
+ deploy: build
251
+ ./scripts/deploy.sh $(ENV)
252
+
253
+ clean:
254
+ rm -rf dist/ coverage/ node_modules/.cache
255
+ ```
256
+
257
+ ## Workflow Quality Checklist
258
+
259
+ ### Reliability
260
+ - [ ] Every step has explicit error handling (set -e, || exit, try/catch)
261
+ - [ ] Transient failures are retried with backoff
262
+ - [ ] Rollback procedures exist for destructive steps
263
+ - [ ] Timeouts prevent hanging steps
264
+
265
+ ### Observability
266
+ - [ ] Each step logs start, progress, and completion
267
+ - [ ] Failure messages include enough context to debug
268
+ - [ ] Artifacts (logs, reports, screenshots) are preserved on failure
269
+ - [ ] Notifications sent on failure (Slack, email, etc.)
270
+
271
+ ### Maintainability
272
+ - [ ] Steps are independent and composable
273
+ - [ ] Configuration is externalized (env vars, config files)
274
+ - [ ] Secrets are managed securely (not hardcoded)
275
+ - [ ] Workflow can be run locally for testing
276
+
277
+ ### Performance
278
+ - [ ] Independent steps run in parallel
279
+ - [ ] Caching is used for dependencies (node_modules, build artifacts)
280
+ - [ ] Incremental builds where possible
281
+ - [ ] Resource limits prevent runaway processes
282
+
283
+ ## Anti-Patterns
284
+
285
+ ### Monolithic Workflow
286
+ **Problem**: One giant workflow that does everything sequentially.
287
+ **Fix**: Break into independent jobs that run in parallel. Use `needs:` for real dependencies.
288
+
289
+ ### No Failure Handling
290
+ **Problem**: Script fails silently, or failure at step 3 still runs steps 4-10.
291
+ **Fix**: Use `set -euo pipefail` in bash. Use `needs:` and `if: failure()` in CI.
292
+
293
+ ### Manual Steps Disguised as Automation
294
+ **Problem**: Workflow has "TODO: manually verify X" comments.
295
+ **Fix**: Either automate the verification or add explicit approval gates.
296
+
297
+ ### Hardcoded Secrets
298
+ **Problem**: API keys, tokens, passwords in workflow files.
299
+ **Fix**: Use secrets management (GitHub Secrets, Vault, env vars from CI).
@@ -0,0 +1,305 @@
1
+ ---
2
+ name: xlsx
3
+ description: Create, edit, and analyze Excel spreadsheets (.xlsx) with support for formulas, formatting, data analysis, and visualization. Use when building spreadsheets, working with tabular data, creating financial models, or recalculating formula-based workbooks.
4
+ disable-model-invocation: true
5
+ ---
6
+
7
+ # Requirements for Outputs
8
+
9
+ ## When to Use
10
+
11
+ - Creating new Excel spreadsheets with formulas and formatting
12
+ - Reading, analyzing, or transforming data in .xlsx/.csv/.tsv files
13
+ - Editing existing spreadsheets while preserving formulas and styles
14
+ - Building financial models with proper formula structure
15
+ - Data visualization within spreadsheets
16
+
17
+ ## When NOT to Use
18
+
19
+ - **Word documents** — use the `docx` skill
20
+ - **Presentations** — use the `pptx` skill
21
+ - **PDF documents** — use the `pdf` skill
22
+ - **One-off data analysis without Excel output** — use `data-analysis` skill
23
+ - **Chart generation for reports** — use `chart-visualization` skill
24
+
25
+ ## All Excel files
26
+
27
+ ### Zero Formula Errors
28
+ - Every Excel model MUST be delivered with ZERO formula errors (#REF!, #DIV/0!, #VALUE!, #N/A, #NAME?)
29
+
30
+ ### Preserve Existing Templates (when updating templates)
31
+ - Study and EXACTLY match existing format, style, and conventions when modifying files
32
+ - Never impose standardized formatting on files with established patterns
33
+ - Existing template conventions ALWAYS override these guidelines
34
+
35
+ ## Financial models
36
+
37
+ ### Color Coding Standards
38
+ Unless otherwise stated by the user or existing template
39
+
40
+ #### Industry-Standard Color Conventions
41
+ - **Blue text (RGB: 0,0,255)**: Hardcoded inputs, and numbers users will change for scenarios
42
+ - **Black text (RGB: 0,0,0)**: ALL formulas and calculations
43
+ - **Green text (RGB: 0,128,0)**: Links pulling from other worksheets within same workbook
44
+ - **Red text (RGB: 255,0,0)**: External links to other files
45
+ - **Yellow background (RGB: 255,255,0)**: Key assumptions needing attention or cells that need to be updated
46
+
47
+ ### Number Formatting Standards
48
+
49
+ #### Required Format Rules
50
+ - **Years**: Format as text strings (e.g., "2024" not "2,024")
51
+ - **Currency**: Use $#,##0 format; ALWAYS specify units in headers ("Revenue ($mm)")
52
+ - **Zeros**: Use number formatting to make all zeros "-", including percentages (e.g., "$#,##0;($#,##0);-")
53
+ - **Percentages**: Default to 0.0% format (one decimal)
54
+ - **Multiples**: Format as 0.0x for valuation multiples (EV/EBITDA, P/E)
55
+ - **Negative numbers**: Use parentheses (123) not minus -123
56
+
57
+ ### Formula Construction Rules
58
+
59
+ #### Assumptions Placement
60
+ - Place ALL assumptions (growth rates, margins, multiples, etc.) in separate assumption cells
61
+ - Use cell references instead of hardcoded values in formulas
62
+ - Example: Use =B5*(1+$B$6) instead of =B5*1.05
63
+
64
+ #### Formula Error Prevention
65
+ - Verify all cell references are correct
66
+ - Check for off-by-one errors in ranges
67
+ - Ensure consistent formulas across all projection periods
68
+ - Test with edge cases (zero values, negative numbers)
69
+ - Verify no unintended circular references
70
+
71
+ #### Documentation Requirements for Hardcodes
72
+ - Comment or in cells beside (if end of table). Format: "Source: [System/Document], [Date], [Specific Reference], [URL if applicable]"
73
+ - Examples:
74
+ - "Source: Company 10-K, FY2024, Page 45, Revenue Note, [SEC EDGAR URL]"
75
+ - "Source: Company 10-Q, Q2 2025, Exhibit 99.1, [SEC EDGAR URL]"
76
+ - "Source: Bloomberg Terminal, 8/15/2025, AAPL US Equity"
77
+ - "Source: FactSet, 8/20/2025, Consensus Estimates Screen"
78
+
79
+ # XLSX creation, editing, and analysis
80
+
81
+ ## Overview
82
+
83
+ 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.
84
+
85
+ ## Important Requirements
86
+
87
+ **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
88
+
89
+ ## Reading and analyzing data
90
+
91
+ ### Data analysis with pandas
92
+ For data analysis, visualization, and basic operations, use **pandas** which provides powerful data manipulation capabilities:
93
+
94
+ ```python
95
+ import pandas as pd
96
+
97
+ # Read Excel
98
+ df = pd.read_excel('file.xlsx') # Default: first sheet
99
+ all_sheets = pd.read_excel('file.xlsx', sheet_name=None) # All sheets as dict
100
+
101
+ # Analyze
102
+ df.head() # Preview data
103
+ df.info() # Column info
104
+ df.describe() # Statistics
105
+
106
+ # Write Excel
107
+ df.to_excel('output.xlsx', index=False)
108
+ ```
109
+
110
+ ## Excel File Workflows
111
+
112
+ ## CRITICAL: Use Formulas, Not Hardcoded Values
113
+
114
+ **Always use Excel formulas instead of calculating values in Python and hardcoding them.** This ensures the spreadsheet remains dynamic and updateable.
115
+
116
+ ### ❌ WRONG - Hardcoding Calculated Values
117
+ ```python
118
+ # Bad: Calculating in Python and hardcoding result
119
+ total = df['Sales'].sum()
120
+ sheet['B10'] = total # Hardcodes 5000
121
+
122
+ # Bad: Computing growth rate in Python
123
+ growth = (df.iloc[-1]['Revenue'] - df.iloc[0]['Revenue']) / df.iloc[0]['Revenue']
124
+ sheet['C5'] = growth # Hardcodes 0.15
125
+
126
+ # Bad: Python calculation for average
127
+ avg = sum(values) / len(values)
128
+ sheet['D20'] = avg # Hardcodes 42.5
129
+ ```
130
+
131
+ ### ✅ CORRECT - Using Excel Formulas
132
+ ```python
133
+ # Good: Let Excel calculate the sum
134
+ sheet['B10'] = '=SUM(B2:B9)'
135
+
136
+ # Good: Growth rate as Excel formula
137
+ sheet['C5'] = '=(C4-C2)/C2'
138
+
139
+ # Good: Average using Excel function
140
+ sheet['D20'] = '=AVERAGE(D2:D19)'
141
+ ```
142
+
143
+ This applies to ALL calculations - totals, percentages, ratios, differences, etc. The spreadsheet should be able to recalculate when source data changes.
144
+
145
+ ## Common Workflow
146
+ 1. **Choose tool**: pandas for data, openpyxl for formulas/formatting
147
+ 2. **Create/Load**: Create new workbook or load existing file
148
+ 3. **Modify**: Add/edit data, formulas, and formatting
149
+ 4. **Save**: Write to file
150
+ 5. **Recalculate formulas (MANDATORY IF USING FORMULAS)**: Use the recalc.py script
151
+ ```bash
152
+ python recalc.py output.xlsx
153
+ ```
154
+ 6. **Verify and fix any errors**:
155
+ - The script returns JSON with error details
156
+ - If `status` is `errors_found`, check `error_summary` for specific error types and locations
157
+ - Fix the identified errors and recalculate again
158
+ - Common errors to fix:
159
+ - `#REF!`: Invalid cell references
160
+ - `#DIV/0!`: Division by zero
161
+ - `#VALUE!`: Wrong data type in formula
162
+ - `#NAME?`: Unrecognized formula name
163
+
164
+ ### Creating new Excel files
165
+
166
+ ```python
167
+ # Using openpyxl for formulas and formatting
168
+ from openpyxl import Workbook
169
+ from openpyxl.styles import Font, PatternFill, Alignment
170
+
171
+ wb = Workbook()
172
+ sheet = wb.active
173
+
174
+ # Add data
175
+ sheet['A1'] = 'Hello'
176
+ sheet['B1'] = 'World'
177
+ sheet.append(['Row', 'of', 'data'])
178
+
179
+ # Add formula
180
+ sheet['B2'] = '=SUM(A1:A10)'
181
+
182
+ # Formatting
183
+ sheet['A1'].font = Font(bold=True, color='FF0000')
184
+ sheet['A1'].fill = PatternFill('solid', start_color='FFFF00')
185
+ sheet['A1'].alignment = Alignment(horizontal='center')
186
+
187
+ # Column width
188
+ sheet.column_dimensions['A'].width = 20
189
+
190
+ wb.save('output.xlsx')
191
+ ```
192
+
193
+ ### Editing existing Excel files
194
+
195
+ ```python
196
+ # Using openpyxl to preserve formulas and formatting
197
+ from openpyxl import load_workbook
198
+
199
+ # Load existing file
200
+ wb = load_workbook('existing.xlsx')
201
+ sheet = wb.active # or wb['SheetName'] for specific sheet
202
+
203
+ # Working with multiple sheets
204
+ for sheet_name in wb.sheetnames:
205
+ sheet = wb[sheet_name]
206
+ print(f"Sheet: {sheet_name}")
207
+
208
+ # Modify cells
209
+ sheet['A1'] = 'New Value'
210
+ sheet.insert_rows(2) # Insert row at position 2
211
+ sheet.delete_cols(3) # Delete column 3
212
+
213
+ # Add new sheet
214
+ new_sheet = wb.create_sheet('NewSheet')
215
+ new_sheet['A1'] = 'Data'
216
+
217
+ wb.save('modified.xlsx')
218
+ ```
219
+
220
+ ## Recalculating formulas
221
+
222
+ Excel files created or modified by openpyxl contain formulas as strings but not calculated values. Use the provided `recalc.py` script to recalculate formulas:
223
+
224
+ ```bash
225
+ python recalc.py <excel_file> [timeout_seconds]
226
+ ```
227
+
228
+ Example:
229
+ ```bash
230
+ python recalc.py output.xlsx 30
231
+ ```
232
+
233
+ The script:
234
+ - Automatically sets up LibreOffice macro on first run
235
+ - Recalculates all formulas in all sheets
236
+ - Scans ALL cells for Excel errors (#REF!, #DIV/0!, etc.)
237
+ - Returns JSON with detailed error locations and counts
238
+ - Works on both Linux and macOS
239
+
240
+ ## Formula Verification Checklist
241
+
242
+ Quick checks to ensure formulas work correctly:
243
+
244
+ ### Essential Verification
245
+ - [ ] **Test 2-3 sample references**: Verify they pull correct values before building full model
246
+ - [ ] **Column mapping**: Confirm Excel columns match (e.g., column 64 = BL, not BK)
247
+ - [ ] **Row offset**: Remember Excel rows are 1-indexed (DataFrame row 5 = Excel row 6)
248
+
249
+ ### Common Pitfalls
250
+ - [ ] **NaN handling**: Check for null values with `pd.notna()`
251
+ - [ ] **Far-right columns**: FY data often in columns 50+
252
+ - [ ] **Multiple matches**: Search all occurrences, not just first
253
+ - [ ] **Division by zero**: Check denominators before using `/` in formulas (#DIV/0!)
254
+ - [ ] **Wrong references**: Verify all cell references point to intended cells (#REF!)
255
+ - [ ] **Cross-sheet references**: Use correct format (Sheet1!A1) for linking sheets
256
+
257
+ ### Formula Testing Strategy
258
+ - [ ] **Start small**: Test formulas on 2-3 cells before applying broadly
259
+ - [ ] **Verify dependencies**: Check all cells referenced in formulas exist
260
+ - [ ] **Test edge cases**: Include zero, negative, and very large values
261
+
262
+ ### Interpreting recalc.py Output
263
+ The script returns JSON with error details:
264
+ ```json
265
+ {
266
+ "status": "success", // or "errors_found"
267
+ "total_errors": 0, // Total error count
268
+ "total_formulas": 42, // Number of formulas in file
269
+ "error_summary": { // Only present if errors found
270
+ "#REF!": {
271
+ "count": 2,
272
+ "locations": ["Sheet1!B5", "Sheet1!C10"]
273
+ }
274
+ }
275
+ }
276
+ ```
277
+
278
+ ## Best Practices
279
+
280
+ ### Library Selection
281
+ - **pandas**: Best for data analysis, bulk operations, and simple data export
282
+ - **openpyxl**: Best for complex formatting, formulas, and Excel-specific features
283
+
284
+ ### Working with openpyxl
285
+ - Cell indices are 1-based (row=1, column=1 refers to cell A1)
286
+ - Use `data_only=True` to read calculated values: `load_workbook('file.xlsx', data_only=True)`
287
+ - **Warning**: If opened with `data_only=True` and saved, formulas are replaced with values and permanently lost
288
+ - For large files: Use `read_only=True` for reading or `write_only=True` for writing
289
+ - Formulas are preserved but not evaluated - use recalc.py to update values
290
+
291
+ ### Working with pandas
292
+ - Specify data types to avoid inference issues: `pd.read_excel('file.xlsx', dtype={'id': str})`
293
+ - For large files, read specific columns: `pd.read_excel('file.xlsx', usecols=['A', 'C', 'E'])`
294
+ - Handle dates properly: `pd.read_excel('file.xlsx', parse_dates=['date_column'])`
295
+
296
+ ## Code Style Guidelines
297
+ **IMPORTANT**: When generating Python code for Excel operations:
298
+ - Write minimal, concise Python code without unnecessary comments
299
+ - Avoid verbose variable names and redundant operations
300
+ - Avoid unnecessary print statements
301
+
302
+ **For Excel files themselves**:
303
+ - Add comments to cells with complex formulas or important assumptions
304
+ - Document data sources for hardcoded values
305
+ - Include notes for key calculations and model sections