--- name: sparebank1-context description: Build and maintain a personal finance context for the `sb1` CLI (SpareBank 1) by running a short onboarding interview over the user's own accounts and transactions, then saving the answers to a private, git-ignored file the agent reads at the start of future finance sessions. Captures the meaning the bank can't know — which inbound money is salary vs reimbursement, what each account is for, what's work-expensed, split with a partner, or a subscription to cancel. Use when the user wants to personalize sb1, set up or refresh their finance context, teach the agent about their money, or annotate uncategorized/ambiguous transactions. compatibility: Requires the `sb1` binary, installed and authenticated (see sparebank1-shared). Writes a profile-specific markdown file to a user-owned path outside this repo. --- # sparebank1-context Turn `sb1` from "shows transactions" into "reasons over *your* money". This skill runs a brief interview over the user's real data, then stores the answers as a **personal finance context** that future finance sessions load up front. Read [sparebank1-shared](../sparebank1-shared/SKILL.md) first for auth and flags. The CLI already surfaces the *data*. This skill captures the *personal meaning layer* the bank cannot infer, and nothing more. ## The privacy contract (read this first) This skill's *mechanism* is public (it ships in a public repo and installs for anyone), but the *answers are private personal data*. Therefore: - **Write the context file to a user-owned path outside this repo.** New profile contexts live at `~/.config/sparebank1-cli/contexts//context.md`, where `` is the UTF-8 bytes of the profile name encoded as lowercase hexadecimal. Override with `SB1_CONTEXT_FILE` for an explicitly selected context file. - `sb1 status --json` reports `legacyContext: true` for the profile that adopted a previous single-profile login. For that profile, keep using the existing `~/.config/sparebank1-cli/context.md` in place. Do not move, overwrite, or associate it with a different profile when the default changes. - **Never** write answers, balances, account numbers, or counterparties into this repository, a commit, a PR, or any shared/cloud-synced location. Treat the file like the plaintext `file` secret store: keep it off backups and out of anything that syncs. - Prefer account **names + last 4 digits** over full account numbers. Don't record figures the user didn't ask you to keep. - The file is for *this user's* agent sessions. Don't paste its contents into chats, issues, or external services. Resolve the path once at the start: ```bash profile="" legacy_context="" if [ "$legacy_context" = true ]; then default_ctx="$HOME/.config/sparebank1-cli/context.md" else profile_hex="$(printf '%s' "$profile" | od -An -v -tx1 | tr -d ' \n')" default_ctx="$HOME/.config/sparebank1-cli/contexts/$profile_hex/context.md" fi ctx="${SB1_CONTEXT_FILE:-$default_ctx}" mkdir -p "$(dirname "$ctx")" ``` Choose the profile from the user's request or the default marked by `sb1 status`. Use that same `--profile ` for all banking commands in this session. Never apply one profile's context to another profile's balances or transactions. For a combined analysis using repeated `--profile` or `--all-profiles`, use a separate aggregate context at `~/.config/sparebank1-cli/contexts/aggregate/context.md`. Create or update it only with the user's input. Keep each person's profile context separate and do not copy its notes into the aggregate context automatically. Attribute any combined-context note to the relevant profile or shared account. Record the selected profiles in that context and use it only when they match the current selection. Household membership requires the user's own explanation. `SB1_CONTEXT_FILE` may explicitly select the context for a session. ## When to run - **First time:** no context file exists → run the full interview below. - **Refresh:** the file exists → read it, show the user what's captured, and only ask about what's new or changed (new counterparties, new Uncategorized rows, subscriptions to revisit). Don't re-ask settled questions. Confirm login before pulling data: ```bash sb1 status # if not logged in, ask the user to run `sb1 login` (see sparebank1-shared) ``` When the user names a profile, check `sb1 status --profile `. For the default, use the profile marked as default by `sb1 status`. ## Step 1 — gather the data (no code change needed) Drive the interview from existing commands. Start with a short window: ```bash sb1 --json summary --months 3 --profile "$profile" ``` From the JSON, the rows worth asking about are: - `categories[]` — especially the **`"Uncategorized"`** bucket (the bank couldn't classify these; you can, with the user's help). - `topOutgoing[]` — the biggest counterparties by spend. - `subscriptions[]` — what the bank already flagged as recurring. To see the actual Uncategorized rows behind that bucket, drill in per account: ```bash sb1 --json transactions -a --from --to --classified --profile "$profile" ``` Each row has `category`, `recurring`, `subscription`, `counterpartyName`, `amount` (negative = outgoing), and `date`. Filter to rows with a missing/`"Uncategorized"` category or to the top counterparties — those are your interview targets. ## Step 2 — the interview (keep it short) **Prioritize the `Uncategorized` bucket and the top counterparties.** Do not walk every transaction. Group similar rows and ask once per group. Aim for a handful of focused questions, not a questionnaire. Capture these dimensions: | Dimension | The question to resolve | |---|---| | **Income classification** | For each inbound counterparty: salary, reimbursement, transfer from a partner, or a refund? (So "income" isn't overcounted.) | | **Work-expensed / reimbursed** | Which outgoing rows does work pay back (travel, equipment)? These should net OUT of "real" spending. | | **Account semantics** | What is each account *for* — daily, buffer, a savings goal, BSU, joint? | | **Shared / split** | Anything split with a partner where only the user's share should count? | | **Counterparty aliases** | Cryptic strings (e.g. `KLARNA*…`, acquirer codes) → a human label. | | **Subscriptions** | For each flagged (or user-known) subscription: keep, cancel, or annual? | | **Fixed vs discretionary** | Which spend is fixed (rent, loan, insurance) vs discretionary? | Ask in plain language, tied to what you actually saw: "You sent ~kr 4 000/month to `BERG EIENDOM` — is that rent (fixed)?" beats an abstract checklist. Skip dimensions that don't apply to this user. ## Step 3 — write the context file Save the answers to the resolved path in the format below. On a refresh, merge into the existing file rather than overwriting blind, and bump the date. After writing, tell the user the exact path and restate that it stays out of git and backups. ```markdown # SpareBank 1 — personal finance context ## Accounts — what each is for - (····): ## Income — how to classify inbound money - : ## Work-expensed / reimbursed (net these OUT of real spending) - : ## Shared / split expenses (only my share counts) - : ## Counterparty aliases (cryptic string → human label) - :