Model Risk Management
Skill Profile
(Select at least one profile to enable specific modules)
Overview
Model Risk Management (MRM) is a framework designed to manage the risk of adverse consequences resulting from decisions based on incorrect or misused model outputs. While software engineering focuses on "bugs," MRM focuses on "Model Errors"—mathematically correct but contextually wrong predictions.
Core Principle: "All models are wrong, but some are dangerous. Manage the danger."
Why This Matters
Core Concepts & Rules
1. Core Principles
- Follow established patterns and conventions
- Maintain consistency across codebase
- Document decisions and trade-offs
2. Implementation Guidelines
- Start with the simplest viable solution
- Iterate based on feedback and requirements
- Test thoroughly before deployment
Inputs / Outputs / Contracts
- Inputs:
- <e.g., env vars, request payload, file paths, schema>
- Entry Conditions:
- <Pre-requisites: e.g., Repo initialized, DB running, specific branch checked out>
- Outputs:
- <e.g., artifacts (PR diff, docs, tests, dashboard JSON)>
- Artifacts Required (Deliverables):
- <e.g., Code Diff, Unit Tests, Migration Script, API Docs>
- Acceptance Evidence:
- <e.g., Test Report (screenshot/log), Benchmark Result, Security Scan Report>
- Success Criteria:
- <e.g., p95 < 300ms, coverage ≥ 80%>
Skill Composition
- Depends on: None
- Compatible with: None
- Conflicts with: None
- Related Skills: None
Quick Start / Implementation Example
- Review requirements and constraints
- Set up development environment
- Implement core functionality following patterns
- Write tests for critical paths
- Run tests and fix issues
- Document any deviations or decisions
# Example implementation following best practices
def example_function():
# Your implementation here
pass
Assumptions / Constraints / Non-goals
- Assumptions:
- Development environment is properly configured
- Required dependencies are available
- Team has basic understanding of domain
- Constraints:
- Must follow existing codebase conventions
- Time and resource limitations
- Compatibility requirements
- Non-goals:
- This skill does not cover edge cases outside scope
- Not a replacement for formal training
Compatibility & Prerequisites
- Supported Versions:
- Python 3.8+
- Node.js 16+
- Modern browsers (Chrome, Firefox, Safari, Edge)
- Required AI Tools:
- Code editor (VS Code recommended)
- Testing framework appropriate for language
- Version control (Git)
- Dependencies:
- Language-specific package manager
- Build tools
- Testing libraries
- Environment Setup:
.env.example keys: API_KEY, DATABASE_URL (no values)
Test Scenario Matrix (QA Strategy)
| Type |
Focus Area |
Required Scenarios / Mocks |
| Unit |
Core Logic |
Must cover primary logic and at least 3 edge/error cases. Target minimum 80% coverage |
| Integration |
DB / API |
All external API calls or database connections must be mocked during unit tests |
| E2E |
User Journey |
Critical user flows to test |
| Performance |
Latency / Load |
Benchmark requirements |
| Security |
Vuln / Auth |
SAST/DAST or dependency audit |
| Frontend |
UX / A11y |
Accessibility checklist (WCAG), Performance Budget (Lighthouse score) |
Technical Guardrails & Security Threat Model
1. Security & Privacy (Threat Model)
- Top Threats: Injection attacks, authentication bypass, data exposure
2. Performance & Resources
3. Architecture & Scalability
4. Observability & Reliability
Agent Directives & Error Recovery
(ข้อกำหนดสำหรับ AI Agent ในการคิดและแก้ปัญหาเมื่อเกิดข้อผิดพลาด)
- Thinking Process: Analyze root cause before fixing. Do not brute-force.
- Fallback Strategy: Stop after 3 failed test attempts. Output root cause and ask for human intervention/clarification.
- Self-Review: Check against Guardrails & Anti-patterns before finalizing.
- Output Constraints: Output ONLY the modified code block. Do not explain unless asked.
Definition of Done (DoD) Checklist
Anti-patterns / Pitfalls
- ⛔ Don't: Log PII, catch-all exception, N+1 queries
- ⚠️ Watch out for: Common symptoms and quick fixes
- 💡 Instead: Use proper error handling, pagination, and logging
Reference Links & Examples
- Internal documentation and examples
- Official documentation and best practices
- Community resources and discussions
Versioning & Changelog
- Version: 1.0.0
- Changelog:
- 2026-02-22: Initial version with complete template structure
1---2name: model-risk-management-23description: Model Risk Management (MRM) is a framework designed to manage the risk of adverse consequences resulting from decisions based on incorrect or misused model outputs. While software engineering focuses4---5
6# Model Risk Management
7
8## Skill Profile
9*(Select at least one profile to enable specific modules)*
10- [ ] **DevOps**
11- [x] **Backend**
12- [ ] **Frontend**
13- [ ] **AI-RAG**
14- [ ] **Security Critical**
15
16## Overview
17Model Risk Management (MRM) is a framework designed to manage the risk of adverse consequences resulting from decisions based on incorrect or misused model outputs. While software engineering focuses on "bugs," MRM focuses on **"Model Errors"**—mathematically correct but contextually wrong predictions.
18
19**Core Principle**: "All models are wrong, but some are dangerous. Manage the danger."
20
21---
22
23## Why This Matters
24- **<Benefit>**: <short explanation>
25- **<Benefit>**: <short explanation>
26- **<Benefit>**: <short explanation>
27
28## Core Concepts & Rules
29
30### 1. Core Principles
31- Follow established patterns and conventions
32- Maintain consistency across codebase
33- Document decisions and trade-offs
34
35### 2. Implementation Guidelines
36- Start with the simplest viable solution
37- Iterate based on feedback and requirements
38- Test thoroughly before deployment
39
40
41## Inputs / Outputs / Contracts
42* **Inputs**:
43 - <e.g., env vars, request payload, file paths, schema>
44* **Entry Conditions**:
45 - <Pre-requisites: e.g., Repo initialized, DB running, specific branch checked out>
46* **Outputs**:
47 - <e.g., artifacts (PR diff, docs, tests, dashboard JSON)>
48* **Artifacts Required (Deliverables)**:
49 - <e.g., Code Diff, Unit Tests, Migration Script, API Docs>
50* **Acceptance Evidence**:
51 - <e.g., Test Report (screenshot/log), Benchmark Result, Security Scan Report>
52* **Success Criteria**:
53 - <e.g., p95 < 300ms, coverage ≥ 80%>
54
55## Skill Composition
56* **Depends on**: None
57* **Compatible with**: None
58* **Conflicts with**: None
59* **Related Skills**: None
60
61## Quick Start / Implementation Example
62
631. Review requirements and constraints
642. Set up development environment
653. Implement core functionality following patterns
664. Write tests for critical paths
675. Run tests and fix issues
686. Document any deviations or decisions
69
70```python
71# Example implementation following best practices
72def example_function():
73 # Your implementation here
74 pass
75```
76
77
78## Assumptions / Constraints / Non-goals
79
80* **Assumptions**:
81 - Development environment is properly configured
82 - Required dependencies are available
83 - Team has basic understanding of domain
84* **Constraints**:
85 - Must follow existing codebase conventions
86 - Time and resource limitations
87 - Compatibility requirements
88* **Non-goals**:
89 - This skill does not cover edge cases outside scope
90 - Not a replacement for formal training
91
92
93## Compatibility & Prerequisites
94
95* **Supported Versions**:
96 - Python 3.8+
97 - Node.js 16+
98 - Modern browsers (Chrome, Firefox, Safari, Edge)
99* **Required AI Tools**:
100 - Code editor (VS Code recommended)
101 - Testing framework appropriate for language
102 - Version control (Git)
103* **Dependencies**:
104 - Language-specific package manager
105 - Build tools
106 - Testing libraries
107* **Environment Setup**:
108 - `.env.example` keys: `API_KEY`, `DATABASE_URL` (no values)
109
110
111## Test Scenario Matrix (QA Strategy)
112
113| Type | Focus Area | Required Scenarios / Mocks |
114| :--- | :--- | :--- |
115| **Unit** | Core Logic | Must cover primary logic and at least 3 edge/error cases. Target minimum 80% coverage |
116| **Integration** | DB / API | All external API calls or database connections must be mocked during unit tests |
117| **E2E** | User Journey | Critical user flows to test |
118| **Performance** | Latency / Load | Benchmark requirements |
119| **Security** | Vuln / Auth | SAST/DAST or dependency audit |
120| **Frontend** | UX / A11y | Accessibility checklist (WCAG), Performance Budget (Lighthouse score) |
121
122
123## Technical Guardrails & Security Threat Model
124
125### 1. Security & Privacy (Threat Model)
126* **Top Threats**: Injection attacks, authentication bypass, data exposure
127- [ ] **Data Handling**: Sanitize all user inputs to prevent Injection attacks. Never log raw PII
128- [ ] **Secrets Management**: No hardcoded API keys. Use Env Vars/Secrets Manager
129- [ ] **Authorization**: Validate user permissions before state changes
130
131### 2. Performance & Resources
132- [ ] **Execution Efficiency**: Consider time complexity for algorithms
133- [ ] **Memory Management**: Use streams/pagination for large data
134- [ ] **Resource Cleanup**: Close DB connections/file handlers in finally blocks
135
136### 3. Architecture & Scalability
137- [ ] **Design Pattern**: Follow SOLID principles, use Dependency Injection
138- [ ] **Modularity**: Decouple logic from UI/Frameworks
139
140### 4. Observability & Reliability
141- [ ] **Logging Standards**: Structured JSON, include trace IDs `request_id`
142- [ ] **Metrics**: Track `error_rate`, `latency`, `queue_depth`
143- [ ] **Error Handling**: Standardized error codes, no bare except
144- [ ] **Observability Artifacts**:
145 - **Log Fields**: timestamp, level, message, request_id
146 - **Metrics**: request_count, error_count, response_time
147 - **Dashboards/Alerts**: High Error Rate > 5%
148
149
150## Agent Directives & Error Recovery
151*(ข้อกำหนดสำหรับ AI Agent ในการคิดและแก้ปัญหาเมื่อเกิดข้อผิดพลาด)*
152
153- **Thinking Process**: Analyze root cause before fixing. Do not brute-force.
154- **Fallback Strategy**: Stop after 3 failed test attempts. Output root cause and ask for human intervention/clarification.
155- **Self-Review**: Check against Guardrails & Anti-patterns before finalizing.
156- **Output Constraints**: Output ONLY the modified code block. Do not explain unless asked.
157
158
159## Definition of Done (DoD) Checklist
160
161- [ ] Tests passed + coverage met
162- [ ] Lint/Typecheck passed
163- [ ] Logging/Metrics/Trace implemented
164- [ ] Security checks passed
165- [ ] Documentation/Changelog updated
166- [ ] Accessibility/Performance requirements met (if frontend)
167
168
169## Anti-patterns / Pitfalls
170
171* ⛔ **Don't**: Log PII, catch-all exception, N+1 queries
172* ⚠️ **Watch out for**: Common symptoms and quick fixes
173* 💡 **Instead**: Use proper error handling, pagination, and logging
174
175
176## Reference Links & Examples
177
178* Internal documentation and examples
179* Official documentation and best practices
180* Community resources and discussions
181
182
183## Versioning & Changelog
184
185* **Version**: 1.0.0
186* **Changelog**:
187 - 2026-02-22: Initial version with complete template structure
188