formula-protection
Prevent accidental modification of sacred spreadsheet formulas in Google Sheets Portfolio Tracker. Blocks edits to GOOGLEFINANCE formulas, calculated columns, and total rows. Allows only IFERROR wrappers, fixing broken references, and expanding ranges. Triggers on update formula, modify column, fix errors, or any attempt to edit formula-based cells.
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o formula-protection.zip https://jpskill.com/download/22817.zip && unzip -o formula-protection.zip && rm formula-protection.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/22817.zip -OutFile "$d\formula-protection.zip"; Expand-Archive "$d\formula-protection.zip" -DestinationPath $d -Force; ri "$d\formula-protection.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
formula-protection.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
formula-protectionフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
[スキル名] formula-protection
数式保護
目的
ガードレールスキル - スプレッドシートの整合性を維持する重要な数式の偶発的な変更や削除を防ぎます。自動計算される列を保護することで、財務データの正確性を保証します。
使用する状況(自動ブロック)
このスキルは、以下の状況を検知すると自動的にブロックします。
- 「数式の更新」、「数式の変更」、「数式の修正」を試みる場合
- 列C(GOOGLEFINANCEの価格数式)を編集する場合
- 列D~F、H~S(計算数式)を変更する場合
- 適切な手順なしに数式エラー(#N/A、#DIV/0!、#REF!)を修正する場合
- ユーザーが「数式を修正する」、「セルを編集する」、「列C/D/Eを更新する」と発言した場合
これはブロックするスキルです - 数式関連の編集を進める前に、このスキルを必ず使用してください。
神聖な数式(決して触れないでください)
DataHubタブ
列C: 最終価格
=GOOGLEFINANCE(A2, "price")
- 株価をリアルタイムで自動更新します
- ❌ 決して変更しないでください - 価格はGoogle Financeから取得する必要があります
- ❌ 決して静的な値に置き換えないでください
- ✅ 上場廃止銘柄で#N/Aが表示される場合、IFERRORで囲むことのみ許可されます
列D~E: $変動、%変動
=C2 - G2 ($変動)
=D2 / G2 (%変動)
- 最終価格(C)と平均取得原価(G)から計算されます
- ❌ 決して触れないでください - 数式に自動計算させてください
列H~M: 損益
=L2 - M2 (合計損益 $)
=K2 / M2 (合計損益 %)
=B2 * C2 (現在価値)
=B2 * G2 (取得原価合計)
- 主要なポートフォリオパフォーマンス指標です
- ❌ 決して変更しないでください - 正確性はこの数式に依存します
- ✅ #DIV/0!エラーが表示される場合、IFERRORを追加することのみ許可されます
列N~S: 高度な指標
- 範囲、配当データ、レイヤー分類が含まれます
- 数式と手動分類の組み合わせです
- ⚠️ 編集する前にspreadsheet-architecture.mdを参照してください
Dividend Trackerタブ
列F: 配当合計 $
=D2 * E2 (株式数 × 1株当たり配当)
- ファンドごとの予想配当収入を計算します
- ❌ 決して変更しないでください - 数式駆動のままでなければなりません
合計行の数式
=SUM(F2:F50) (予想配当合計)
- すべての配当収入を合計します
- ❌ 決して削除または変更しないでください
- ✅ データが50行を超えて増える場合、範囲を拡張することのみ許可されます
Margin Dashboardタブ
カバレッジ比率
=IFERROR(B10 / B11, 0) (配当 ÷ 金利費用)
- マージン戦略における重要な安全性指標です
- ❌ IFERRORラッパーを削除しないでください
- ✅ 新しい安全閾値を追加する場合、更新することのみ許可されます
許可される操作
✅ 安全: IFERROR()ラッパーの追加
目的: ロジックを変更せずにエラー表示を防ぐ
例:
Before: =GOOGLEFINANCE(A2, "price")
After: =IFERROR(GOOGLEFINANCE(A2, "price"), "N/A")
Before: =B10 / B11
After: =IFERROR(B10 / B11, 0)
使用する状況:
- 上場廃止銘柄による#N/Aエラー(GOOGLEFINANCEの失敗)
- マージン残高が$0の場合の#DIV/0!エラー
- 削除された行による#REF!エラー(一時的な修正としてIFERRORを使用)
✅ 安全: 壊れたシート参照の修正
目的: シート名の変更や移動による参照を修正する
例:
Before: =Sheet1!A1
After: ='DataHub'!A1
Before: ='Dividend Tracker OLD'!B10
After: ='Dividend Tracker'!B10
使用する状況:
- シート名が変更された場合(Sheet1 → DataHub)
- シートが複製され、古い参照が残っている場合
- タブが別の位置に移動した場合
✅ 安全: 数式範囲の拡張
目的: ロジックを変更せずに新しいデータ行を含める
例:
Before: =SUM(F2:F50)
After: =SUM(F2:F100)
Before: =AVERAGE(B2:B30)
After: =AVERAGE(B2:B50)
使用する状況:
- 50行を超えて新しいポートフォリオポジションが追加された場合
- 配当トラッカーが予想サイズを超えて増大した場合
- マージンダッシュボードに月次エントリが蓄積された場合
✅ 安全: セル参照のタイプミスの修正
目的: 数式構築における明らかな間違いを修正する
例:
Before: =B100 * C100 (B100は存在しない)
After: =B10 * C10
Before: =A2 + A2 (重複したセル参照)
After: =A2 + B2 (正しいセル)
使用する状況:
- 数式が既存しない行を参照している場合
- セル参照に明らかなタイプミスがある場合
- 手動エラーにより数式が明らかに壊れている場合
禁止される操作
❌ 決して: 数式ロジックの変更
してはならないことの例:
❌ =SUM(F2:F50) → =AVERAGE(F2:F50) (意味が変わる)
❌ =B2 * C2 → =B2 + C2 (計算が変わる)
❌ =GOOGLEFINANCE(A2, "price") → =GOOGLEFINANCE(A2, "volume")
理由: 計算データの意味が変わり、ダッシュボードの整合性が損なわれます
❌ 決して: 数式を静的な値に置き換える
してはならないことの例:
❌ =GOOGLEFINANCE("TSLA", "price") → 445.47 (ハードコード)
❌ =B2 * C2 → 32964.78 (静的な値)
❌ =SUM(F2:F50) → 2847.32 (動的な計算が失われる)
理由: データが古くなり、自動的に更新されなくなります
❌ 決して: 数式の削除
してはならないことの例:
❌ 列C(最終価格数式)を「クリーンアップ」のために削除する
❌ 合計行の数式を「簡素化」のために削除する
❌ 数式セルを「最初からやり直す」ためにクリアする
理由: データパイプラインを破壊し、すべての依存する計算を壊します
❌ 決して: GOOGLEFINANCEパラメータの変更
してはならないことの例:
❌ =GOOGLEFINANCE(A2, "price") → =GOOGLEFINANCE(A2, "closeyest")
❌ =GOOGLEFINANCE("TSLA", "price") → =GOOGLEFINANCE("NASDAQ:TSLA", "price")
理由: 価格検索が壊れたり、データソースが予期せず変更されたりする可能性があります
スマートな数式修復ワークフロー
ステップ1: エラータイプの特定
スプレッドシートをスキャンして以下を確認します:
-
N/A (利用不可 - 通常はGOOGLEFINANCEまたはVLOOKUPの失敗)
-
DIV/0! (ゼロ除算 - 通常は残高が$0の場合のマージン計算)
-
REF! (参照エラー - 削除された行/列)
-
VALUE! (間違ったデータ型 - 財務シートではまれ)
ステップ2: 修復戦略の分類
#N/Aエラーの場合:
GOOGLEFINANCEの失敗 (列C):
原因: 株式の上場廃止、ティッカーが無効、またはGoogle Finance APIの問題
解決策: IFERROR()で囲む
=IFERROR(GOOGLEFINANCE(A2, "price"), "DELISTED")
VLOOKUPの失敗 (使用されている場合):
原因: 参照値がソースデータに存在しない
解決策: ソースデータが存在することを確認し、範囲を拡張するか、IFERROR()を追加する
=IFERROR(VLOOKUP(A2, Data!A:B, 2, FALSE), "NOT FOUND")
#DIV/0!エラーの場合:
マージンカバー
(原文がここで途切れています)
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Formula Protection
Purpose
GUARDRAIL SKILL - Prevents accidental modification or deletion of critical formulas that maintain spreadsheet integrity. Ensures financial data accuracy by protecting auto-calculated columns.
When to Use (Auto-Blocks)
This skill automatically blocks when detecting:
- Attempts to "update formula", "modify formula", "change formula"
- Editing Column C (GOOGLEFINANCE price formulas)
- Modifying Columns D-F, H-S (calculated formulas)
- Fixing formula errors (#N/A, #DIV/0!, #REF!) without proper protocol
- User mentions: "fix formula", "edit cell", "update column C/D/E"
This is a BLOCKING skill - You MUST use this skill before proceeding with any formula-related edits.
Sacred Formulas (NEVER TOUCH)
DataHub Tab
Column C: Last Price
=GOOGLEFINANCE(A2, "price")
- Auto-updates stock prices in real-time
- ❌ NEVER modify - prices must come from Google Finance
- ❌ NEVER replace with static values
- ✅ ONLY wrap with IFERROR if showing #N/A for delisted stocks
Columns D-E: $ Change, % Change
=C2 - G2 ($ Change)
=D2 / G2 (% Change)
- Calculated from Last Price (C) and Avg Cost Basis (G)
- ❌ NEVER touch - let formulas calculate automatically
Columns H-M: Gains/Losses
=L2 - M2 (Total G/L $)
=K2 / M2 (Total G/L %)
=B2 * C2 (Current Value)
=B2 * G2 (Cost Basis Total)
- Core portfolio performance metrics
- ❌ NEVER modify - accuracy depends on these formulas
- ✅ ONLY add IFERROR if #DIV/0! errors appear
Columns N-S: Advanced Metrics
- Contains ranges, dividend data, layer classifications
- Mix of formulas and manual classifications
- ⚠️ Consult spreadsheet-architecture.md before editing
Dividend Tracker Tab
Column F: Total Dividend $
=D2 * E2 (Shares × Dividend Per Share)
- Calculates expected dividend income per fund
- ❌ NEVER modify - must remain formula-driven
Total Row Formula
=SUM(F2:F50) (TOTAL EXPECTED DIVIDENDS)
- Sums all dividend income
- ❌ NEVER delete or modify
- ✅ ONLY expand range if data grows beyond row 50
Margin Dashboard Tab
Coverage Ratio
=IFERROR(B10 / B11, 0) (Dividends ÷ Interest Cost)
- Critical safety metric for margin strategy
- ❌ NEVER remove IFERROR wrapper
- ✅ ONLY update if adding new safety thresholds
Allowed Operations
✅ SAFE: Add IFERROR() Wrappers
Purpose: Prevent error display without changing logic
Example:
Before: =GOOGLEFINANCE(A2, "price")
After: =IFERROR(GOOGLEFINANCE(A2, "price"), "N/A")
Before: =B10 / B11
After: =IFERROR(B10 / B11, 0)
When to use:
-
N/A errors from delisted stocks (GOOGLEFINANCE failures)
-
DIV/0! errors when margin balance = $0
-
REF! errors from deleted rows (use IFERROR as temporary fix)
✅ SAFE: Fix Broken Sheet References
Purpose: Correct renamed or moved sheet names
Example:
Before: =Sheet1!A1
After: ='DataHub'!A1
Before: ='Dividend Tracker OLD'!B10
After: ='Dividend Tracker'!B10
When to use:
- Sheet was renamed (Sheet1 → DataHub)
- Sheet was duplicated and old reference remains
- Tab moved to different position
✅ SAFE: Expand Formula Ranges
Purpose: Include new data rows without changing logic
Example:
Before: =SUM(F2:F50)
After: =SUM(F2:F100)
Before: =AVERAGE(B2:B30)
After: =AVERAGE(B2:B50)
When to use:
- New portfolio positions added beyond row 50
- Dividend tracker grows beyond expected size
- Margin dashboard accumulates monthly entries
✅ SAFE: Fix Cell Reference Typos
Purpose: Correct obvious mistakes in formula construction
Example:
Before: =B100 * C100 (B100 doesn't exist)
After: =B10 * C10
Before: =A2 + A2 (duplicate cell reference)
After: =A2 + B2 (correct cells)
When to use:
- Formula references non-existent row
- Clear typo in cell reference
- Formula clearly broken due to manual error
Forbidden Operations
❌ NEVER: Change Formula Logic
Example of what NOT to do:
❌ =SUM(F2:F50) → =AVERAGE(F2:F50) (changes meaning)
❌ =B2 * C2 → =B2 + C2 (changes calculation)
❌ =GOOGLEFINANCE(A2, "price") → =GOOGLEFINANCE(A2, "volume")
Why: Changes the meaning of calculated data, breaks dashboard integrity
❌ NEVER: Replace Formulas with Static Values
Example of what NOT to do:
❌ =GOOGLEFINANCE("TSLA", "price") → 445.47 (hardcoded)
❌ =B2 * C2 → 32964.78 (static value)
❌ =SUM(F2:F50) → 2847.32 (loses dynamic calculation)
Why: Data becomes stale, no longer updates automatically
❌ NEVER: Delete Formulas
Example of what NOT to do:
❌ Deleting Column C (Last Price formulas) to "clean up"
❌ Removing total row formulas to "simplify"
❌ Clearing formula cells to "start fresh"
Why: Destroys data pipeline, breaks all dependent calculations
❌ NEVER: Modify GOOGLEFINANCE Parameters
Example of what NOT to do:
❌ =GOOGLEFINANCE(A2, "price") → =GOOGLEFINANCE(A2, "closeyest")
❌ =GOOGLEFINANCE("TSLA", "price") → =GOOGLEFINANCE("NASDAQ:TSLA", "price")
Why: May break price lookups, change data source unexpectedly
Smart Formula Repair Workflow
Step 1: Identify Error Type
Scan spreadsheet for:
-
N/A (not available - usually GOOGLEFINANCE or VLOOKUP failures)
-
DIV/0! (division by zero - usually margin calculations when balance = $0)
-
REF! (reference error - deleted rows/columns)
-
VALUE! (wrong data type - rare in financial sheets)
Step 2: Classify Repair Strategy
For #N/A Errors:
GOOGLEFINANCE failures (Column C):
Cause: Stock delisted, ticker invalid, or Google Finance API issue
Solution: Wrap with IFERROR()
=IFERROR(GOOGLEFINANCE(A2, "price"), "DELISTED")
VLOOKUP failures (if used):
Cause: Lookup value doesn't exist in source data
Solution: Check source data exists, expand range, or add IFERROR()
=IFERROR(VLOOKUP(A2, Data!A:B, 2, FALSE), "NOT FOUND")
For #DIV/0! Errors:
Margin coverage ratio (when margin = $0):
Before: =B10 / B11
After: =IFERROR(B10 / B11, 0)
Percentage calculations (when denominator = 0):
Before: =K2 / M2
After: =IFERROR(K2 / M2, 0)
For #REF! Errors:
Deleted rows/columns:
Cause: Formula references Sheet1!A10 but row 10 was deleted
Solution: If temporary, wrap with IFERROR(). If permanent, reconstruct formula.
Temporary: =IFERROR(Sheet1!A10, 0)
Permanent: Identify correct new reference and update
Step 3: Test Repair on Single Cell
Before applying broadly:
- Copy original formula to notes (for rollback)
- Apply repair to ONE cell
- Verify result looks correct
- Check no new errors introduced
- If successful, apply to other similar errors
Step 4: Validate No New Errors
After repair:
- Scan entire sheet for new #N/A, #DIV/0!, #REF!
- Verify totals still sum correctly
- Check formulas still reference correct cells
- Confirm no unexpected data changes
Step 5: Document Repair
Log all changes:
✅ Fixed #DIV/0! in Margin Dashboard C10 by adding IFERROR()
Formula change: =B10/B11 → =IFERROR(B10/B11, 0)
Reason: Margin balance was $0 causing division by zero
Date: 2025-11-11
Pre-Flight Checklist (Before Editing Formulas)
Ask yourself:
- [ ] Am I trying to modify a formula-based column? (C, D-F, H-S)
- [ ] Is this a GOOGLEFINANCE formula? (STOP - don't touch)
- [ ] Is this a total/summary formula? (STOP - don't touch)
- [ ] Am I changing formula logic? (STOP - forbidden)
- [ ] Am I replacing formula with static value? (STOP - forbidden)
- [ ] Am I adding IFERROR to existing formula? (✅ Allowed)
- [ ] Am I fixing a broken sheet reference? (✅ Allowed)
- [ ] Am I expanding a range for new data? (✅ Allowed)
- [ ] Have I consulted
spreadsheet-architecture.md? (Required)
If ANY stop condition triggered: Use this skill, review rules, proceed with caution
Emergency Rollback Procedure
If formula modification breaks the spreadsheet:
- STOP immediately - Do not attempt additional fixes
- Alert user - Clearly explain what went wrong
- Document the error:
- Which cell/column was modified
- What formula change was made
- What error occurred (new #N/A, wrong calculations, etc.)
- Restore from Google Sheets version history:
- File → Version History → See Version History
- Find last working version (before modification)
- Click "Restore this version"
- Learn from it - Update this skill if new edge case discovered
Example Scenarios
❌ WRONG: Modifying Last Price Formula
User request: "The price for TSLA isn't updating, let me fix the formula"
Agent response:
🛑 BLOCKED by formula-protection skill
You're attempting to modify Column C (Last Price) which contains GOOGLEFINANCE formulas.
These are sacred formulas and must NEVER be modified.
If TSLA price isn't updating, the issue is likely:
1. Google Finance API delay (wait 5-10 minutes)
2. Market is closed (prices only update during trading hours)
3. Ticker symbol incorrect (verify "TSLA" is correct)
❌ Do NOT modify =GOOGLEFINANCE(A2, "price")
✅ If truly broken, wrap with: =IFERROR(GOOGLEFINANCE(A2, "price"), "N/A")
✅ RIGHT: Adding IFERROR Wrapper
User request: "Column C shows #N/A for delisted stock, can you fix?"
Agent response:
✅ Using formula-protection skill
I'll safely wrap the GOOGLEFINANCE formula with IFERROR() to handle the delisted stock.
Before: =GOOGLEFINANCE(A45, "price")
After: =IFERROR(GOOGLEFINANCE(A45, "price"), "DELISTED")
This preserves the formula logic while displaying "DELISTED" instead of #N/A.
The formula will still work if the stock relists in the future.
✅ Safe operation - formula logic unchanged
✅ RIGHT: Expanding Summary Range
User request: "Total dividends formula only goes to row 50, but I have 55 funds now"
Agent response:
✅ Using formula-protection skill
I'll safely expand the SUM range to include all 55 funds.
Before: =SUM(F2:F50)
After: =SUM(F2:F100)
This expands the range to accommodate current data (55 funds) plus room for growth.
Formula logic unchanged - still summing Total Dividend $ column.
✅ Safe operation - range expanded, logic preserved
Google Sheets Integration
Spreadsheet ID: Read from fin-guru/data/user-profile.yaml → google_sheets.portfolio_tracker.spreadsheet_id
Use the mcpgdrivesheets tool:
Read-only operations (to detect formula errors):
// STEP 1: Read Spreadsheet ID from user profile
// Load fin-guru/data/user-profile.yaml
// Extract: google_sheets.portfolio_tracker.spreadsheet_id
// STEP 2: Scan for errors
mcp__gdrive__sheets(
operation: "spreadsheets.values.get",
params: {
spreadsheetId: SPREADSHEET_ID, // from user-profile.yaml
range: "DataHub!A1:Z100"
}
)
// Check for #N/A, #DIV/0!, #REF! in returned values
Write operations (only for safe repairs):
// Add IFERROR wrapper to fix formula errors
mcp__gdrive__sheets(
operation: "spreadsheets.values.update",
params: {
spreadsheetId: SPREADSHEET_ID, // from user-profile.yaml
range: "DataHub!C2:C2",
valueInputOption: "USER_ENTERED",
requestBody: {
values: [["=IFERROR(GOOGLEFINANCE(A2, \"price\"), \"N/A\")"]]
}
}
)
Agent Permissions
Builder (Write-enabled with formula-protection):
- Can add IFERROR wrappers
- Can fix broken sheet references
- Can expand formula ranges
- Can fix cell reference typos
- MUST follow this skill's rules
All Other Agents (Strictly Read-only):
- Market Researcher, Quant Analyst, Strategy Advisor, Margin Specialist, Dividend Specialist
- Can read all data including formulas
- CANNOT modify any formulas
- Must defer to Builder for any formula repairs
- Should alert Builder if formula errors detected
Reference Files
For complete details, see:
- Spreadsheet Architecture:
fin-guru/data/spreadsheet-architecture.md(lines 380-440) - Quick Reference:
fin-guru/data/spreadsheet-quick-ref.md - Agent Permissions:
fin-guru/data/spreadsheet-architecture.md(lines 91-136)
Key Takeaways
Remember:
- 🛑 Formulas are sacred - Default assumption is DON'T TOUCH
- ✅ IFERROR is your friend - Safe way to handle errors
- 📖 Consult docs first - Read spreadsheet-architecture.md before any edit
- 🤝 Ask user if unsure - Better to ask than break financial data
- 🔄 Google Sheets has version history - Mistakes can be rolled back
When in doubt: READ-ONLY and ASK USER for guidance.
Skill Type: Guardrail (safety mechanism) Enforcement: BLOCK (prevents formula modifications) Priority: Critical Line Count: < 500 (following 500-line rule) ✅