Agent skill

Forward Risk

by JoelLewis in JoelLewis/finance_skills

Estimate potential future losses using VaR, Expected Shortfall, Monte Carlo simulation, and stress testing.

MITAuto-check passedTesting & QA

Install Forward Risk

skills CLI
$ npx skills add JoelLewis/finance_skills --skill forward-risk -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install JoelLewis/finance_skills forward-risk --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/JoelLewis/finance_skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/plugins/wealth-management/skills/forward-risk .claude/skills/forward-risk && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
forward-risk
GitHub stars
205
Token cost
~2.6k tokens
SKILL.md length
1,124 words
Files
2 (incl. scripts)
Skills in repo
91
Repo updated
First seen
Licence
MIT

At a glance

Estimate potential future losses using VaR, Expected Shortfall, Monte Carlo simulation, and stress testing.

  • Works in 4 steps: Estimate the return distribution… → Generate N random return scenarios… → Compute portfolio return for each… → …
  • The user asks about Value-at-Risk
  • SKILL.md covers Core Concepts, Key Formulas, Worked Examples and Common Pitfalls, plus 2 more sections
  • Runs Python scripts from its folder; calls uv, python3 and python

What it does

Forward Risk is an agent skill from JoelLewis/finance_skills. Estimate potential future losses using VaR, Expected Shortfall, Monte Carlo simulation, and stress testing. Use when the user asks about Value-at-Risk, CVaR, Expected Shortfall, scenario analysis, stress testing, or factor-based risk decomposition. Also trigger when users mention 'how much could I lose', 'worst-case scenario', 'tail risk', 'risk budget', 'component VaR', 'marginal VaR', '99% confidence loss', 'Monte Carlo simulation', or ask how to project portfolio risk forward.

Its SKILL.md is about 2.6k tokens, which your agent loads only when the skill is triggered. The skill folder holds 2 other files, including scripts (for example `scripts/forward_risk.py`).

It sits in Testing & QA, covering Load testing. The repository describes itself as: Claude Code skill plugins for financial services — 81 skills across 7 domain plugins covering investment management, compliance, advisory practice, trading, and operations. The licence is MIT.

When your agent uses it

  • The user asks about Value-at-Risk
  • Expected Shortfall
  • Scenario analysis
  • Factor-based risk decomposition

Example prompts

  • “how much could I lose”
  • “worst-case scenario”
  • “tail risk”
  • “/forward-risk”

Requirements

  • Python 3

Workflow steps

4 steps, taken from the first numbered list in SKILL.md.

  1. Estimate the return distribution parameters (mean vector, covariance matrix, or use a copula model).
  2. Generate N random return scenarios (e.g., via Cholesky decomposition of the covariance matrix for multivariate normal).
  3. Compute portfolio return for each scenario.
  4. Sort results and identify the alpha-percentile loss.

What it can do on your machine

Read from SKILL.md and the folder at commit 5c498ea. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 1 file in scripts/ (Python), which the agent can run.

    Shell commands in SKILL.md call:

    • uv
    • python3
    • python

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use uv, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Forward Risk loads about 2.6k tokens when it runs. Until then it costs about 124 tokens; SKILL.md has 1,124 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~124
When it runs · the whole SKILL.md, loaded when a task matches
~2.6k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from JoelLewis/finance_skills at commit 5c498ea, republished under its MIT licence (© JoelLewis). 1,124 words, ~2,598 tokens.

Download SKILL.mdSave it as .claude/skills/forward-risk/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
forward-risk
description
Estimate potential future losses using VaR, Expected Shortfall, Monte Carlo simulation, and stress testing. Use when the user asks about Value-at-Risk, CVaR, Expected Shortfall, scenario analysis, stress testing, or factor-based risk decomposition. Also trigger when users mention 'how much could I lose', 'worst-case scenario', 'tail risk', 'risk budget', 'component VaR', 'marginal VaR', '99% confidence loss', 'Monte Carlo simulation', or ask how to project portfolio risk forward.

Forward-Looking Risk Analysis

Core Concepts

Parametric (Variance-Covariance) VaR

Assumes returns are normally distributed. For a single asset or portfolio in dollar terms (assuming zero expected return over short horizons):

VaR = W * z_alpha * sigma_p

where:

  • W = portfolio value
  • z_alpha = z-score for confidence level (1.645 for 95%, 2.326 for 99%)
  • sigma_p = portfolio volatility over the relevant horizon

More generally, including expected return:

VaR_alpha = mu - z_alpha * sigma

To convert from 1-day VaR to h-day VaR (assuming i.i.d. returns):

VaR_h = VaR_1 * sqrt(h)
Portfolio VaR (Multiple Assets)

For a portfolio with weight vector w and covariance matrix Sigma:

sigma_p = sqrt(w' * Sigma * w)
VaR_p   = W * z_alpha * sqrt(w' * Sigma * w)

The covariance matrix captures both individual volatilities and correlations between assets.

Monte Carlo VaR

Simulate a large number of portfolio return scenarios (e.g., 10,000+), then take the alpha-percentile of the simulated loss distribution.

Steps:

  1. Estimate the return distribution parameters (mean vector, covariance matrix, or use a copula model).
  2. Generate N random return scenarios (e.g., via Cholesky decomposition of the covariance matrix for multivariate normal).
  3. Compute portfolio return for each scenario.
  4. Sort results and identify the alpha-percentile loss.

Monte Carlo VaR can accommodate non-normal distributions, fat tails, path-dependent instruments, and nonlinear payoffs (e.g., options).

Conditional VaR (CVaR) / Expected Shortfall

CVaR answers: "Given that losses exceed VaR, what is the expected loss?"

ES_alpha = E[Loss | Loss > VaR_alpha]

For a normal distribution:

ES_alpha = mu + sigma * phi(z_alpha) / (1 - alpha)

where phi is the standard normal PDF.

CVaR is a coherent risk measure (unlike VaR) because it satisfies subadditivity: CVaR(A+B) <= CVaR(A) + CVaR(B). This means diversification always reduces or maintains CVaR, which is not guaranteed for VaR.

Component VaR

Decomposes total portfolio VaR into contributions from each position. Component VaRs sum to total VaR.

CVaR_i = w_i * beta_i * VaR_p

where beta_i = Cov(R_i, R_p) / Var(R_p) is the asset's beta to the portfolio.

Equivalently:

CVaR_i = w_i * (partial VaR / partial w_i)
sum(CVaR_i) = VaR_p

This decomposition identifies which positions are the largest contributors to portfolio risk.

Marginal VaR

Measures the rate of change of portfolio VaR with respect to a small increase in a position's weight.

MVaR_i = partial(VaR_p) / partial(w_i) = z_alpha * (Sigma * w)_i / sigma_p

Marginal VaR is used for position sizing: adding to a position with low marginal VaR reduces portfolio risk more efficiently.

Scenario Analysis

Apply specific historical or hypothetical market moves to the current portfolio to estimate P&L impact.

  • Historical scenarios: Replay actual market events (e.g., 2008 GFC, 2020 COVID crash, 2022 rate hiking cycle) with current holdings.
  • Hypothetical scenarios: Construct custom shocks (e.g., "equities -20%, rates +200bp, credit spreads +300bp, USD +10%").

Scenario P&L is computed by applying the scenario returns to current position exposures and revaluing.

Stress Testing

A structured framework for assessing portfolio resilience under extreme but plausible conditions.

Common stress scenarios:

  • Equity crash: S&P 500 -30% to -40%
  • Interest rate shock: +300bp parallel shift
  • Credit crisis: investment-grade spreads +200bp, high-yield +800bp
  • Liquidity freeze: bid-ask spreads widen 10x, forced selling at discount
  • Currency shock: major currency pair moves 15-20%
  • Stagflation: inflation +5%, GDP -3%, rates +200bp

Stress tests should include second-order effects: margin calls, liquidity demands, correlation spikes, counterparty risk.

Factor-Based Risk Decomposition

Separate total portfolio risk into systematic factor risk and idiosyncratic (security-specific) risk.

sigma^2_p = b' * Sigma_f * b + sum(w_i^2 * sigma^2_epsilon_i)

where:

  • b = vector of portfolio factor exposures
  • Sigma_f = factor covariance matrix
  • sigma^2_epsilon_i = idiosyncratic variance of asset i

Common factor models: Fama-French (market, size, value, momentum), Barra risk models, PCA-based statistical factors.

Key Formulas

FormulaExpressionUse Case
Parametric VaR (single)W * z_alpha * sigmaSimple position VaR
Portfolio VaRW * z_alpha * sqrt(w' * Sigma * w)Multi-asset VaR
Multi-day VaRVaR_1 * sqrt(h)Scale to h-day horizon
CVaR (normal)mu + sigma * phi(z_alpha) / (1 - alpha)Expected tail loss
Component VaRw_i * beta_i * VaR_pRisk contribution per position
Marginal VaRz_alpha * (Sigma * w)_i / sigma_pSensitivity to weight change
Factor Riskb' * Sigma_f * bSystematic risk component
Idiosyncratic Risksum(w_i^2 * sigma^2_epsilon_i)Security-specific risk

Worked Examples

Example 1: Parametric 95% VaR

Given: A $1,000,000 equity portfolio with an annualized volatility of 15%.

Calculate: 1-day 95% parametric VaR (assuming 252 trading days and zero expected daily return).

Solution:

Daily volatility:

sigma_daily = 0.15 / sqrt(252) = 0.15 / 15.875 = 0.00945

1-day 95% VaR:

VaR = $1,000,000 * 1.645 * 0.00945 = $15,545

Alternatively, computing directly from annual figures:

VaR_annual = $1,000,000 * 1.645 * 0.15 = $246,750
VaR_1day   = $246,750 / sqrt(252)       = $15,545

Interpretation: There is a 5% chance of losing more than $15,545 in a single day under normal market conditions.

Show full SKILL.md (481 more words)Show less
Example 2: Monte Carlo VaR

Given: A two-asset portfolio (60% equities, 40% bonds). Equities: mu = 10%, sigma = 18%. Bonds: mu = 4%, sigma = 5%. Correlation rho = -0.2. Portfolio value = $1,000,000.

Calculate: 95% annual VaR via Monte Carlo simulation (conceptual steps).

Solution:

  1. Construct covariance matrix:
Sigma = | 0.0324  -0.0018 |
        | -0.0018  0.0025 |
  1. Cholesky decomposition of Sigma to get lower triangular matrix L.

  2. Simulate 10,000 scenarios: For each simulation, draw z ~ N(0, I), compute r = mu + L*z, then portfolio return R_p = w' * r.

  3. Compute portfolio P&L for each scenario: P&L = $1,000,000 * R_p.

  4. Sort P&L from worst to best. The 500th worst (5th percentile) is the 95% VaR.

For this portfolio, the analytical answer provides a benchmark:

sigma_p = sqrt(0.6^2 * 0.0324 + 0.4^2 * 0.0025 + 2 * 0.6 * 0.4 * (-0.0018))
        = sqrt(0.011664 + 0.0004 - 0.000864)
        = sqrt(0.0112)
        = 10.58%

VaR_95% = $1,000,000 * 1.645 * 0.1058 = $174,090

The Monte Carlo result should converge to approximately this value for a multivariate normal assumption.

Example 3: Expected Shortfall

Given: From the Monte Carlo simulation above, the losses exceeding VaR (the worst 500 out of 10,000 scenarios) have an average loss of $225,000.

Calculate: 95% CVaR.

Solution:

CVaR_95% = $225,000

Interpretation: When losses exceed the 95% VaR threshold, the average loss is $225,000. This is roughly 29% worse than the $174,090 VaR figure, highlighting the severity of tail events.

Common Pitfalls

  • VaR says nothing about tail shape: VaR only identifies a threshold. Two portfolios with identical VaR can have vastly different tail losses. Always compute CVaR alongside VaR to understand tail severity.
  • Parametric VaR assumes normality: Financial returns exhibit fat tails and skewness. Parametric VaR systematically underestimates tail risk. Use Monte Carlo with fat-tailed distributions or historical simulation for more realistic estimates.
  • Correlation breakdown in crises: Correlations spike toward 1.0 during market stress, precisely when diversification is most needed. Stress tests should use crisis-period correlations, not calm-period correlations.
  • Using too short a lookback for covariance estimation: Too short a window is noisy; too long a window includes stale data from different market regimes. A common compromise is 1-3 years of daily data, or use EWMA-weighted covariances.
  • Not distinguishing between absolute VaR and relative VaR: Absolute VaR includes expected return (VaR = -mu + zsigma); relative VaR excludes it (VaR = zsigma). For short horizons (1-10 days), the expected return is negligible and the distinction is minor. For longer horizons, it matters.
  • Square-root-of-time scaling limitations: VaR_h = VaR_1 * sqrt(h) assumes i.i.d. returns. With serial correlation or volatility clustering, this scaling is inaccurate.

Cross-References

  • historical-risk (wealth-management plugin): Historical VaR and realized volatility serve as non-parametric alternatives and calibration benchmarks for the forward-looking models in this skill.
  • performance-metrics (wealth-management plugin): VaR and CVaR can be used as risk denominators in modified risk-adjusted ratios (e.g., return/CVaR).
  • volatility-modeling (wealth-management plugin): EWMA and GARCH volatility forecasts provide the volatility inputs (sigma) for parametric and Monte Carlo VaR.

Running the Script

bash
uv run scripts/forward_risk.py            # run the demo (uses PEP 723 inline deps)
uv run scripts/forward_risk.py --verify   # check demo outputs against the worked examples (exit 1 on mismatch)
python3 scripts/forward_risk.py            # alternative (requires: pip install numpy scipy)

The demo prints the calculations covered above; its values match the worked examples in this skill. Run --help for a list of the classes and functions. For programmatic use, import the module rather than running it — the demo only executes under python forward_risk.py.

© JoelLewis, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file (scripts) in plugins/wealth-management/skills/forward-risk of JoelLewis/finance_skills.

  • SKILL.md
  • scripts/forward_risk.py

Open the folder on GitHubat commit 5c498ea

Compare with similar skills

Forward Risk next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Forward Risk compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Forward Risk this skillJoelLewis/finance_skills205—~2.6kAutomated safety check: PassMIT
Writing Livekit Scenarioslivekit-examples/agent-starter-python2641 repos~2.5kAutomated safety check: PassMIT
Go Testingcxuu/golang-skills1721 repos~1.3kAutomated safety check: PassApache-2.0
Goalcraftgrp06/goalcraft102—~3.8kAutomated safety check: PassMIT
Thinking Partnermattnowdev/thinking-partner206—~4.4kAutomated safety check: PassMIT
Visionkunchenguid/vision331—~2.9kAutomated safety check: PassMIT

Similar skills

  • Writing Livekit Scenarios

    livekit-examples/agent-starter-python

    Creates and maintains the scenarios a LiveKit agent simulation runs, and wires the agent to consume them.

    264 GitHub starsUsed in 1 repo~2.5k tokens
    Testing & QAAuto-check passed
  • Go Testing

    cxuu/golang-skills

    A skill your agent uses when writing, reviewing, or improving Go test code — including table-driven tests, subtests, parallel tests, test helpers, test doubles, and assertions with cmp.Diff.

    172 GitHub starsUsed in 1 repo~1.3k tokens
    Testing & QAAuto-check passed
  • Goalcraft

    grp06/goalcraft

    Turn a rough draft, vague ambition, or messy task brief into a powerful Codex /goal objective for persistent, evidence-checked work.

    102 GitHub stars~3.8k tokensUpdated 4 mo ago
    Testing & QAAuto-check passed
  • Thinking Partner

    mattnowdev/thinking-partner

    A deterministic thinking partner that challenges assumptions and applies mental models to sharpen decisions, solve problems, and think more clearly.

    206 GitHub stars~4.4k tokensUpdated 6 mo ago
    Testing & QAAuto-check passed
  • Vision

    kunchenguid/vision

    Draft and stress-test a VISION.md for a repository, then iterate with the author on an interactive review board until approved.

    331 GitHub stars~2.9k tokensUpdated 1 mo ago
    Testing & QAAuto-check passed
  • Volt Load Testing

    owenHochwald/volt

    Safely exercise and evaluate HTTP APIs with the Volt CLI, including authenticated requests, JSON bodies, staged load, machine-readable results, performance baselines, and before/after comparisons.

    141 GitHub stars~1.2k tokensUpdated 2 mo ago
    Testing & QAAuto-check passed

More from JoelLewis/finance_skills

All 91 skills in this repo
  • Asset Allocation

    JoelLewis/finance_skills

    Determine how to distribute capital across asset classes using strategic and tactical allocation frameworks.

    205 GitHub stars~2.5k tokensUpdated 2 mo ago
    Auto-check passed
  • Bet Sizing

    JoelLewis/finance_skills

    Determine how much capital to allocate to individual positions within a portfolio.

    205 GitHub stars~2.5k tokensUpdated 2 mo ago
    Auto-check passed
  • Commodities

    JoelLewis/finance_skills

    Analyze commodity markets including futures curve dynamics, roll yield, and supply/demand fundamentals.

    205 GitHub stars~1.9k tokensUpdated 2 mo ago
    Auto-check passed
  • Currencies And Fx

    JoelLewis/finance_skills

    Analyze currency markets, exchange rate mechanics, and FX risk management for international portfolios.

    205 GitHub stars~1.9k tokensUpdated 2 mo ago
    Auto-check passed
  • Debt Management

    JoelLewis/finance_skills

    Provide frameworks for managing and paying off personal debt effectively.

    205 GitHub stars~2.5k tokensUpdated 2 mo ago
    Auto-check passed
  • Diversification

    JoelLewis/finance_skills

    Build diversified portfolios using correlation analysis, efficient frontier construction, and factor-based diversification.

    205 GitHub stars~2.3k tokensUpdated 2 mo ago
    Auto-check passed

Categories

Questions about Forward Risk

What does Forward Risk do?

Estimate potential future losses using VaR, Expected Shortfall, Monte Carlo simulation, and stress testing. Forward Risk is an agent skill from JoelLewis/finance_skills. Estimate potential future losses using VaR, Expected Shortfall, Monte Carlo simulation, and stress testing.

When should I use Forward Risk?

Forward Risk fits situations like: the user asks about Value-at-Risk; expected Shortfall; scenario analysis; factor-based risk decomposition.

How do I install Forward Risk in Claude Code?

Run `npx skills add JoelLewis/finance_skills --skill forward-risk -a claude-code`. Or copy the skill folder (plugins/wealth-management/skills/forward-risk in JoelLewis/finance_skills) into .claude/skills/forward-risk in your project. Claude Code loads it when a task matches its description.

How do I install Forward Risk in Codex?

Run `npx skills add JoelLewis/finance_skills --skill forward-risk -a codex`. Or copy the skill folder (plugins/wealth-management/skills/forward-risk in JoelLewis/finance_skills) into .agents/skills/forward-risk in your project. Codex loads it when a task matches its description.

Can I use Forward Risk in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add JoelLewis/finance_skills --skill forward-risk -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/forward-risk, .gemini/skills/forward-risk, .github/skills/forward-risk and .opencode/skills/forward-risk in your project.

What does Forward Risk need to run?

Going by SKILL.md and its folder, Forward Risk needs Python for the scripts in its folder and the command-line tools its instructions call (uv, python3 and python). Our summary lists: Python 3.

Does Forward Risk access the network?

SKILL.md contains no URLs. Its commands use uv, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Forward Risk safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Forward Risk use?

Forward Risk is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Forward Risk use?

About 2.6k tokens (SKILL.md is roughly 10k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Forward Risk?

Skills that share tags, products or a category with Forward Risk: Writing Livekit Scenarios (livekit-examples/agent-starter-python, 264 stars), Go Testing (cxuu/golang-skills, 172 stars), Goalcraft (grp06/goalcraft, 102 stars) and Thinking Partner (mattnowdev/thinking-partner, 206 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Forward Risk?

JoelLewis (a GitHub user) maintains it in JoelLewis/finance_skills, which has 205 GitHub stars. The repository holds 91 skills in this directory. The repository was last updated on July 18, 2026.

Source: JoelLewis/finance_skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.