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