You are in AUTONOMOUS MODE. Do NOT ask questions. Analyze every aspect of the credit risk system systematically.
TARGET: $ARGUMENTS
If no arguments provided, analyze the entire credit risk codebase in the current working directory.
============================================================
PHASE 0: SYSTEM DISCOVERY
Auto-detect the credit risk system architecture:
TECH STACK:
requirements.txt / pyproject.toml -> Python (scikit-learn, XGBoost, LightGBM, TensorFlow)
pom.xml / build.gradle -> Java (FICO, custom engines)
package.json -> Node.js (custom scoring, API layer)
go.mod -> Go (decision engine, real-time scoring)
*.sas / *.r / *.R -> SAS / R (traditional statistical models)
- Jupyter notebooks (
*.ipynb) -> Model development and experimentation
MODEL COMPONENTS -- identify each:
- Scoring models: logistic regression, gradient boosting, neural networks, ensemble
- Feature stores and feature engineering pipelines
- Decision engines: rule-based, model-based, hybrid
- Model serving: batch scoring, real-time API, embedded scoring
- Monitoring: model drift detection, performance tracking, alerting
- Data sources: credit bureaus, application data, alternative data
Produce a system inventory before proceeding.
============================================================
PHASE 1: MODEL ARCHITECTURE ANALYSIS
ALGORITHM REVIEW:
- Identify all scoring algorithms in use (logistic regression, GBM, neural net, etc.).
- Assess model complexity vs interpretability tradeoff.
- Verify model selection rationale is documented.
- Check ensemble methods and sub-model combination strategy.
- Verify hyperparameter tuning process (grid search, Bayesian optimization, cross-validation).
FEATURE SELECTION:
- List all input features used in scoring models.
- Check for feature importance ranking (Gini, information value, chi-square).
- Identify correlated features that may cause multicollinearity.
- Verify feature stability analysis across time periods.
- Check for feature drift monitoring between training and production.
MODEL VALIDATION:
- Verify out-of-sample testing methodology (train/test split, k-fold, time-based).
- Check discrimination metrics: AUC-ROC, Gini coefficient, KS statistic.
- Check calibration metrics: Hosmer-Lemeshow, calibration curves.
- Verify PSI (Population Stability Index) monitoring.
- Check for stress testing and sensitivity analysis.
- Verify backtesting against historical default data.
For each finding: record file path, model component, severity, description, recommendation.
============================================================
PHASE 2: DATA QUALITY ASSESSMENT
INPUT DATA VALIDATION:
- Schema validation on incoming data (bureau data, application data).
- Data type enforcement (numeric fields not accepting strings, date formats).
- Range validation (age > 0, income > 0, credit score 300-850).
- Referential integrity checks across data sources.
MISSING VALUE HANDLING:
- Detection and flagging of missing values.
- Imputation strategies (mean, median, model-based, flag-and-fill).
- Missing value rate monitoring and alerting.
- Missing-at-random assumption validation.
- Flag hardcoded magic values used as missing indicators (-999, 9999, etc.).
OUTLIER DETECTION:
- Outlier detection in continuous features.
- Treatment strategy (winsorization, capping, exclusion).
- Documented and justified outlier thresholds.
- Extreme value handling in production scoring.
DATA LINEAGE:
- Data source documentation.
- Data transformation audit trail.
- Data versioning for model reproducibility.
- Training data snapshot archival.
============================================================
PHASE 3: REGULATORY COMPLIANCE
Audit against fair lending and consumer protection regulations.
FAIR LENDING (ECOA / Regulation B / FHA):
- Verify protected class variables are excluded from models: race, color, religion, national origin, sex, marital status, age (except as permitted).
- Scan for proxy variables that correlate with protected classes: zip code (race proxy), first name (ethnicity proxy), university attended (race proxy).
- Check disparate impact analysis documentation.
- Verify adverse action notice generation meets Regulation B requirements.
- Check that specific denial reasons are provided (not generic).
- Verify adverse action reason codes map to FCRA/ECOA requirements.
ADVERSE ACTION NOTICES:
- Verify specific reason codes generated for each denial.
- Check reason codes are ordered by impact (most impactful first).
- Verify reason code descriptions are consumer-friendly.
- Check that up to 4 principal reasons are provided per ECOA requirements.
- Verify adverse action notice templates include all required disclosures.
MODEL DOCUMENTATION (SR 11-7 / OCC 2011-12):
- Model development documentation (methodology, assumptions, limitations).
- Independent model validation.
- Ongoing monitoring plan documentation.
- Model inventory/registry with version tracking.
- Model risk tier classification documentation.
FCRA COMPLIANCE:
- Permissible purpose checks before pulling credit reports.
- Accurate furnishing logic for credit bureau reporting.
- Dispute resolution workflow.
- Consumer disclosure mechanisms.
============================================================
PHASE 4: BIAS DETECTION AND FAIRNESS
PROTECTED CLASS PROXY ANALYSIS:
- Compute correlation between each input feature and known protected attributes.
- Flag features with correlation > 0.3 to race, gender, age, or national origin.
- Check if zip code, education institution, or employer are used (common proxies).
- Verify alternative data sources (rent payments, utility data) are tested for bias.
DISPARATE IMPACT TESTING:
- Approval rate comparison across demographic groups.
- Four-fifths (80%) rule analysis.
- Marginal effect analysis on protected classes.
- Statistical significance testing on outcome differences.
- Disparate impact testing at multiple score thresholds.
FAIRNESS METRICS:
- Demographic parity measurement.
- Equalized odds / equal opportunity metrics.
- Predictive parity across groups.
- Calibration fairness (equal calibration across groups).
- Fairness-accuracy tradeoff documentation.
BIAS MITIGATION:
- Pre-processing techniques (reweighting, resampling).
- In-processing techniques (adversarial debiasing, fairness constraints).
- Post-processing adjustments (threshold optimization per group).
- Mitigation step documentation with impact analysis.
============================================================
PHASE 5: MODEL GOVERNANCE
VERSION CONTROL:
- Model version control with reproducibility artifacts.
- Training data, code, hyperparameters, and outputs versioned together.
- Model registry (MLflow, Weights & Biases, custom).
- Rollback capability to previous model versions.
CHAMPION-CHALLENGER FRAMEWORK:
- Challenger models tested alongside production champion.
- A/B testing or shadow scoring infrastructure.
- Defined and documented champion replacement criteria.
- Performance comparison methodology.
MONITORING AND ALERTING:
- Model performance degradation detection.
- PSI monitoring on input features.
- Concept drift detection on target variable.
- Automated alerting when metrics breach thresholds.
- Regular model performance reporting cadence.
APPROVAL AND AUDIT:
- Model approval workflow (development -> validation -> approval -> deployment).
- Audit trail on model changes and approvals.
- Segregation of duties between model developers and validators.
- Documented model risk assessments.
============================================================
PHASE 6: EXPLAINABILITY AND TRANSPARENCY
GLOBAL EXPLAINABILITY:
- Feature importance calculations (Gini, permutation, SHAP).
- Partial dependence plots or accumulated local effects.
- Global surrogate model documentation.
- Model behavior documentation for edge cases.
LOCAL EXPLAINABILITY:
- Individual prediction explanations (SHAP values, LIME).
- Reason code generation from model explanations.
- Explanation magnitudes mapped to adverse action reasons.
- Explanation consistency across similar applicants.
DOCUMENTATION:
- Model cards or model factsheets.
- Intended use and limitations documented.
- Performance metrics broken down by relevant segments.
- Known failure modes documented.
============================================================
SELF-HEALING VALIDATION (max 2 iterations)
After producing output, validate data quality and completeness:
- Verify all output sections have substantive content (not just headers).
- Verify every finding references a specific file, code location, or data point.
- Verify recommendations are actionable and evidence-based.
- If the analysis consumed insufficient data (empty directories, missing configs),
note data gaps and attempt alternative discovery methods.
IF VALIDATION FAILS:
- Identify which sections are incomplete or lack evidence
- Re-analyze the deficient areas with expanded search patterns
- Repeat up to 2 iterations
IF STILL INCOMPLETE after 2 iterations:
- Flag specific gaps in the output
- Note what data would be needed to complete the analysis
============================================================
OUTPUT
Credit Risk Model Analysis Report
System: [name/description]
Stack: [detected technologies]
Models Found: [count and types]
Summary
| Category |
Status |
Findings |
Critical |
| Model Architecture |
[PASS/WARN/FAIL] |
N |
N |
| Data Quality |
[PASS/WARN/FAIL] |
N |
N |
| Regulatory Compliance |
[PASS/WARN/FAIL] |
N |
N |
| Bias & Fairness |
[PASS/WARN/FAIL] |
N |
N |
| Model Governance |
[PASS/WARN/FAIL] |
N |
N |
| Explainability |
[PASS/WARN/FAIL] |
N |
N |
Model Inventory
| Model |
Type |
Features |
AUC |
Last Validated |
Status |
Detailed Findings
For each category with WARN or FAIL:
[Category Name]
| # |
Severity |
File |
Description |
Regulation |
Recommendation |
Regulatory Risk Assessment
- Fair Lending violations: [count and summary]
- Documentation gaps: [count and summary]
- Adverse action deficiencies: [count and summary]
- Model governance gaps: [count and summary]
Bias Analysis Summary
- Proxy variables identified: [list]
- Disparate impact findings: [summary by protected class]
- Fairness metric results: [summary table]
Remediation Priority
[Ordered list by regulatory risk and severity -- compliance issues first]
============================================================
NEXT STEPS
- "Run
/fraud-detection to analyze fraud detection components in the lending pipeline."
- "Run
/financial-compliance to review broader regulatory compliance (KYC/AML, BSA)."
- "Run
/owasp to audit the scoring API for security vulnerabilities."
- "Run
/analyze to trace data flows end-to-end across the system."
============================================================
SELF-EVOLUTION TELEMETRY
After producing output, record execution metadata for the /evolve pipeline.
Check if a project memory directory exists:
- Look for the project path in
~/.claude/projects/
- If found, append to
skill-telemetry.md in that memory directory
Entry format:
### /credit-risk — {{YYYY-MM-DD}}
- Outcome: {{SUCCESS | PARTIAL | FAILED}}
- Self-healed: {{yes — what was healed | no}}
- Iterations used: {{N}} / {{N max}}
- Bottleneck: {{phase that struggled or "none"}}
- Suggestion: {{one-line improvement idea for /evolve, or "none"}}
Only log if the memory directory exists. Skip silently if not found.
Keep entries concise — /evolve will parse these for skill improvement signals.
============================================================
DO NOT
- Do NOT modify any model code or scoring logic -- this is an analysis skill.
- Do NOT retrain or re-score any models.
- Do NOT access or display actual customer PII from training data or production.
- Do NOT make definitive legal conclusions -- flag issues for legal/compliance review.
- Do NOT skip regulatory compliance phases even if the system appears small.
- Do NOT assume fair lending compliance without testing -- always check for proxy variables.
- Do NOT conflate statistical correlation with confirmed disparate impact -- note confidence levels.
1---2name: credit-risk3description: Audit credit risk modeling software for scoring algorithm accuracy, regulatory compliance (ECOA, FCRA, SR 11-7), bias and disparate impact testing, model governance lifecycle, and explainability..4---56You are in AUTONOMOUS MODE. Do NOT ask questions. Analyze every aspect of the credit risk system systematically.78TARGET: $ARGUMENTS910If no arguments provided, analyze the entire credit risk codebase in the current working directory.1112============================================================13PHASE 0: SYSTEM DISCOVERY14============================================================1516Auto-detect the credit risk system architecture:1718TECH STACK:19- `requirements.txt` / `pyproject.toml` -> Python (scikit-learn, XGBoost, LightGBM, TensorFlow)20- `pom.xml` / `build.gradle` -> Java (FICO, custom engines)21- `package.json` -> Node.js (custom scoring, API layer)22- `go.mod` -> Go (decision engine, real-time scoring)23- `*.sas` / `*.r` / `*.R` -> SAS / R (traditional statistical models)24- Jupyter notebooks (`*.ipynb`) -> Model development and experimentation2526MODEL COMPONENTS -- identify each:27- Scoring models: logistic regression, gradient boosting, neural networks, ensemble28- Feature stores and feature engineering pipelines29- Decision engines: rule-based, model-based, hybrid30- Model serving: batch scoring, real-time API, embedded scoring31- Monitoring: model drift detection, performance tracking, alerting32- Data sources: credit bureaus, application data, alternative data3334Produce a system inventory before proceeding.3536============================================================37PHASE 1: MODEL ARCHITECTURE ANALYSIS38============================================================3940ALGORITHM REVIEW:41- Identify all scoring algorithms in use (logistic regression, GBM, neural net, etc.).42- Assess model complexity vs interpretability tradeoff.43- Verify model selection rationale is documented.44- Check ensemble methods and sub-model combination strategy.45- Verify hyperparameter tuning process (grid search, Bayesian optimization, cross-validation).4647FEATURE SELECTION:48- List all input features used in scoring models.49- Check for feature importance ranking (Gini, information value, chi-square).50- Identify correlated features that may cause multicollinearity.51- Verify feature stability analysis across time periods.52- Check for feature drift monitoring between training and production.5354MODEL VALIDATION:55- Verify out-of-sample testing methodology (train/test split, k-fold, time-based).56- Check discrimination metrics: AUC-ROC, Gini coefficient, KS statistic.57- Check calibration metrics: Hosmer-Lemeshow, calibration curves.58- Verify PSI (Population Stability Index) monitoring.59- Check for stress testing and sensitivity analysis.60- Verify backtesting against historical default data.6162For each finding: record file path, model component, severity, description, recommendation.6364============================================================65PHASE 2: DATA QUALITY ASSESSMENT66============================================================6768INPUT DATA VALIDATION:69- Schema validation on incoming data (bureau data, application data).70- Data type enforcement (numeric fields not accepting strings, date formats).71- Range validation (age > 0, income > 0, credit score 300-850).72- Referential integrity checks across data sources.7374MISSING VALUE HANDLING:75- Detection and flagging of missing values.76- Imputation strategies (mean, median, model-based, flag-and-fill).77- Missing value rate monitoring and alerting.78- Missing-at-random assumption validation.79- Flag hardcoded magic values used as missing indicators (-999, 9999, etc.).8081OUTLIER DETECTION:82- Outlier detection in continuous features.83- Treatment strategy (winsorization, capping, exclusion).84- Documented and justified outlier thresholds.85- Extreme value handling in production scoring.8687DATA LINEAGE:88- Data source documentation.89- Data transformation audit trail.90- Data versioning for model reproducibility.91- Training data snapshot archival.9293============================================================94PHASE 3: REGULATORY COMPLIANCE95============================================================9697Audit against fair lending and consumer protection regulations.9899FAIR LENDING (ECOA / Regulation B / FHA):100- Verify protected class variables are excluded from models: race, color, religion, national origin, sex, marital status, age (except as permitted).101- Scan for proxy variables that correlate with protected classes: zip code (race proxy), first name (ethnicity proxy), university attended (race proxy).102- Check disparate impact analysis documentation.103- Verify adverse action notice generation meets Regulation B requirements.104- Check that specific denial reasons are provided (not generic).105- Verify adverse action reason codes map to FCRA/ECOA requirements.106107ADVERSE ACTION NOTICES:108- Verify specific reason codes generated for each denial.109- Check reason codes are ordered by impact (most impactful first).110- Verify reason code descriptions are consumer-friendly.111- Check that up to 4 principal reasons are provided per ECOA requirements.112- Verify adverse action notice templates include all required disclosures.113114MODEL DOCUMENTATION (SR 11-7 / OCC 2011-12):115- Model development documentation (methodology, assumptions, limitations).116- Independent model validation.117- Ongoing monitoring plan documentation.118- Model inventory/registry with version tracking.119- Model risk tier classification documentation.120121FCRA COMPLIANCE:122- Permissible purpose checks before pulling credit reports.123- Accurate furnishing logic for credit bureau reporting.124- Dispute resolution workflow.125- Consumer disclosure mechanisms.126127============================================================128PHASE 4: BIAS DETECTION AND FAIRNESS129============================================================130131PROTECTED CLASS PROXY ANALYSIS:132- Compute correlation between each input feature and known protected attributes.133- Flag features with correlation > 0.3 to race, gender, age, or national origin.134- Check if zip code, education institution, or employer are used (common proxies).135- Verify alternative data sources (rent payments, utility data) are tested for bias.136137DISPARATE IMPACT TESTING:138- Approval rate comparison across demographic groups.139- Four-fifths (80%) rule analysis.140- Marginal effect analysis on protected classes.141- Statistical significance testing on outcome differences.142- Disparate impact testing at multiple score thresholds.143144FAIRNESS METRICS:145- Demographic parity measurement.146- Equalized odds / equal opportunity metrics.147- Predictive parity across groups.148- Calibration fairness (equal calibration across groups).149- Fairness-accuracy tradeoff documentation.150151BIAS MITIGATION:152- Pre-processing techniques (reweighting, resampling).153- In-processing techniques (adversarial debiasing, fairness constraints).154- Post-processing adjustments (threshold optimization per group).155- Mitigation step documentation with impact analysis.156157============================================================158PHASE 5: MODEL GOVERNANCE159============================================================160161VERSION CONTROL:162- Model version control with reproducibility artifacts.163- Training data, code, hyperparameters, and outputs versioned together.164- Model registry (MLflow, Weights & Biases, custom).165- Rollback capability to previous model versions.166167CHAMPION-CHALLENGER FRAMEWORK:168- Challenger models tested alongside production champion.169- A/B testing or shadow scoring infrastructure.170- Defined and documented champion replacement criteria.171- Performance comparison methodology.172173MONITORING AND ALERTING:174- Model performance degradation detection.175- PSI monitoring on input features.176- Concept drift detection on target variable.177- Automated alerting when metrics breach thresholds.178- Regular model performance reporting cadence.179180APPROVAL AND AUDIT:181- Model approval workflow (development -> validation -> approval -> deployment).182- Audit trail on model changes and approvals.183- Segregation of duties between model developers and validators.184- Documented model risk assessments.185186============================================================187PHASE 6: EXPLAINABILITY AND TRANSPARENCY188============================================================189190GLOBAL EXPLAINABILITY:191- Feature importance calculations (Gini, permutation, SHAP).192- Partial dependence plots or accumulated local effects.193- Global surrogate model documentation.194- Model behavior documentation for edge cases.195196LOCAL EXPLAINABILITY:197- Individual prediction explanations (SHAP values, LIME).198- Reason code generation from model explanations.199- Explanation magnitudes mapped to adverse action reasons.200- Explanation consistency across similar applicants.201202DOCUMENTATION:203- Model cards or model factsheets.204- Intended use and limitations documented.205- Performance metrics broken down by relevant segments.206- Known failure modes documented.207208209============================================================210SELF-HEALING VALIDATION (max 2 iterations)211============================================================212213After producing output, validate data quality and completeness:2142151. Verify all output sections have substantive content (not just headers).2162. Verify every finding references a specific file, code location, or data point.2173. Verify recommendations are actionable and evidence-based.2184. If the analysis consumed insufficient data (empty directories, missing configs),219 note data gaps and attempt alternative discovery methods.220221IF VALIDATION FAILS:222- Identify which sections are incomplete or lack evidence223- Re-analyze the deficient areas with expanded search patterns224- Repeat up to 2 iterations225226IF STILL INCOMPLETE after 2 iterations:227- Flag specific gaps in the output228- Note what data would be needed to complete the analysis229230============================================================231OUTPUT232============================================================233234## Credit Risk Model Analysis Report235236**System:** [name/description]237**Stack:** [detected technologies]238**Models Found:** [count and types]239240### Summary241242| Category | Status | Findings | Critical |243|----------|--------|----------|----------|244| Model Architecture | [PASS/WARN/FAIL] | N | N |245| Data Quality | [PASS/WARN/FAIL] | N | N |246| Regulatory Compliance | [PASS/WARN/FAIL] | N | N |247| Bias & Fairness | [PASS/WARN/FAIL] | N | N |248| Model Governance | [PASS/WARN/FAIL] | N | N |249| Explainability | [PASS/WARN/FAIL] | N | N |250251### Model Inventory252253| Model | Type | Features | AUC | Last Validated | Status |254|-------|------|----------|-----|----------------|--------|255256### Detailed Findings257258For each category with WARN or FAIL:259260#### [Category Name]261262| # | Severity | File | Description | Regulation | Recommendation |263|---|----------|------|-------------|------------|----------------|264265### Regulatory Risk Assessment266- **Fair Lending violations:** [count and summary]267- **Documentation gaps:** [count and summary]268- **Adverse action deficiencies:** [count and summary]269- **Model governance gaps:** [count and summary]270271### Bias Analysis Summary272- **Proxy variables identified:** [list]273- **Disparate impact findings:** [summary by protected class]274- **Fairness metric results:** [summary table]275276### Remediation Priority277[Ordered list by regulatory risk and severity -- compliance issues first]278279============================================================280NEXT STEPS281============================================================282283- "Run `/fraud-detection` to analyze fraud detection components in the lending pipeline."284- "Run `/financial-compliance` to review broader regulatory compliance (KYC/AML, BSA)."285- "Run `/owasp` to audit the scoring API for security vulnerabilities."286- "Run `/analyze` to trace data flows end-to-end across the system."287288289============================================================290SELF-EVOLUTION TELEMETRY291============================================================292293After producing output, record execution metadata for the /evolve pipeline.294295Check if a project memory directory exists:296- Look for the project path in `~/.claude/projects/`297- If found, append to `skill-telemetry.md` in that memory directory298299Entry format:300```301### /credit-risk — {{YYYY-MM-DD}}302- Outcome: {{SUCCESS | PARTIAL | FAILED}}303- Self-healed: {{yes — what was healed | no}}304- Iterations used: {{N}} / {{N max}}305- Bottleneck: {{phase that struggled or "none"}}306- Suggestion: {{one-line improvement idea for /evolve, or "none"}}307```308309Only log if the memory directory exists. Skip silently if not found.310Keep entries concise — /evolve will parse these for skill improvement signals.311312============================================================313DO NOT314============================================================315316- Do NOT modify any model code or scoring logic -- this is an analysis skill.317- Do NOT retrain or re-score any models.318- Do NOT access or display actual customer PII from training data or production.319- Do NOT make definitive legal conclusions -- flag issues for legal/compliance review.320- Do NOT skip regulatory compliance phases even if the system appears small.321- Do NOT assume fair lending compliance without testing -- always check for proxy variables.322- Do NOT conflate statistical correlation with confirmed disparate impact -- note confidence levels.