Gotcha Summarizer
Automatically extracts and documents technical lessons learned from conversations into the project's docs/gotchas/ directory.
Features
- Structured Extraction: Extracts problems, causes, solutions, best practices from conversations
- 18+ Language Detection: Automatic code language detection (JSX/TSX, SQL, Vue, Bash, PowerShell, PHP, Ruby, Swift, Kotlin, C#, Dart, Rust, Go, Python, TypeScript, Java, JavaScript, C, C++)
- Multi-Code Block Support: Groups and displays code blocks by programming language
- Confidence Scoring: Returns classification confidence scores for domain and category
- Fuzzy Duplicate Detection: Detects similar entries using SequenceMatcher (threshold: 0.75)
- Internationalization: Chinese/English interface with
LOCALE environment variable
- Error Tracking: Tracks JSON parse errors, file I/O errors, classification errors with statistics
Purpose
This skill analyzes conversation history to identify and document:
Frontend Development:
- Frontend bugs and root causes (hydration errors, memory leaks, rendering issues)
- Framework issues (React, Vue, Next.js, Nuxt, Svelte, Angular)
- Styling problems (CSS, SCSS, Tailwind, UnoCSS)
- Build tool issues (Vite, Webpack, Rollup, esbuild)
- State management (Redux, Pinia, Zustand, Jotai, Vuex)
- UI component library issues (Ant Design, Element Plus, shadcn/ui, Material-UI)
Backend Development:
- Backend bugs and root causes (nil pointer, race conditions, database errors)
- Database/ORM issues (SQL, migrations, Bun, GORM, Ent, sqlx)
- API issues (REST, GraphQL, gRPC, endpoints, controllers)
- Concurrency issues (goroutines, mutexes, channels, context, race conditions)
- Performance issues (caching, Redis, slow queries, indexing, n+1 problems)
- Precision issues (decimal vs float, money/amount handling)
Common Development:
- Testing problems and solutions (unit tests, integration tests, mocks, TDD)
- CI/CD pipeline issues (GitHub Actions, Docker, deployment, Kubernetes)
- Git/version control problems (merge conflicts, rebasing, branches)
- Code quality improvements (refactoring, design patterns, linting)
- Any technical lessons worth documenting
Usage
Run this skill at the end of a conversation to capture lessons learned:
skill gotcha-summarizer
The skill will:
- Analyze the conversation for technical issues
- Use a decision tree to categorize the topic
- Extract key information (error messages, root causes, solutions)
- Check existing docs for duplicates
- Update the appropriate markdown file
Decision Tree
START: Analyze conversation for technical issues
│
├─ LAYER 1: Domain Classification (Common / Frontend / Backend)
│ │
│ ├─ COMMON BRANCH → LAYER 2
│ │ ├─ Testing → common/testing.md
│ │ ├─ CI/CD → common/cicd.md
│ │ ├─ Git → common/git.md
│ │ └─ Code Quality → common/code-quality.md
│ │
│ ├─ FRONTEND BRANCH → LAYER 2
│ │ ├─ Bug Issues → frontend/bugs.md
│ │ ├─ Framework → frontend/frameworks.md
│ │ ├─ Styling → frontend/styling.md
│ │ ├─ Build Tools → frontend/build-tools.md
│ │ ├─ State Management → frontend/state-mgmt.md
│ │ └─ UI Components → frontend/ui-components.md
│ │
│ └─ BACKEND BRANCH → LAYER 2
│ ├─ Bug Issues → backend/bugs.md
│ ├─ Database → backend/database.md
│ ├─ API → backend/api.md
│ ├─ Concurrency → backend/concurrency.md
│ ├─ Performance → backend/performance.md
│ └─ Precision → backend/precision.md
│
└─ LAYER 3: File Mapping (Category → markdown file)
Classification Priority
The three-layer decision tree checks categories in this priority order:
Layer 1: Domain (Common > Frontend > Backend)
- Common domains (Testing, CI/CD, Git) are checked first as they apply to all development
Layer 2: Category (within each domain)
- Bugs always have highest priority within each domain
- Other categories follow domain-specific priority
Frontend Priority: Bugs > Frameworks > State Mgmt > Styling > Build Tools > UI Components
Backend Priority: Bugs > Database > API > Concurrency > Performance > Precision
Common Priority: Testing > CI/CD > Git > Code Quality
Supported Categories
| Domain |
Category |
File |
Examples |
| Frontend |
Bugs |
frontend/bugs.md |
Hydration errors, memory leaks, re-render issues |
|
Frameworks |
frontend/frameworks.md |
React, Vue, Next.js, Nuxt, Svelte, Angular |
|
Styling |
frontend/styling.md |
CSS, SCSS, Tailwind, UnoCSS, styled-components |
|
Build Tools |
frontend/build-tools.md |
Vite, Webpack, Rollup, esbuild, HMR |
|
State Mgmt |
frontend/state-mgmt.md |
Redux, Pinia, Zustand, Jotai, Vuex |
|
UI Components |
frontend/ui-components.md |
Ant Design, Element Plus, shadcn/ui, MUI |
| Backend |
Bugs |
backend/bugs.md |
Nil pointer, race conditions, SQL errors |
|
Database |
backend/database.md |
SQL, ORM (Bun, GORM, Ent), migrations |
|
API |
backend/api.md |
REST, GraphQL, gRPC, endpoints, controllers |
|
Concurrency |
backend/concurrency.md |
Goroutines, mutexes, channels, context |
|
Performance |
backend/performance.md |
Caching (Redis), slow queries, indexing, n+1 |
|
Precision |
backend/precision.md |
Decimal vs float, money/amount handling |
| Common |
Testing |
common/testing.md |
Unit tests, integration tests, mocks, TDD |
|
CI/CD |
common/cicd.md |
GitHub Actions, Docker, Kubernetes, deployment |
|
Git |
common/git.md |
Merge conflicts, rebasing, branch management |
|
Code Quality |
common/code-quality.md |
Refactoring, design patterns, linting |
Script Usage
The main script can be run directly:
python3 scripts/summarize.py
Environment Variables
| Variable |
Default |
Description |
CLAUDE_HISTORY_PATH |
Auto-detected |
Path to conversation history JSON |
GOTCHAS_DIR |
./docs/gotchas |
Path to docs/gotchas directory |
DRY_RUN |
false |
Set to true to preview changes without writing |
TIMESTAMP_FORMAT |
%Y-%m-%d %H:%M:%S |
Format for timestamps in generated markdown |
LOCALE |
zh |
Interface language (zh for Chinese, en for English) |
LOG_LEVEL |
WARNING |
Logging level (DEBUG, INFO, WARNING, ERROR) |
ENABLE_ERROR_TRACKING |
false |
Enable detailed error tracking and statistics |
Examples
# Default: analyze latest conversation and update docs
python3 scripts/summarize.py
# Preview changes without writing
DRY_RUN=true python3 scripts/summarize.py
# Specify custom gotchas directory
GOTCHAS_DIR=/path/to/docs/gotchas python3 scripts/summarize.py
# Use specific conversation history
CLAUDE_HISTORY_PATH=/path/to/history.jsonl python3 scripts/summarize.py
# Use English locale
LOCALE=en python3 scripts/summarize.py
# Custom timestamp format (ISO 8601)
TIMESTAMP_FORMAT="%Y-%m-%dT%H:%M:%S%z" python3 scripts/summarize.py
# Enable debug logging and error tracking
LOG_LEVEL=DEBUG ENABLE_ERROR_TRACKING=true python3 scripts/summarize.py
Output Format
The skill generates markdown sections following this format:
Chinese (Default)
## 问题:[简短标题]
> **自动生成时间**: 2026-02-04 18:00:00
### 错误信息
错误信息内容
### 相关代码
```javascript
// Code with automatic language detection
const example = "value";
问题描述
[解释为什么会发生这个问题]
根本原因
[问题背后的技术原因]
解决方案
[解决该问题的方法]
最佳实践清单
### English (LOCALE=en)
```markdown
## Issue: [Short Title]
> **Auto-generated time**: 2026-02-04 18:00:00
### Error Information
Error message content
### Related Code
```javascript
// Code with automatic language detection
const example = "value";
Problem Description
[Explanation of why this issue occurs]
Root Cause
[Technical reason behind the problem]
Solution
[Method to resolve the issue]
Best Practices Checklist
### Multiple Code Blocks
When multiple code blocks in different languages are detected, they are grouped:
```markdown
### 相关代码
#### JAVASCRIPT
```javascript
const App = () => <div />;
GO
func main() {}
## Duplicate Detection
Before adding new content, the script:
1. Reads all existing gotcha files
2. Normalizes text (removes markdown formatting, timestamps, IDs)
3. Checks for similar titles (fuzzy matching with 0.75 threshold)
4. Checks for similar error messages
5. Checks for similar code patterns
6. Skips adding if a duplicate is detected (with warning)
## Error Statistics
When `ENABLE_ERROR_TRACKING=true`, the script outputs detailed error statistics:
📊 Error Statistics:
• Total entries processed: 150
• JSON parse errors: 3
• File read errors: 0
• File write errors: 1
• Classification errors: 0
This helps identify data quality issues in conversation history files.
## Integration with Session End
This skill is designed to be called automatically at the end of conversations. You can set up a session-end hook in your Claude Code configuration to automatically run `gotcha-summarizer` when a conversation ends.
## Troubleshooting
### No technical issues found
If the skill doesn't detect any technical issues:
- Ensure the conversation contains error messages, code examples, or problem-solving discussions
- Try manually triggering the skill with explicit instructions about what to document
### Duplicate entries
The skill attempts to detect duplicates, but may occasionally create similar entries. Review the generated content and merge or remove duplicates as needed.
### File permission errors
Ensure the `docs/gotchas/` directory is writable:
```bash
chmod +w docs/gotchas/*.md
See Also
1---2name: gotcha-summarizer3description: Automatically summarizes technical lessons learned from conversations into docs/gotchas/. Supports 18+ programming languages with confidence scoring. Use at the end of conversations to capture: (1) Frontend/Backend bugs and root causes, (2) Framework issues (React/Vue/Next.js/Nuxt/Databases/APIs), (3) Code quality improvements (precision, caching, concurrency, etc.), (4) Performance optimization insights, (5) Testing/CI/CD/Git issues, (6) Any technical lessons worth documenting. Features: three-layer classification (Domain → Category → File), fuzzy duplicate detection, i18n support (zh/en), multi-code block grouping, error tracking statistics.4---56# Gotcha Summarizer78Automatically extracts and documents technical lessons learned from conversations into the project's `docs/gotchas/` directory.910## Features1112- **Structured Extraction**: Extracts problems, causes, solutions, best practices from conversations13- **18+ Language Detection**: Automatic code language detection (JSX/TSX, SQL, Vue, Bash, PowerShell, PHP, Ruby, Swift, Kotlin, C#, Dart, Rust, Go, Python, TypeScript, Java, JavaScript, C, C++)14- **Multi-Code Block Support**: Groups and displays code blocks by programming language15- **Confidence Scoring**: Returns classification confidence scores for domain and category16- **Fuzzy Duplicate Detection**: Detects similar entries using SequenceMatcher (threshold: 0.75)17- **Internationalization**: Chinese/English interface with `LOCALE` environment variable18- **Error Tracking**: Tracks JSON parse errors, file I/O errors, classification errors with statistics1920## Purpose2122This skill analyzes conversation history to identify and document:2324**Frontend Development:**25- Frontend bugs and root causes (hydration errors, memory leaks, rendering issues)26- Framework issues (React, Vue, Next.js, Nuxt, Svelte, Angular)27- Styling problems (CSS, SCSS, Tailwind, UnoCSS)28- Build tool issues (Vite, Webpack, Rollup, esbuild)29- State management (Redux, Pinia, Zustand, Jotai, Vuex)30- UI component library issues (Ant Design, Element Plus, shadcn/ui, Material-UI)3132**Backend Development:**33- Backend bugs and root causes (nil pointer, race conditions, database errors)34- Database/ORM issues (SQL, migrations, Bun, GORM, Ent, sqlx)35- API issues (REST, GraphQL, gRPC, endpoints, controllers)36- Concurrency issues (goroutines, mutexes, channels, context, race conditions)37- Performance issues (caching, Redis, slow queries, indexing, n+1 problems)38- Precision issues (decimal vs float, money/amount handling)3940**Common Development:**41- Testing problems and solutions (unit tests, integration tests, mocks, TDD)42- CI/CD pipeline issues (GitHub Actions, Docker, deployment, Kubernetes)43- Git/version control problems (merge conflicts, rebasing, branches)44- Code quality improvements (refactoring, design patterns, linting)45- Any technical lessons worth documenting4647## Usage4849Run this skill at the end of a conversation to capture lessons learned:5051```bash52skill gotcha-summarizer53```5455The skill will:561. Analyze the conversation for technical issues572. Use a decision tree to categorize the topic583. Extract key information (error messages, root causes, solutions)594. Check existing docs for duplicates605. Update the appropriate markdown file6162## Decision Tree6364```65START: Analyze conversation for technical issues66│67├─ LAYER 1: Domain Classification (Common / Frontend / Backend)68│ │69│ ├─ COMMON BRANCH → LAYER 270│ │ ├─ Testing → common/testing.md71│ │ ├─ CI/CD → common/cicd.md72│ │ ├─ Git → common/git.md73│ │ └─ Code Quality → common/code-quality.md74│ │75│ ├─ FRONTEND BRANCH → LAYER 276│ │ ├─ Bug Issues → frontend/bugs.md77│ │ ├─ Framework → frontend/frameworks.md78│ │ ├─ Styling → frontend/styling.md79│ │ ├─ Build Tools → frontend/build-tools.md80│ │ ├─ State Management → frontend/state-mgmt.md81│ │ └─ UI Components → frontend/ui-components.md82│ │83│ └─ BACKEND BRANCH → LAYER 284│ ├─ Bug Issues → backend/bugs.md85│ ├─ Database → backend/database.md86│ ├─ API → backend/api.md87│ ├─ Concurrency → backend/concurrency.md88│ ├─ Performance → backend/performance.md89│ └─ Precision → backend/precision.md90│91└─ LAYER 3: File Mapping (Category → markdown file)92```9394### Classification Priority9596The three-layer decision tree checks categories in this priority order:9798**Layer 1: Domain** (Common > Frontend > Backend)99- Common domains (Testing, CI/CD, Git) are checked first as they apply to all development100101**Layer 2: Category** (within each domain)102- **Bugs** always have highest priority within each domain103- Other categories follow domain-specific priority104105**Frontend Priority:** Bugs > Frameworks > State Mgmt > Styling > Build Tools > UI Components106**Backend Priority:** Bugs > Database > API > Concurrency > Performance > Precision107**Common Priority:** Testing > CI/CD > Git > Code Quality108109## Supported Categories110111| Domain | Category | File | Examples |112|--------|----------|------|----------|113| **Frontend** | Bugs | `frontend/bugs.md` | Hydration errors, memory leaks, re-render issues |114| | Frameworks | `frontend/frameworks.md` | React, Vue, Next.js, Nuxt, Svelte, Angular |115| | Styling | `frontend/styling.md` | CSS, SCSS, Tailwind, UnoCSS, styled-components |116| | Build Tools | `frontend/build-tools.md` | Vite, Webpack, Rollup, esbuild, HMR |117| | State Mgmt | `frontend/state-mgmt.md` | Redux, Pinia, Zustand, Jotai, Vuex |118| | UI Components | `frontend/ui-components.md` | Ant Design, Element Plus, shadcn/ui, MUI |119| **Backend** | Bugs | `backend/bugs.md` | Nil pointer, race conditions, SQL errors |120| | Database | `backend/database.md` | SQL, ORM (Bun, GORM, Ent), migrations |121| | API | `backend/api.md` | REST, GraphQL, gRPC, endpoints, controllers |122| | Concurrency | `backend/concurrency.md` | Goroutines, mutexes, channels, context |123| | Performance | `backend/performance.md` | Caching (Redis), slow queries, indexing, n+1 |124| | Precision | `backend/precision.md` | Decimal vs float, money/amount handling |125| **Common** | Testing | `common/testing.md` | Unit tests, integration tests, mocks, TDD |126| | CI/CD | `common/cicd.md` | GitHub Actions, Docker, Kubernetes, deployment |127| | Git | `common/git.md` | Merge conflicts, rebasing, branch management |128| | Code Quality | `common/code-quality.md` | Refactoring, design patterns, linting |129130## Script Usage131132The main script can be run directly:133134```bash135python3 scripts/summarize.py136```137138### Environment Variables139140| Variable | Default | Description |141|----------|---------|-------------|142| `CLAUDE_HISTORY_PATH` | Auto-detected | Path to conversation history JSON |143| `GOTCHAS_DIR` | `./docs/gotchas` | Path to docs/gotchas directory |144| `DRY_RUN` | `false` | Set to `true` to preview changes without writing |145| `TIMESTAMP_FORMAT` | `%Y-%m-%d %H:%M:%S` | Format for timestamps in generated markdown |146| `LOCALE` | `zh` | Interface language (`zh` for Chinese, `en` for English) |147| `LOG_LEVEL` | `WARNING` | Logging level (`DEBUG`, `INFO`, `WARNING`, `ERROR`) |148| `ENABLE_ERROR_TRACKING` | `false` | Enable detailed error tracking and statistics |149150### Examples151152```bash153# Default: analyze latest conversation and update docs154python3 scripts/summarize.py155156# Preview changes without writing157DRY_RUN=true python3 scripts/summarize.py158159# Specify custom gotchas directory160GOTCHAS_DIR=/path/to/docs/gotchas python3 scripts/summarize.py161162# Use specific conversation history163CLAUDE_HISTORY_PATH=/path/to/history.jsonl python3 scripts/summarize.py164165# Use English locale166LOCALE=en python3 scripts/summarize.py167168# Custom timestamp format (ISO 8601)169TIMESTAMP_FORMAT="%Y-%m-%dT%H:%M:%S%z" python3 scripts/summarize.py170171# Enable debug logging and error tracking172LOG_LEVEL=DEBUG ENABLE_ERROR_TRACKING=true python3 scripts/summarize.py173```174175## Output Format176177The skill generates markdown sections following this format:178179### Chinese (Default)180181```markdown182## 问题:[简短标题]183184> **自动生成时间**: 2026-02-04 18:00:00185186### 错误信息187```188错误信息内容189```190191### 相关代码192```javascript193// Code with automatic language detection194const example = "value";195```196197### 问题描述198[解释为什么会发生这个问题]199200### 根本原因201[问题背后的技术原因]202203### 解决方案204[解决该问题的方法]205206### 最佳实践清单207- [ ] 检查项 1208- [ ] 检查项 2209210---211```212213### English (LOCALE=en)214215```markdown216## Issue: [Short Title]217218> **Auto-generated time**: 2026-02-04 18:00:00219220### Error Information221```222Error message content223```224225### Related Code226```javascript227// Code with automatic language detection228const example = "value";229```230231### Problem Description232[Explanation of why this issue occurs]233234### Root Cause235[Technical reason behind the problem]236237### Solution238[Method to resolve the issue]239240### Best Practices Checklist241- [ ] Check item 1242- [ ] Check item 2243244---245```246247### Multiple Code Blocks248249When multiple code blocks in different languages are detected, they are grouped:250251```markdown252### 相关代码253254#### JAVASCRIPT255```javascript256const App = () => <div />;257```258259#### GO260```go261func main() {}262```263```264265## Duplicate Detection266267Before adding new content, the script:2681. Reads all existing gotcha files2692. Normalizes text (removes markdown formatting, timestamps, IDs)2703. Checks for similar titles (fuzzy matching with 0.75 threshold)2714. Checks for similar error messages2725. Checks for similar code patterns2736. Skips adding if a duplicate is detected (with warning)274275## Error Statistics276277When `ENABLE_ERROR_TRACKING=true`, the script outputs detailed error statistics:278279```280📊 Error Statistics:281 • Total entries processed: 150282 • JSON parse errors: 3283 • File read errors: 0284 • File write errors: 1285 • Classification errors: 0286```287288This helps identify data quality issues in conversation history files.289290## Integration with Session End291292This skill is designed to be called automatically at the end of conversations. You can set up a session-end hook in your Claude Code configuration to automatically run `gotcha-summarizer` when a conversation ends.293294## Troubleshooting295296### No technical issues found297298If the skill doesn't detect any technical issues:299- Ensure the conversation contains error messages, code examples, or problem-solving discussions300- Try manually triggering the skill with explicit instructions about what to document301302### Duplicate entries303304The skill attempts to detect duplicates, but may occasionally create similar entries. Review the generated content and merge or remove duplicates as needed.305306### File permission errors307308Ensure the `docs/gotchas/` directory is writable:309```bash310chmod +w docs/gotchas/*.md311```312313## See Also314315- [docs/gotchas/README.md](../../README.md) - Gotchas documentation index316- [docs/gotchas/database.md](../../database.md) - Database and ORM issues and solutions317- [docs/gotchas/code-quality.md](../../code-quality.md) - Code quality issues and solutions