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
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: logging-redaction3description: Logging redaction is the practice of removing or masking sensitive information Use when this capability is needed.4---56# Logging Redaction78## Skill Profile9*(Select at least one profile to enable specific modules)*10- [ ] **DevOps**11- [x] **Backend**12- [ ] **Frontend**13- [ ] **AI-RAG**14- [ ] **Security Critical**1516## Overview17Logging redaction is the practice of removing or masking sensitive information before it appears in logs. This is critical because:1819- **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)2425**Golden Rule**: If you wouldn't want it in a public GitHub repo, don't log it.2627## Why This Matters28- **<Benefit>**: <short explanation>29- **<Benefit>**: <short explanation>30- **<Benefit>**: <short explanation>3132## Core Concepts & Rules3334### 1. Core Principles35- Follow established patterns and conventions36- Maintain consistency across codebase37- Document decisions and trade-offs3839### 2. Implementation Guidelines40- Start with the simplest viable solution41- Iterate based on feedback and requirements42- Test thoroughly before deployment434445## Inputs / Outputs / Contracts46* **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%>5859## Skill Composition60* **Depends on**: None61* **Compatible with**: None62* **Conflicts with**: None63* **Related Skills**: None6465## Quick Start / Implementation Example66671. Review requirements and constraints682. Set up development environment693. Implement core functionality following patterns704. Write tests for critical paths715. Run tests and fix issues726. Document any deviations or decisions7374```python75# Example implementation following best practices76def example_function():77 # Your implementation here78 pass79```808182## Assumptions / Constraints / Non-goals8384* **Assumptions**:85 - Development environment is properly configured86 - Required dependencies are available87 - Team has basic understanding of domain88* **Constraints**:89 - Must follow existing codebase conventions90 - Time and resource limitations91 - Compatibility requirements92* **Non-goals**:93 - This skill does not cover edge cases outside scope94 - Not a replacement for formal training959697## Compatibility & Prerequisites9899* **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 language106 - Version control (Git)107* **Dependencies**:108 - Language-specific package manager109 - Build tools110 - Testing libraries111* **Environment Setup**:112 - `.env.example` keys: `API_KEY`, `DATABASE_URL` (no values)113114115## Test Scenario Matrix (QA Strategy)116117| 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) |125126127## Technical Guardrails & Security Threat Model128129### 1. Security & Privacy (Threat Model)130* **Top Threats**: Injection attacks, authentication bypass, data exposure131- [ ] **Data Handling**: Sanitize all user inputs to prevent Injection attacks. Never log raw PII132- [ ] **Secrets Management**: No hardcoded API keys. Use Env Vars/Secrets Manager133- [ ] **Authorization**: Validate user permissions before state changes134135### 2. Performance & Resources136- [ ] **Execution Efficiency**: Consider time complexity for algorithms137- [ ] **Memory Management**: Use streams/pagination for large data138- [ ] **Resource Cleanup**: Close DB connections/file handlers in finally blocks139140### 3. Architecture & Scalability141- [ ] **Design Pattern**: Follow SOLID principles, use Dependency Injection142- [ ] **Modularity**: Decouple logic from UI/Frameworks143144### 4. Observability & Reliability145- [ ] **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 except148- [ ] **Observability Artifacts**:149 - **Log Fields**: timestamp, level, message, request_id150 - **Metrics**: request_count, error_count, response_time151 - **Dashboards/Alerts**: High Error Rate > 5%152153154## Agent Directives & Error Recovery155*(ข้อกำหนดสำหรับ AI Agent ในการคิดและแก้ปัญหาเมื่อเกิดข้อผิดพลาด)*156157- **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.161162163## Definition of Done (DoD) Checklist164165- [ ] Tests passed + coverage met166- [ ] Lint/Typecheck passed167- [ ] Logging/Metrics/Trace implemented168- [ ] Security checks passed169- [ ] Documentation/Changelog updated170- [ ] Accessibility/Performance requirements met (if frontend)171172173## Anti-patterns / Pitfalls174175* ⛔ **Don't**: Log PII, catch-all exception, N+1 queries176* ⚠️ **Watch out for**: Common symptoms and quick fixes177* 💡 **Instead**: Use proper error handling, pagination, and logging178179180## Reference Links & Examples181182* Internal documentation and examples183* Official documentation and best practices184* Community resources and discussions185186187## Versioning & Changelog188189* **Version**: 1.0.0190* **Changelog**:191 - 2026-02-22: Initial version with complete template structure192193---194> Converted and distributed by [TomeVault](https://tomevault.io/claim/amnadtaowsoam) — claim your Tome and manage your conversions.195<!-- tomevault:4.0:skill_md:2026-04-13 -->