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. Covers logistic regression, GBM, neural net evaluation, protected class proxy detection, adverse action notice generation, SHAP/LIME explainability, champion-challenger frameworks, and PSI drift monitoring. Use when reviewing lending platforms, underwriting engines, credit scoring APIs, fintech decisioning systems, or any codebase that scores creditworthiness or generates approval/denial decisions.4---5
6You are in AUTONOMOUS MODE. Do NOT ask questions. Analyze every aspect of the credit risk system systematically.
7
8TARGET: $ARGUMENTS
9
10If no arguments provided, analyze the entire credit risk codebase in the current working directory.
11
12============================================================
13PHASE 0: SYSTEM DISCOVERY
14============================================================
15
16Auto-detect the credit risk system architecture:
17
18TECH 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 experimentation
25
26MODEL COMPONENTS -- identify each:
27- Scoring models: logistic regression, gradient boosting, neural networks, ensemble
28- Feature stores and feature engineering pipelines
29- Decision engines: rule-based, model-based, hybrid
30- Model serving: batch scoring, real-time API, embedded scoring
31- Monitoring: model drift detection, performance tracking, alerting
32- Data sources: credit bureaus, application data, alternative data
33
34Produce a system inventory before proceeding.
35
36============================================================
37PHASE 1: MODEL ARCHITECTURE ANALYSIS
38============================================================
39
40ALGORITHM 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).
46
47FEATURE 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.
53
54MODEL 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.
61
62For each finding: record file path, model component, severity, description, recommendation.
63
64============================================================
65PHASE 2: DATA QUALITY ASSESSMENT
66============================================================
67
68INPUT 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.
73
74MISSING 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.).
80
81OUTLIER 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.
86
87DATA LINEAGE:
88- Data source documentation.
89- Data transformation audit trail.
90- Data versioning for model reproducibility.
91- Training data snapshot archival.
92
93============================================================
94PHASE 3: REGULATORY COMPLIANCE
95============================================================
96
97Audit against fair lending and consumer protection regulations.
98
99FAIR 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.
106
107ADVERSE 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.
113
114MODEL 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.
120
121FCRA 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.
126
127============================================================
128PHASE 4: BIAS DETECTION AND FAIRNESS
129============================================================
130
131PROTECTED 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.
136
137DISPARATE 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.
143
144FAIRNESS 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.
150
151BIAS 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.
156
157============================================================
158PHASE 5: MODEL GOVERNANCE
159============================================================
160
161VERSION 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.
166
167CHAMPION-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.
172
173MONITORING 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.
179
180APPROVAL 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.
185
186============================================================
187PHASE 6: EXPLAINABILITY AND TRANSPARENCY
188============================================================
189
190GLOBAL 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.
195
196LOCAL 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.
201
202DOCUMENTATION:
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.
207
208
209============================================================
210SELF-HEALING VALIDATION (max 2 iterations)
211============================================================
212
213After producing output, validate data quality and completeness:
214
2151. 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.
220
221IF VALIDATION FAILS:
222- Identify which sections are incomplete or lack evidence
223- Re-analyze the deficient areas with expanded search patterns
224- Repeat up to 2 iterations
225
226IF STILL INCOMPLETE after 2 iterations:
227- Flag specific gaps in the output
228- Note what data would be needed to complete the analysis
229
230============================================================
231OUTPUT
232============================================================
233
234## Credit Risk Model Analysis Report
235
236**System:** [name/description]
237**Stack:** [detected technologies]
238**Models Found:** [count and types]
239
240### Summary
241
242| 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 |
250
251### Model Inventory
252
253| Model | Type | Features | AUC | Last Validated | Status |
254|-------|------|----------|-----|----------------|--------|
255
256### Detailed Findings
257
258For each category with WARN or FAIL:
259
260#### [Category Name]
261
262| # | Severity | File | Description | Regulation | Recommendation |
263|---|----------|------|-------------|------------|----------------|
264
265### Regulatory Risk Assessment
266- **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]
270
271### Bias Analysis Summary
272- **Proxy variables identified:** [list]
273- **Disparate impact findings:** [summary by protected class]
274- **Fairness metric results:** [summary table]
275
276### Remediation Priority
277[Ordered list by regulatory risk and severity -- compliance issues first]
278
279============================================================
280NEXT STEPS
281============================================================
282
283- "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."
287
288
289============================================================
290SELF-EVOLUTION TELEMETRY
291============================================================
292
293After producing output, record execution metadata for the /evolve pipeline.
294
295Check 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 directory
298
299Entry 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```
308
309Only log if the memory directory exists. Skip silently if not found.
310Keep entries concise — /evolve will parse these for skill improvement signals.
311
312============================================================
313DO NOT
314============================================================
315
316- 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.