AgentSkillsCN

monthly-migration

对 Terraform Azure 配置进行安全扫描与合规性检查。当您需要扫描安全漏洞、核查 CIS/Azure 安全基准的合规性、对 Terraform 代码进行漏洞审计、在 CI/CD 流水线中部署安全门禁、执行漏洞扫描、安全审计、合规性检查、CIS 基准测试、tfsec 或 checkov 时,此技能将助您高效完成任务。

SKILL.md
--- frontmatter
name: monthly-migration
description: Perform monthly journal migration using hledger close --migrate to close the previous month and open the new month with proper balance assertions and account initialization.

Monthly Migration Skill

Journal File Path Format

Reminder: All monthly journal files must be named and referenced as ledger/[year]/[year]-/[name].journal (e.g., ledger/2024/2024-01/self.journal). Do not omit the ledger/ prefix when referring to journal files.

🚩 Agent Workflow Reminder

Use the Todo List Tool for multi-step tasks (plan, mark a step in-progress, complete it, and update). See AGENTS.md for the concise agent workflow rules.

Guide for migrating journals at the start of each month.

When to Use

  • Start of each month (typically 1st-3rd) before adding new transactions
  • Previous month is complete and validated
  • Setting up opening/closing balances

Prerequisites

  • All transactions for previous month finalized
  • Both self.journal and self.alternatives.journal need migration
  • Ran python -m check successfully

Process

1. Run Migration Commands

Close both journal types:

powershell
# Example: Close December 2025, prepare for January 2026
hledger close -f ledger/2025/2025-12/self.journal --migrate
hledger close -f ledger/2025/2025-12/self.alternatives.journal --migrate

Run separately—one per journal file.

2. Understand Output

hledger close --migrate generates two transactions:

  1. Closing balances: Zeroes all accounts at month-end

    hledger
    2025-12-31 closing balances  ; time: 23:59:59
        assets:banks:<uuid>:HKD     -5000.00 HKD = 0.00 HKD
        ...
        equity:opening/closing balances
    
  2. Opening balances: Re-establishes for new month

    hledger
    2026-01-01 opening balances  ; time: 00:00:00
        assets:banks:<uuid>:HKD      5000.00 HKD = 5000.00 HKD
        ...
        equity:opening/closing balances
    

3. Add Closing to Old Month

Copy closing balances to end of previous month journal.

4. Create New Monthly Journal

If new month directory doesn't exist:

powershell
mkdir ledger/2026/2026-01
New-Item ledger/2026/2026-01/self.journal

Include prelude:

hledger
include ../../../preludes/self.journal

5. Add Opening to New Month

Copy opening balances to start of new month (after prelude).

6. Adjust Times if Needed

Verify dates/times are correct:

  • Closing: last day of month at 23:59:59
  • Opening: first day of month at 00:00:00

7. Validate

powershell
python -m check   # set cwd to scripts/
python -m format  # set cwd to scripts/

Scripts & working directory: See .github/instructions/developer-workflows.instructions.md for canonical guidance — prefer pnpm run <script>; if running Python directly, set cwd=scripts/.

8. Commit

powershell
git commit -S -m "chore(migration): migrate journals to 2026-01"

Do's and Don'ts

Do:

  • Run for both self.journal and self.alternatives.journal
  • Create new directory/file if needed
  • Include prelude in new journal
  • Verify closing balances show = 0.00 CURRENCY
  • Run check and format after

Don't:

  • Edit hledger close output extensively
  • Forget prelude include
  • Skip validation before commit
  • Perform migration multiple times for same month

Reference Recent Examples

powershell
cat ledger/2025/2025-12/self.journal | tail -50  # View closing
cat ledger/2026/2026-01/self.journal | head -50  # View opening

Related Documentation