mcpbeat Sign in

Algo Risk Benford Agent Skill

Apply Benford's Law to detect anomalies in numerical datasets by analyzing first-digit frequency distributions. Use this skill when the user needs to audit financial data for fraud indicators, validate data integrity, or detect fabricated numbers — even if they say 'data manipulation detection', 'first digit test', or 'accounting fraud screening'.

8k tokens
context cost
the whole folder, loaded on every use
4
files
instructions only
0
copies elsewhere
how many repositories repackaged it
223
stars on the repo
on the repository, not the skill itself

Install

one command, takes just this skill from the repository
npx skills add https://github.com/asgard-ai-platform/skills --skill algo-risk-benford

What comes with it

26 209 bytes besides the instruction
examples/sample_scenario.md
references/fraud-case-studies.md
references/higher-digit-tests.md

The instruction itself

14 sections, as written by the author

Benford's Law Analysis

Overview

Benford's Law predicts that in naturally occurring datasets, the leading digit d appears with probability P(d) = log₁₀(1 + 1/d). Digit 1 appears ~30.1% of the time, digit 9 only ~4.6%. Deviations from this distribution may indicate data fabrication or manipulation. Analysis runs in O(n).

When to Use

Trigger conditions:

  • Auditing financial data (expenses, invoices, tax returns) for manipulation
  • Screening large datasets for data integrity issues
  • Detecting fabricated or artificially rounded numbers

When NOT to use:

  • For assigned/sequential numbers (zip codes, phone numbers, IDs)
  • For datasets with constrained ranges (e.g., human ages, percentages)
  • For small datasets (< 500 records — insufficient statistical power)

Algorithm

IRON LAW: Benford's Law Applies to NATURALLY OCCURRING Data Spanning Orders of Magnitude
Data that doesn't span multiple orders of magnitude (e.g., temperatures
in Celsius, human heights) will NOT follow Benford's Law. Deviation from
Benford's in such data is EXPECTED, not suspicious. Always verify the
data type is appropriate before concluding fraud.

Phase 1: Input Validation

Extract leading digits from dataset. Filter: remove zeros, negatives (take absolute value), values < 10. Verify dataset spans multiple orders of magnitude.

Gate: 500+ records, data spans at least 2 orders of magnitude.

Phase 2: Core Algorithm

  • Extract first digit of each number
  • Count frequency of each digit (1-9)
  • Compare observed frequencies against Benford's expected: P(d) = log₁₀(1 + 1/d)
  • Statistical tests: chi-squared test, MAD (Mean Absolute Deviation), KS test

Phase 3: Verification

MAD thresholds: < 0.006 (close conformity), 0.006-0.012 (acceptable), 0.012-0.015 (marginal), > 0.015 (non-conforming). Flag specific digits with large deviations.

Gate: MAD computed, non-conforming digits identified.

Phase 4: Output

Return conformity assessment with digit-level analysis.

Output Format

{
  "conformity": "marginal",
  "mad": 0.013,
  "chi_squared": {"statistic": 18.5, "p_value": 0.018, "df": 8},
  "digit_analysis": [{"digit": 1, "observed_pct": 25.1, "expected_pct": 30.1, "deviation": -5.0}],
  "metadata": {"records": 5000, "dataset": "Q4 expense reports"}
}

Examples

Sample I/O

Input: 1000 invoice amounts from a company's AP ledger

Expected: First digits should approximate 30.1%, 17.6%, 12.5%, 9.7%, 7.9%, 6.7%, 5.8%, 5.1%, 4.6%. MAD < 0.012 for legitimate data.

Edge Cases

| Input | Expected | Why |

|-------|----------|-----|

| All amounts $90-$99 | Digit 9 dominates | Constrained range — Benford's doesn't apply |

| Round number spike (digit 1, 5) | Flag for review | May indicate round-number estimation or threshold manipulation |

| Government budget data | Typically conforms well | Large naturally-occurring financial datasets fit Benford's |

Gotchas

  • Not proof of fraud: Non-conformity is a RED FLAG, not evidence. Many legitimate processes produce non-Benford distributions. Always investigate further.
  • Second-digit test: First digit test catches gross fabrication. Second-digit analysis catches more subtle manipulation (e.g., rounding to approval thresholds).
  • Combining datasets: Mixing datasets from different processes may artificially create or destroy Benford conformity. Analyze homogeneous datasets.
  • Approval thresholds: If expenses over $5,000 require VP approval, expect a spike of amounts just below $5,000 (digit 4 in the $4,9xx range). This is a behavioral pattern, flagged by second-digit analysis.
  • Sample size matters: Chi-squared test is sensitive to sample size. With 100K+ records, even trivial deviations become statistically significant. Use MAD as primary metric.

References

  • For second and third digit extensions, see references/higher-digit-tests.md
  • For case studies in fraud detection, see references/fraud-case-studies.md

Other skills for the same job

different authors, same section of the catalogue
Invoice Organizer
by frostant
×5

Automatically organizes invoices and receipts for tax preparation by reading messy files, extracting key information, renaming them consistently, and sorting them into logical folders. Turns hours of manual bookkeeping into minutes of automated organization.

3k tokens
Backtest Expert
by BaggaT236
×3

Expert guidance for systematic backtesting of trading strategies. Use when developing, testing, stress-testing, or validating quantitative trading strategies. Covers "beating ideas to death" methodology, parameter robustness testing, slippage modeling, bias prevention, and interpreting backtest results. Applicable when user asks about backtesting, strategy validation, robustness testing, avoiding overfitting, or systematic trading development.

15k tokens scripts
Analyzing Financial Statements
by anthropics
vendor ×2

This skill calculates key financial ratios and metrics from financial statement data for investment analysis

8k tokens scripts
Creating Financial Models
by anthropics
vendor ×2

This skill provides an advanced financial modeling suite with DCF analysis, sensitivity testing, Monte Carlo simulations, and scenario planning for investment decisions

8k tokens scripts
Earnings Calendar
by nicepkg
×2

This skill retrieves upcoming earnings announcements for US stocks using the Financial Modeling Prep (FMP) API. Use this when the user requests earnings calendar data, wants to know which companies are reporting earnings in the upcoming week, or needs a weekly earnings review. The skill focuses on mid-cap and above companies (over $2B market cap) that have significant market impact, organizing the data by date and timing in a clean markdown table format. Supports multiple environments (CLI, Desktop, Web) with flexible API key management.

17k tokens scripts
Agentic Wallet
by coinbase
vendor ×2

Crypto wallet operations via the awal CLI — sign in, check balances, send USDC/ETH/POL/SOL, trade tokens, fund the wallet, and use the x402 payment protocol to discover paid services, pay for API calls, monetize an API, or query onchain data. Use whenever the user mentions signing in, login, authentication, wallet status, balance, address, sending money, paying someone, transferring tokens, ENS names, swapping/trading/converting tokens, funding/topping up/onramp, USDC, ETH, POL, SOL, the x402 bazaar, paid APIs, monetizing an endpoint, or querying onchain data on Base.

14k tokens
Alpha Vantage
by christophacham
×2

Access real-time and historical stock market data, forex rates, cryptocurrency prices, commodities, economic indicators, and 50+ technical indicators via the Alpha Vantage API. Use when fetching stock prices (OHLCV), company fundamentals (income statement, balance sheet, cash flow), earnings, options data, market news/sentiment, insider transactions, GDP, CPI, treasury yields, gold/silver/oil prices, Bitcoin/crypto prices, forex exchange rates, or calculating technical indicators (SMA, EMA, MACD, RSI, Bollinger Bands). Requires a free API key from alphavantage.co.

13k tokens
Braintree Automation
by christophacham
×2

Braintree Automation: manage payment processing via Stripe-compatible tools for customers, subscriptions, payment methods, and transactions

2k tokens needs MCP

How to use it

Copy the folder

Take asgard-ai-platform/algo-risk-benford from the repository into ~/.claude/skills for personal use, or into .claude/skills inside a project.

Check the name does not clash

The agent identifies a skill by the name field in its header. Two skills with the same name cannot sit side by side — one of them will be ignored.