@qazuor/claude-code-config 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1248 -0
- package/dist/bin.cjs +11886 -0
- package/dist/bin.cjs.map +1 -0
- package/dist/bin.d.cts +1 -0
- package/dist/bin.d.ts +1 -0
- package/dist/bin.js +11869 -0
- package/dist/bin.js.map +1 -0
- package/dist/index.cjs +3887 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1325 -0
- package/dist/index.d.ts +1325 -0
- package/dist/index.js +3835 -0
- package/dist/index.js.map +1 -0
- package/package.json +86 -0
- package/templates/.log/notifications.log +1775 -0
- package/templates/agents/README.md +164 -0
- package/templates/agents/_registry.json +443 -0
- package/templates/agents/design/content-writer.md +353 -0
- package/templates/agents/design/ux-ui-designer.md +382 -0
- package/templates/agents/engineering/astro-engineer.md +293 -0
- package/templates/agents/engineering/db-drizzle-engineer.md +360 -0
- package/templates/agents/engineering/express-engineer.md +316 -0
- package/templates/agents/engineering/fastify-engineer.md +399 -0
- package/templates/agents/engineering/hono-engineer.md +263 -0
- package/templates/agents/engineering/mongoose-engineer.md +473 -0
- package/templates/agents/engineering/nestjs-engineer.md +429 -0
- package/templates/agents/engineering/nextjs-engineer.md +451 -0
- package/templates/agents/engineering/node-typescript-engineer.md +347 -0
- package/templates/agents/engineering/prisma-engineer.md +432 -0
- package/templates/agents/engineering/react-senior-dev.md +394 -0
- package/templates/agents/engineering/tanstack-start-engineer.md +447 -0
- package/templates/agents/engineering/tech-lead.md +269 -0
- package/templates/agents/product/product-functional.md +329 -0
- package/templates/agents/product/product-technical.md +578 -0
- package/templates/agents/quality/debugger.md +514 -0
- package/templates/agents/quality/qa-engineer.md +390 -0
- package/templates/agents/specialized/enrichment-agent.md +277 -0
- package/templates/agents/specialized/i18n-specialist.md +322 -0
- package/templates/agents/specialized/seo-ai-specialist.md +387 -0
- package/templates/agents/specialized/tech-writer.md +300 -0
- package/templates/code-style/.editorconfig +27 -0
- package/templates/code-style/.prettierignore +25 -0
- package/templates/code-style/.prettierrc +12 -0
- package/templates/code-style/biome.json +78 -0
- package/templates/code-style/commitlint.config.js +44 -0
- package/templates/commands/README.md +175 -0
- package/templates/commands/_registry.json +420 -0
- package/templates/commands/add-new-entity.md +211 -0
- package/templates/commands/audit/accessibility-audit.md +360 -0
- package/templates/commands/audit/performance-audit.md +290 -0
- package/templates/commands/audit/security-audit.md +231 -0
- package/templates/commands/code-check.md +127 -0
- package/templates/commands/five-why.md +225 -0
- package/templates/commands/formatting/format-markdown.md +197 -0
- package/templates/commands/git/commit.md +247 -0
- package/templates/commands/meta/create-agent.md +257 -0
- package/templates/commands/meta/create-command.md +312 -0
- package/templates/commands/meta/create-skill.md +321 -0
- package/templates/commands/meta/help.md +318 -0
- package/templates/commands/planning/check-completed-tasks.md +224 -0
- package/templates/commands/planning/cleanup-issues.md +248 -0
- package/templates/commands/planning/planning-cleanup.md +251 -0
- package/templates/commands/planning/sync-planning-github.md +133 -0
- package/templates/commands/planning/sync-todos-github.md +203 -0
- package/templates/commands/quality-check.md +211 -0
- package/templates/commands/run-tests.md +159 -0
- package/templates/commands/start-feature-plan.md +232 -0
- package/templates/commands/start-refactor-plan.md +244 -0
- package/templates/commands/sync-planning.md +176 -0
- package/templates/commands/update-docs.md +242 -0
- package/templates/docs/CHECKPOINT-SYSTEM.md +504 -0
- package/templates/docs/INDEX.md +677 -0
- package/templates/docs/RECOMMENDED-HOOKS.md +415 -0
- package/templates/docs/_registry.json +329 -0
- package/templates/docs/diagrams/README.md +220 -0
- package/templates/docs/diagrams/agent-hierarchy.mmd +55 -0
- package/templates/docs/diagrams/documentation-map.mmd +61 -0
- package/templates/docs/diagrams/tools-relationship.mmd +55 -0
- package/templates/docs/diagrams/workflow-decision-tree.mmd +38 -0
- package/templates/docs/doc-sync.md +533 -0
- package/templates/docs/examples/end-to-end-workflow.md +1505 -0
- package/templates/docs/glossary.md +495 -0
- package/templates/docs/guides/mockup-prompt-engineering.md +644 -0
- package/templates/docs/guides/mockup-setup.md +737 -0
- package/templates/docs/learnings/README.md +250 -0
- package/templates/docs/learnings/common-architectural-patterns.md +123 -0
- package/templates/docs/learnings/common-mistakes-to-avoid.md +149 -0
- package/templates/docs/learnings/markdown-formatting-standards.md +104 -0
- package/templates/docs/learnings/monorepo-command-execution.md +64 -0
- package/templates/docs/learnings/optimization-tips.md +146 -0
- package/templates/docs/learnings/planning-linear-sync-workflow.md +70 -0
- package/templates/docs/learnings/shell-compatibility-fish.md +46 -0
- package/templates/docs/learnings/test-organization-structure.md +68 -0
- package/templates/docs/mcp-installation.md +613 -0
- package/templates/docs/mcp-servers.md +989 -0
- package/templates/docs/notification-installation.md +570 -0
- package/templates/docs/quick-start.md +354 -0
- package/templates/docs/standards/architecture-patterns.md +1064 -0
- package/templates/docs/standards/atomic-commits.md +513 -0
- package/templates/docs/standards/code-standards.md +993 -0
- package/templates/docs/standards/design-standards.md +656 -0
- package/templates/docs/standards/documentation-standards.md +1160 -0
- package/templates/docs/standards/testing-standards.md +969 -0
- package/templates/docs/system-maintenance.md +604 -0
- package/templates/docs/templates/PDR-template.md +561 -0
- package/templates/docs/templates/TODOs-template.md +534 -0
- package/templates/docs/templates/tech-analysis-template.md +800 -0
- package/templates/docs/workflows/README.md +519 -0
- package/templates/docs/workflows/atomic-task-protocol.md +955 -0
- package/templates/docs/workflows/decision-tree.md +482 -0
- package/templates/docs/workflows/edge-cases.md +856 -0
- package/templates/docs/workflows/phase-1-planning.md +957 -0
- package/templates/docs/workflows/phase-2-implementation.md +896 -0
- package/templates/docs/workflows/phase-3-validation.md +792 -0
- package/templates/docs/workflows/phase-4-finalization.md +927 -0
- package/templates/docs/workflows/quick-fix-protocol.md +505 -0
- package/templates/docs/workflows/task-atomization.md +537 -0
- package/templates/docs/workflows/task-completion-protocol.md +448 -0
- package/templates/hooks/on-notification.sh +28 -0
- package/templates/schemas/checkpoint.schema.json +97 -0
- package/templates/schemas/code-registry.schema.json +84 -0
- package/templates/schemas/pdr.schema.json +314 -0
- package/templates/schemas/problems.schema.json +55 -0
- package/templates/schemas/tech-analysis.schema.json +404 -0
- package/templates/schemas/telemetry.schema.json +298 -0
- package/templates/schemas/todos.schema.json +234 -0
- package/templates/schemas/workflows.schema.json +69 -0
- package/templates/scripts/add-changelogs.sh +105 -0
- package/templates/scripts/generate-code-registry.ts +270 -0
- package/templates/scripts/health-check.sh +343 -0
- package/templates/scripts/sync-registry.sh +40 -0
- package/templates/scripts/telemetry-report.ts +36 -0
- package/templates/scripts/validate-docs.sh +224 -0
- package/templates/scripts/validate-registry.sh +225 -0
- package/templates/scripts/validate-schemas.ts +283 -0
- package/templates/scripts/validate-structure.sh +165 -0
- package/templates/scripts/worktree-cleanup.sh +81 -0
- package/templates/scripts/worktree-create.sh +63 -0
- package/templates/sessions/planning/.gitkeep +0 -0
- package/templates/sessions/planning/archived/.gitkeep +0 -0
- package/templates/settings.json +202 -0
- package/templates/settings.local.json +138 -0
- package/templates/skills/README.md +197 -0
- package/templates/skills/_registry.json +473 -0
- package/templates/skills/audit/accessibility-audit.md +309 -0
- package/templates/skills/audit/performance-audit.md +257 -0
- package/templates/skills/audit/security-audit.md +217 -0
- package/templates/skills/auth/nextauth-patterns.md +308 -0
- package/templates/skills/brand-guidelines.md +240 -0
- package/templates/skills/documentation/markdown-formatter.md +302 -0
- package/templates/skills/git/git-commit-helper.md +321 -0
- package/templates/skills/i18n/i18n-patterns.md +251 -0
- package/templates/skills/patterns/error-handling-patterns.md +242 -0
- package/templates/skills/patterns/tdd-methodology.md +342 -0
- package/templates/skills/qa/qa-criteria-validator.md +383 -0
- package/templates/skills/qa/web-app-testing.md +398 -0
- package/templates/skills/react/react-hook-form-patterns.md +359 -0
- package/templates/skills/state/redux-toolkit-patterns.md +272 -0
- package/templates/skills/state/tanstack-query-patterns.md +299 -0
- package/templates/skills/state/zustand-patterns.md +301 -0
- package/templates/skills/tech/mermaid-diagram-specialist.md +195 -0
- package/templates/skills/tech/shadcn-specialist.md +252 -0
- package/templates/skills/tech/vercel-specialist.md +297 -0
- package/templates/skills/testing/api-app-testing.md +254 -0
- package/templates/skills/testing/performance-testing.md +275 -0
- package/templates/skills/testing/security-testing.md +348 -0
- package/templates/skills/utils/add-memory.md +295 -0
- package/templates/skills/utils/json-data-auditor.md +283 -0
- package/templates/skills/utils/pdf-creator-editor.md +342 -0
- package/templates/tools/format-markdown.sh +185 -0
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: add-memory
|
|
3
|
+
category: utils
|
|
4
|
+
description: Capture and document learnings, decisions, patterns, and best practices for knowledge continuity
|
|
5
|
+
usage: After making decisions, discovering patterns, solving problems, or establishing conventions
|
|
6
|
+
input: Learning topic, decision rationale, pattern description, context
|
|
7
|
+
output: Structured memory file in configured memory directory
|
|
8
|
+
config_required:
|
|
9
|
+
- memory_path: "Path to memory storage directory"
|
|
10
|
+
- categories: "List of memory categories to use"
|
|
11
|
+
- index_file: "Path to memory index file"
|
|
12
|
+
- date_format: "Date format for file naming"
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# Add Memory
|
|
16
|
+
|
|
17
|
+
## ⚙️ Configuration
|
|
18
|
+
|
|
19
|
+
| Setting | Description | Example |
|
|
20
|
+
|---------|-------------|---------|
|
|
21
|
+
| `memory_path` | Memory storage directory | `.claude/memory/`, `docs/decisions/` |
|
|
22
|
+
| `categories` | Memory categories | `arch`, `patterns`, `gotchas`, `config` |
|
|
23
|
+
| `index_file` | Index file location | `memory/INDEX.md` |
|
|
24
|
+
| `date_format` | File naming date format | `YYYY-MM-DD` |
|
|
25
|
+
| `auto_index` | Auto-update index | `true` |
|
|
26
|
+
|
|
27
|
+
## Purpose
|
|
28
|
+
|
|
29
|
+
Capture architectural decisions, patterns, gotchas, and best practices for future reference and knowledge continuity across the team.
|
|
30
|
+
|
|
31
|
+
## Capabilities
|
|
32
|
+
|
|
33
|
+
- Document architectural decisions with rationale
|
|
34
|
+
- Record reusable code patterns
|
|
35
|
+
- Capture configuration learnings
|
|
36
|
+
- Track gotchas and solutions
|
|
37
|
+
- Build searchable knowledge base
|
|
38
|
+
|
|
39
|
+
## Memory Categories
|
|
40
|
+
|
|
41
|
+
| Category | Purpose | Examples |
|
|
42
|
+
|----------|---------|----------|
|
|
43
|
+
| `arch/` | Architecture decisions | Tech stack, system design, integrations |
|
|
44
|
+
| `patterns/` | Code patterns | RO-RO, base classes, factory patterns |
|
|
45
|
+
| `config/` | Configuration | Environment setup, tool config |
|
|
46
|
+
| `gotchas/` | Issues & solutions | Platform quirks, error fixes |
|
|
47
|
+
| `performance/` | Optimizations | Caching, query optimization |
|
|
48
|
+
| `security/` | Security patterns | Auth patterns, data protection |
|
|
49
|
+
|
|
50
|
+
## Memory Template
|
|
51
|
+
|
|
52
|
+
```markdown
|
|
53
|
+
---
|
|
54
|
+
topic: Brief topic name
|
|
55
|
+
category: arch|patterns|config|gotchas|performance|security
|
|
56
|
+
date: YYYY-MM-DD
|
|
57
|
+
tags: [tag1, tag2, tag3]
|
|
58
|
+
related: [file1.md, file2.md]
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
# Topic Title
|
|
62
|
+
|
|
63
|
+
## Context
|
|
64
|
+
|
|
65
|
+
When this is relevant and why it matters.
|
|
66
|
+
|
|
67
|
+
## Decision/Learning
|
|
68
|
+
|
|
69
|
+
What was decided or learned.
|
|
70
|
+
|
|
71
|
+
## Rationale
|
|
72
|
+
|
|
73
|
+
Why this approach was chosen over alternatives.
|
|
74
|
+
|
|
75
|
+
## Alternatives Considered
|
|
76
|
+
|
|
77
|
+
- **Option 1**: Description, pros/cons
|
|
78
|
+
- **Option 2**: Description, pros/cons
|
|
79
|
+
|
|
80
|
+
## Implementation
|
|
81
|
+
|
|
82
|
+
How to implement this decision/pattern.
|
|
83
|
+
|
|
84
|
+
### Example
|
|
85
|
+
|
|
86
|
+
\`\`\`typescript
|
|
87
|
+
// Code example demonstrating the pattern
|
|
88
|
+
\`\`\`
|
|
89
|
+
|
|
90
|
+
## Implications
|
|
91
|
+
|
|
92
|
+
- Impact on system
|
|
93
|
+
- Trade-offs accepted
|
|
94
|
+
- Future considerations
|
|
95
|
+
|
|
96
|
+
## References
|
|
97
|
+
|
|
98
|
+
- Related documentation
|
|
99
|
+
- External resources
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Example: Architectural Decision
|
|
103
|
+
|
|
104
|
+
```markdown
|
|
105
|
+
---
|
|
106
|
+
topic: Monorepo with TurboRepo
|
|
107
|
+
category: arch
|
|
108
|
+
date: 2024-01-15
|
|
109
|
+
tags: [monorepo, turborepo, build-system]
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
# Monorepo Structure with TurboRepo
|
|
113
|
+
|
|
114
|
+
## Context
|
|
115
|
+
|
|
116
|
+
Need to organize multiple apps and shared packages with code reuse.
|
|
117
|
+
|
|
118
|
+
## Decision
|
|
119
|
+
|
|
120
|
+
Adopt TurboRepo monorepo with apps/ and packages/ structure.
|
|
121
|
+
|
|
122
|
+
## Rationale
|
|
123
|
+
|
|
124
|
+
- Superior build caching (3x faster builds)
|
|
125
|
+
- Parallel task execution
|
|
126
|
+
- Simple configuration
|
|
127
|
+
- Atomic commits across changes
|
|
128
|
+
- Shared dependencies
|
|
129
|
+
|
|
130
|
+
## Alternatives Considered
|
|
131
|
+
|
|
132
|
+
- **Nx**: More features but steeper learning curve
|
|
133
|
+
- **Lerna**: Less active development
|
|
134
|
+
- **Separate repos**: Complex versioning
|
|
135
|
+
|
|
136
|
+
## Implementation
|
|
137
|
+
|
|
138
|
+
\`\`\`
|
|
139
|
+
project/
|
|
140
|
+
├── apps/ # Applications
|
|
141
|
+
├── packages/ # Shared packages
|
|
142
|
+
└── turbo.json # Build pipeline
|
|
143
|
+
\`\`\`
|
|
144
|
+
|
|
145
|
+
## References
|
|
146
|
+
|
|
147
|
+
- [TurboRepo Docs](https://turbo.build)
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Example: Pattern
|
|
151
|
+
|
|
152
|
+
```markdown
|
|
153
|
+
---
|
|
154
|
+
topic: RO-RO Pattern
|
|
155
|
+
category: patterns
|
|
156
|
+
date: 2024-01-20
|
|
157
|
+
tags: [pattern, function-design, maintainability]
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
# RO-RO Pattern (Receive Object, Return Object)
|
|
161
|
+
|
|
162
|
+
## Context
|
|
163
|
+
|
|
164
|
+
Functions with multiple parameters become hard to maintain.
|
|
165
|
+
|
|
166
|
+
## Learning
|
|
167
|
+
|
|
168
|
+
Always use object parameters and return objects.
|
|
169
|
+
|
|
170
|
+
## Rationale
|
|
171
|
+
|
|
172
|
+
- Easy to add parameters without breaking changes
|
|
173
|
+
- Named parameters improve readability
|
|
174
|
+
- Better TypeScript autocomplete
|
|
175
|
+
- Easier to mock in tests
|
|
176
|
+
|
|
177
|
+
## Implementation
|
|
178
|
+
|
|
179
|
+
\`\`\`typescript
|
|
180
|
+
// ❌ Bad
|
|
181
|
+
function create(userId, itemId, quantity, notes) { }
|
|
182
|
+
|
|
183
|
+
// ✅ Good
|
|
184
|
+
interface CreateInput {
|
|
185
|
+
userId: string;
|
|
186
|
+
itemId: string;
|
|
187
|
+
quantity: number;
|
|
188
|
+
notes?: string;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
interface CreateOutput {
|
|
192
|
+
item: Item;
|
|
193
|
+
success: boolean;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function create(input: CreateInput): CreateOutput { }
|
|
197
|
+
\`\`\`
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## Example: Gotcha
|
|
201
|
+
|
|
202
|
+
```markdown
|
|
203
|
+
---
|
|
204
|
+
topic: Shell For Loop Limitation
|
|
205
|
+
category: gotchas
|
|
206
|
+
date: 2024-02-01
|
|
207
|
+
tags: [shell, bash, fish]
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
# Fish Shell For Loop Limitation
|
|
211
|
+
|
|
212
|
+
## Issue
|
|
213
|
+
|
|
214
|
+
Fish shell hangs on bash-style for loops with no error message.
|
|
215
|
+
|
|
216
|
+
## Solution
|
|
217
|
+
|
|
218
|
+
Use alternatives:
|
|
219
|
+
|
|
220
|
+
\`\`\`bash
|
|
221
|
+
# ❌ Don't (hangs in Fish)
|
|
222
|
+
for file in *.md; do echo $file; done
|
|
223
|
+
|
|
224
|
+
# ✅ Do (works everywhere)
|
|
225
|
+
find . -name "*.md" -exec echo {} \;
|
|
226
|
+
\`\`\`
|
|
227
|
+
|
|
228
|
+
## Prevention
|
|
229
|
+
|
|
230
|
+
- Use find -exec for file operations
|
|
231
|
+
- Create bash scripts for complex loops
|
|
232
|
+
- Check shell type before commands
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
## Workflow
|
|
236
|
+
|
|
237
|
+
### 1. Identify Type
|
|
238
|
+
|
|
239
|
+
Choose appropriate category for the learning.
|
|
240
|
+
|
|
241
|
+
### 2. Create File
|
|
242
|
+
|
|
243
|
+
Use configured naming: `{memory_path}/{category}/{date}-{topic-slug}.md`
|
|
244
|
+
|
|
245
|
+
### 3. Write Content
|
|
246
|
+
|
|
247
|
+
Follow template structure with all sections.
|
|
248
|
+
|
|
249
|
+
### 4. Update Index
|
|
250
|
+
|
|
251
|
+
If `auto_index` enabled, index updates automatically. Otherwise:
|
|
252
|
+
|
|
253
|
+
```markdown
|
|
254
|
+
# Memory Index
|
|
255
|
+
|
|
256
|
+
## Architectural Decisions
|
|
257
|
+
|
|
258
|
+
| Date | Topic | Tags |
|
|
259
|
+
|------|-------|------|
|
|
260
|
+
| 2024-01-15 | [Monorepo Structure](arch/2024-01-15-monorepo.md) | monorepo, turborepo |
|
|
261
|
+
|
|
262
|
+
## Patterns
|
|
263
|
+
|
|
264
|
+
| Date | Topic | Tags |
|
|
265
|
+
|------|-------|------|
|
|
266
|
+
| 2024-01-20 | [RO-RO Pattern](patterns/2024-01-20-ro-ro.md) | pattern, functions |
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### 5. Link Related
|
|
270
|
+
|
|
271
|
+
Add cross-references to related memories.
|
|
272
|
+
|
|
273
|
+
## Best Practices
|
|
274
|
+
|
|
275
|
+
| Practice | Description |
|
|
276
|
+
|----------|-------------|
|
|
277
|
+
| **Be Specific** | Capture concrete decisions, not vague thoughts |
|
|
278
|
+
| **Include Context** | Explain when and why this matters |
|
|
279
|
+
| **Provide Examples** | Code examples are invaluable |
|
|
280
|
+
| **Explain Rationale** | Why this over alternatives |
|
|
281
|
+
| **Link Related** | Create knowledge graph |
|
|
282
|
+
| **Use Tags** | Make memories searchable |
|
|
283
|
+
| **Date Everything** | Track when decisions made |
|
|
284
|
+
| **Review Regularly** | Update or archive outdated |
|
|
285
|
+
|
|
286
|
+
## Checklist
|
|
287
|
+
|
|
288
|
+
- [ ] Appropriate category selected
|
|
289
|
+
- [ ] File named correctly with date
|
|
290
|
+
- [ ] All template sections filled
|
|
291
|
+
- [ ] Code examples provided
|
|
292
|
+
- [ ] Rationale clearly explained
|
|
293
|
+
- [ ] Tags added for searchability
|
|
294
|
+
- [ ] Index updated
|
|
295
|
+
- [ ] Related memories linked
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: json-data-auditor
|
|
3
|
+
category: utils
|
|
4
|
+
description: Validate, transform, and audit JSON data for quality, consistency, and schema compliance
|
|
5
|
+
usage: When validating API data, auditing database exports, transforming formats, or ensuring data quality
|
|
6
|
+
input: JSON data, validation schemas, transformation rules, quality criteria
|
|
7
|
+
output: Validation results, transformed data, quality reports, anomaly detection
|
|
8
|
+
config_required:
|
|
9
|
+
- validation_library: "Schema validation library (Zod, Joi, AJV)"
|
|
10
|
+
- quality_threshold: "Minimum data quality score"
|
|
11
|
+
- required_fields: "Fields that must be present"
|
|
12
|
+
- anomaly_sensitivity: "Z-score threshold for outlier detection"
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# JSON Data Auditor
|
|
16
|
+
|
|
17
|
+
## ⚙️ Configuration
|
|
18
|
+
|
|
19
|
+
| Setting | Description | Example |
|
|
20
|
+
|---------|-------------|---------|
|
|
21
|
+
| `validation_library` | Schema validator | `zod`, `joi`, `ajv` |
|
|
22
|
+
| `quality_threshold` | Min quality score | `90` (0-100) |
|
|
23
|
+
| `completeness_target` | Min completeness % | `95` |
|
|
24
|
+
| `anomaly_z_score` | Outlier threshold | `3` (standard deviations) |
|
|
25
|
+
| `max_duplicates` | Max allowed duplicates | `0` |
|
|
26
|
+
| `required_fields` | Must-have fields | `['id', 'email', 'createdAt']` |
|
|
27
|
+
|
|
28
|
+
## Purpose
|
|
29
|
+
|
|
30
|
+
Validate, transform, and audit JSON data for quality, consistency, and schema compliance across APIs and databases.
|
|
31
|
+
|
|
32
|
+
## Capabilities
|
|
33
|
+
|
|
34
|
+
- Schema validation with detailed errors
|
|
35
|
+
- Data quality metrics and scoring
|
|
36
|
+
- Anomaly detection (outliers, nulls)
|
|
37
|
+
- Data transformation and normalization
|
|
38
|
+
- Comprehensive audit reporting
|
|
39
|
+
- Format validation (email, UUID, dates)
|
|
40
|
+
|
|
41
|
+
## Data Analysis
|
|
42
|
+
|
|
43
|
+
### Structure Detection
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
interface DataAnalysis {
|
|
47
|
+
totalRecords: number;
|
|
48
|
+
fields: Record<string, {
|
|
49
|
+
type: string;
|
|
50
|
+
nullable: boolean;
|
|
51
|
+
unique: boolean;
|
|
52
|
+
pattern: string;
|
|
53
|
+
}>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function analyzeJSON(data: unknown[]): DataAnalysis {
|
|
57
|
+
// Detect types, patterns, uniqueness
|
|
58
|
+
// Return structure analysis
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Pattern Recognition
|
|
63
|
+
|
|
64
|
+
| Pattern | Detection |
|
|
65
|
+
|---------|-----------|
|
|
66
|
+
| Email | `/^[^\s@]+@[^\s@]+\.[^\s@]+$/` |
|
|
67
|
+
| UUID | `/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i` |
|
|
68
|
+
| Date | `!isNaN(Date.parse(value))` |
|
|
69
|
+
| Phone | Country-specific patterns |
|
|
70
|
+
|
|
71
|
+
## Schema Validation
|
|
72
|
+
|
|
73
|
+
### With Zod
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
import { z } from 'zod';
|
|
77
|
+
|
|
78
|
+
const schema = z.object({
|
|
79
|
+
id: z.string().uuid(),
|
|
80
|
+
email: z.string().email(),
|
|
81
|
+
createdAt: z.string().datetime(),
|
|
82
|
+
status: z.enum(['active', 'inactive']),
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
interface ValidationResult {
|
|
86
|
+
valid: boolean;
|
|
87
|
+
errors: Array<{ path: string; message: string }>;
|
|
88
|
+
validRecords: number;
|
|
89
|
+
invalidRecords: number;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function validate(data: unknown[], schema: z.ZodSchema): ValidationResult {
|
|
93
|
+
// Validate each record
|
|
94
|
+
// Collect errors with paths
|
|
95
|
+
// Return summary
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Quality Metrics
|
|
100
|
+
|
|
101
|
+
### Completeness
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
// Percentage of complete records (all required fields present)
|
|
105
|
+
completeness = (completeRecords / totalRecords) * 100
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Uniqueness
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
// Percentage of unique values per field
|
|
112
|
+
uniqueness[field] = (uniqueValues / totalValues) * 100
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Validity
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
// Percentage of values matching expected format
|
|
119
|
+
validity[field] = (validValues / totalValues) * 100
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Quality Score
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
score = 100
|
|
126
|
+
- (100 - completeness) * 0.4
|
|
127
|
+
- (100 - validity) * 0.4
|
|
128
|
+
- min(duplicates / 10, 10)
|
|
129
|
+
- min(anomalies / 5, 10)
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Anomaly Detection
|
|
133
|
+
|
|
134
|
+
### Statistical Outliers
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
// Z-score method for numeric fields
|
|
138
|
+
const mean = values.reduce((sum, v) => sum + v, 0) / values.length;
|
|
139
|
+
const variance = values.reduce((sum, v) => sum + (v - mean) ** 2, 0) / values.length;
|
|
140
|
+
const stdDev = Math.sqrt(variance);
|
|
141
|
+
const zScore = Math.abs((value - mean) / stdDev);
|
|
142
|
+
|
|
143
|
+
// Flag if z-score > configured threshold (default: 3)
|
|
144
|
+
if (zScore > config.anomaly_z_score) {
|
|
145
|
+
flagAsAnomaly();
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Null Anomalies
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
// Flag unexpected nulls (field usually not null but <10% nulls)
|
|
153
|
+
const nullPercentage = (nullCount / totalRecords) * 100;
|
|
154
|
+
if (nullPercentage > 0 && nullPercentage < 10) {
|
|
155
|
+
flagAsAnomaly();
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Data Transformation
|
|
160
|
+
|
|
161
|
+
### Field Mapping
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
interface TransformRule {
|
|
165
|
+
source: string;
|
|
166
|
+
target: string;
|
|
167
|
+
transform?: (value: unknown) => unknown;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const rules: TransformRule[] = [
|
|
171
|
+
{ source: 'user_id', target: 'userId' },
|
|
172
|
+
{
|
|
173
|
+
source: 'price',
|
|
174
|
+
target: 'priceInCents',
|
|
175
|
+
transform: (v) => Math.round((v as number) * 100)
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
source: 'created_at',
|
|
179
|
+
target: 'createdAt',
|
|
180
|
+
transform: (v) => new Date(v as string).toISOString()
|
|
181
|
+
}
|
|
182
|
+
];
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Common Transformations
|
|
186
|
+
|
|
187
|
+
```typescript
|
|
188
|
+
// Snake case to camel case
|
|
189
|
+
function snakeToCamel(obj: Record<string, unknown>): Record<string, unknown> {
|
|
190
|
+
return Object.fromEntries(
|
|
191
|
+
Object.entries(obj).map(([key, value]) => [
|
|
192
|
+
key.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase()),
|
|
193
|
+
value
|
|
194
|
+
])
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// Flatten nested objects
|
|
199
|
+
function flatten(obj: Record<string, unknown>, prefix = ''): Record<string, unknown> {
|
|
200
|
+
return Object.entries(obj).reduce((acc, [key, value]) => {
|
|
201
|
+
const newKey = prefix ? `${prefix}.${key}` : key;
|
|
202
|
+
if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
|
|
203
|
+
return { ...acc, ...flatten(value as Record<string, unknown>, newKey) };
|
|
204
|
+
}
|
|
205
|
+
return { ...acc, [newKey]: value };
|
|
206
|
+
}, {});
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## Audit Report
|
|
211
|
+
|
|
212
|
+
```typescript
|
|
213
|
+
interface AuditReport {
|
|
214
|
+
summary: {
|
|
215
|
+
totalRecords: number;
|
|
216
|
+
validRecords: number;
|
|
217
|
+
qualityScore: number;
|
|
218
|
+
};
|
|
219
|
+
validation: {
|
|
220
|
+
errors: ValidationError[];
|
|
221
|
+
};
|
|
222
|
+
quality: {
|
|
223
|
+
completeness: number;
|
|
224
|
+
uniqueness: Record<string, number>;
|
|
225
|
+
validity: Record<string, number>;
|
|
226
|
+
};
|
|
227
|
+
anomalies: Anomaly[];
|
|
228
|
+
recommendations: string[];
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Recommendations
|
|
233
|
+
|
|
234
|
+
Generated based on findings:
|
|
235
|
+
|
|
236
|
+
- Completeness < 95%: "Improve data completeness"
|
|
237
|
+
- Duplicates found: "Remove N duplicate records"
|
|
238
|
+
- Validation errors: "Fix N validation errors"
|
|
239
|
+
- High-severity anomalies: "Investigate N critical anomalies"
|
|
240
|
+
|
|
241
|
+
## Best Practices
|
|
242
|
+
|
|
243
|
+
| Practice | Description |
|
|
244
|
+
|----------|-------------|
|
|
245
|
+
| **Schema First** | Define schemas for all data structures |
|
|
246
|
+
| **Boundary Validation** | Validate at system boundaries (API, DB) |
|
|
247
|
+
| **Track Metrics** | Monitor quality trends over time |
|
|
248
|
+
| **Tune Thresholds** | Adjust anomaly detection for your data |
|
|
249
|
+
| **Preserve Originals** | Never modify source data |
|
|
250
|
+
| **Automate** | Run audits in CI/CD pipeline |
|
|
251
|
+
| **Fix Root Cause** | Address quality at data source |
|
|
252
|
+
|
|
253
|
+
## Usage Example
|
|
254
|
+
|
|
255
|
+
```typescript
|
|
256
|
+
import { auditJSON } from './json-auditor';
|
|
257
|
+
|
|
258
|
+
const data = await fetchData();
|
|
259
|
+
const schema = z.array(recordSchema);
|
|
260
|
+
|
|
261
|
+
const report = await auditJSON(data, {
|
|
262
|
+
schema,
|
|
263
|
+
qualityThreshold: 90,
|
|
264
|
+
requiredFields: ['id', 'email', 'status'],
|
|
265
|
+
anomalyZScore: 3,
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
if (report.summary.qualityScore < 90) {
|
|
269
|
+
console.log('Quality issues found:');
|
|
270
|
+
report.recommendations.forEach(r => console.log(`- ${r}`));
|
|
271
|
+
}
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
## Checklist
|
|
275
|
+
|
|
276
|
+
- [ ] Schema defined for validation
|
|
277
|
+
- [ ] Required fields configured
|
|
278
|
+
- [ ] Quality thresholds set
|
|
279
|
+
- [ ] Anomaly detection tuned
|
|
280
|
+
- [ ] Validation errors addressed
|
|
281
|
+
- [ ] Quality score above threshold
|
|
282
|
+
- [ ] No critical anomalies
|
|
283
|
+
- [ ] Recommendations reviewed
|