Define policy

From ricardocabral/rikdom · View interactive version

Define policy is an AI agent skill from the GitHub repository ricardocabral/rikdom. Use when the user wants to create, fill, define, review, or update a Rikdom investment policy, IPS, objectives, target allocation, glide path, rebalancing rules, constraints, or guardrails.

How to use this skill

Skill file

Skill: Define Rikdom Investment Policy

Use this skill when the user wants to create, fill, define, review, or update data/policy.json, an Investment Policy Statement (IPS), objectives, target allocation, glide path, rebalancing rules, retirement assumptions, constraints, or guardrails.

Purpose

Interview the user and produce a valid data/policy.json for a Rikdom portfolio. The policy is prescriptive configuration consumed by humans or agents during portfolio health checks and rebalancing reviews.

This skill does not provide regulated financial advice, execute trades, propose specific buy/sell orders, run imports, or edit data/portfolio.json.

Scope

Required Context

Before asking detailed questions:

  1. Ask for the portfolio data path if unknown:

What is your rikdom portfolio data path? You can send: (1) the data directory, (2) a full path to portfolio.json, or (3) workspace root + portfolio name.

If the user does not provide one, default to data/ in the current workspace.

  1. Read src/rikdom/_resources/policy.schema.json as the authoritative schema.
  2. Read data-sample/policy.json as a realistic example and source of schema-shaped defaults.
  3. If <data-dir>/portfolio.json exists, read it for defaults only: portfolio id/name, base currency, countries if present, account/provider hints, and rough AUM for guardrail sizing.
  4. If <data-dir>/policy.json exists, treat this as an update: reuse existing values as defaults and only reconfirm stale, missing, or user-flagged sections.
  5. If <data-dir>/.policy-interview.md exists, resume from it.

Interview Rules

Interview Order

Cover every section, but allow use defaults for this section or skip optional fields.

  1. Identity
  1. Investor profile
  1. Accounts

Catalog every wrapper/account type: taxable brokerage, PGBL/VGBL, 401k/IRA, previdência fechada, offshore, crypto custody, cash, or other.

For each account collect:

  1. Objectives

Always ask about:

Then ask whether to include education, home purchase, legacy, sabbatical, healthcare, or other goals.

For each objective collect kind, priority, target date/age if known, target amount if known, and funding accounts.

  1. Retirement assumptions

Explain real vs nominal spending in one sentence, then collect:

  1. Strategic allocation
  1. Glide path
  1. Rebalancing policy
  1. Cashflow policy
  1. Constraints and exclusions
  1. Guardrails

This is the section future agents should cite most. Collect:

  1. Review policy

Writing And Validation

After every section:

  1. Update <data-dir>/policy.json using pretty JSON with stable indentation.
  2. Preserve existing values unless the user explicitly changes them.
  3. Set/update provenance when the schema supports it:
  1. Validate with the project validator:
uv run python - <<'PY'
import json
from pathlib import Path
from rikdom.policy import validate_policy
path = Path('data/policy.json')
errors = validate_policy(json.loads(path.read_text()))
if errors:
    print('\n'.join(errors))
    raise SystemExit(1)
print('policy.json valid')
PY

If the user's data directory is not data, substitute the correct path. If validation fails, fix schema-shape issues immediately and re-ask only for missing or ambiguous user intent.

Final Report

When finished, provide a short Markdown report with:

  1. Coverage matrix — populated, defaulted, skipped, or open for each major section.
  2. Consistency checks — allocation sums per dimension, min/max bands, glide path monotonicity, emergency fund vs liquidity months where possible, human confirmation threshold vs rough AUM where available.
  3. Drift snapshot — only if portfolio.json exists and current weights can be computed locally; flag outside-band buckets only. Do not propose trades.
  4. Open questions — deferred assumptions, missing values, unsupported schema needs.

Privacy And Safety

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.