@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.
Files changed (171) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1248 -0
  3. package/dist/bin.cjs +11886 -0
  4. package/dist/bin.cjs.map +1 -0
  5. package/dist/bin.d.cts +1 -0
  6. package/dist/bin.d.ts +1 -0
  7. package/dist/bin.js +11869 -0
  8. package/dist/bin.js.map +1 -0
  9. package/dist/index.cjs +3887 -0
  10. package/dist/index.cjs.map +1 -0
  11. package/dist/index.d.cts +1325 -0
  12. package/dist/index.d.ts +1325 -0
  13. package/dist/index.js +3835 -0
  14. package/dist/index.js.map +1 -0
  15. package/package.json +86 -0
  16. package/templates/.log/notifications.log +1775 -0
  17. package/templates/agents/README.md +164 -0
  18. package/templates/agents/_registry.json +443 -0
  19. package/templates/agents/design/content-writer.md +353 -0
  20. package/templates/agents/design/ux-ui-designer.md +382 -0
  21. package/templates/agents/engineering/astro-engineer.md +293 -0
  22. package/templates/agents/engineering/db-drizzle-engineer.md +360 -0
  23. package/templates/agents/engineering/express-engineer.md +316 -0
  24. package/templates/agents/engineering/fastify-engineer.md +399 -0
  25. package/templates/agents/engineering/hono-engineer.md +263 -0
  26. package/templates/agents/engineering/mongoose-engineer.md +473 -0
  27. package/templates/agents/engineering/nestjs-engineer.md +429 -0
  28. package/templates/agents/engineering/nextjs-engineer.md +451 -0
  29. package/templates/agents/engineering/node-typescript-engineer.md +347 -0
  30. package/templates/agents/engineering/prisma-engineer.md +432 -0
  31. package/templates/agents/engineering/react-senior-dev.md +394 -0
  32. package/templates/agents/engineering/tanstack-start-engineer.md +447 -0
  33. package/templates/agents/engineering/tech-lead.md +269 -0
  34. package/templates/agents/product/product-functional.md +329 -0
  35. package/templates/agents/product/product-technical.md +578 -0
  36. package/templates/agents/quality/debugger.md +514 -0
  37. package/templates/agents/quality/qa-engineer.md +390 -0
  38. package/templates/agents/specialized/enrichment-agent.md +277 -0
  39. package/templates/agents/specialized/i18n-specialist.md +322 -0
  40. package/templates/agents/specialized/seo-ai-specialist.md +387 -0
  41. package/templates/agents/specialized/tech-writer.md +300 -0
  42. package/templates/code-style/.editorconfig +27 -0
  43. package/templates/code-style/.prettierignore +25 -0
  44. package/templates/code-style/.prettierrc +12 -0
  45. package/templates/code-style/biome.json +78 -0
  46. package/templates/code-style/commitlint.config.js +44 -0
  47. package/templates/commands/README.md +175 -0
  48. package/templates/commands/_registry.json +420 -0
  49. package/templates/commands/add-new-entity.md +211 -0
  50. package/templates/commands/audit/accessibility-audit.md +360 -0
  51. package/templates/commands/audit/performance-audit.md +290 -0
  52. package/templates/commands/audit/security-audit.md +231 -0
  53. package/templates/commands/code-check.md +127 -0
  54. package/templates/commands/five-why.md +225 -0
  55. package/templates/commands/formatting/format-markdown.md +197 -0
  56. package/templates/commands/git/commit.md +247 -0
  57. package/templates/commands/meta/create-agent.md +257 -0
  58. package/templates/commands/meta/create-command.md +312 -0
  59. package/templates/commands/meta/create-skill.md +321 -0
  60. package/templates/commands/meta/help.md +318 -0
  61. package/templates/commands/planning/check-completed-tasks.md +224 -0
  62. package/templates/commands/planning/cleanup-issues.md +248 -0
  63. package/templates/commands/planning/planning-cleanup.md +251 -0
  64. package/templates/commands/planning/sync-planning-github.md +133 -0
  65. package/templates/commands/planning/sync-todos-github.md +203 -0
  66. package/templates/commands/quality-check.md +211 -0
  67. package/templates/commands/run-tests.md +159 -0
  68. package/templates/commands/start-feature-plan.md +232 -0
  69. package/templates/commands/start-refactor-plan.md +244 -0
  70. package/templates/commands/sync-planning.md +176 -0
  71. package/templates/commands/update-docs.md +242 -0
  72. package/templates/docs/CHECKPOINT-SYSTEM.md +504 -0
  73. package/templates/docs/INDEX.md +677 -0
  74. package/templates/docs/RECOMMENDED-HOOKS.md +415 -0
  75. package/templates/docs/_registry.json +329 -0
  76. package/templates/docs/diagrams/README.md +220 -0
  77. package/templates/docs/diagrams/agent-hierarchy.mmd +55 -0
  78. package/templates/docs/diagrams/documentation-map.mmd +61 -0
  79. package/templates/docs/diagrams/tools-relationship.mmd +55 -0
  80. package/templates/docs/diagrams/workflow-decision-tree.mmd +38 -0
  81. package/templates/docs/doc-sync.md +533 -0
  82. package/templates/docs/examples/end-to-end-workflow.md +1505 -0
  83. package/templates/docs/glossary.md +495 -0
  84. package/templates/docs/guides/mockup-prompt-engineering.md +644 -0
  85. package/templates/docs/guides/mockup-setup.md +737 -0
  86. package/templates/docs/learnings/README.md +250 -0
  87. package/templates/docs/learnings/common-architectural-patterns.md +123 -0
  88. package/templates/docs/learnings/common-mistakes-to-avoid.md +149 -0
  89. package/templates/docs/learnings/markdown-formatting-standards.md +104 -0
  90. package/templates/docs/learnings/monorepo-command-execution.md +64 -0
  91. package/templates/docs/learnings/optimization-tips.md +146 -0
  92. package/templates/docs/learnings/planning-linear-sync-workflow.md +70 -0
  93. package/templates/docs/learnings/shell-compatibility-fish.md +46 -0
  94. package/templates/docs/learnings/test-organization-structure.md +68 -0
  95. package/templates/docs/mcp-installation.md +613 -0
  96. package/templates/docs/mcp-servers.md +989 -0
  97. package/templates/docs/notification-installation.md +570 -0
  98. package/templates/docs/quick-start.md +354 -0
  99. package/templates/docs/standards/architecture-patterns.md +1064 -0
  100. package/templates/docs/standards/atomic-commits.md +513 -0
  101. package/templates/docs/standards/code-standards.md +993 -0
  102. package/templates/docs/standards/design-standards.md +656 -0
  103. package/templates/docs/standards/documentation-standards.md +1160 -0
  104. package/templates/docs/standards/testing-standards.md +969 -0
  105. package/templates/docs/system-maintenance.md +604 -0
  106. package/templates/docs/templates/PDR-template.md +561 -0
  107. package/templates/docs/templates/TODOs-template.md +534 -0
  108. package/templates/docs/templates/tech-analysis-template.md +800 -0
  109. package/templates/docs/workflows/README.md +519 -0
  110. package/templates/docs/workflows/atomic-task-protocol.md +955 -0
  111. package/templates/docs/workflows/decision-tree.md +482 -0
  112. package/templates/docs/workflows/edge-cases.md +856 -0
  113. package/templates/docs/workflows/phase-1-planning.md +957 -0
  114. package/templates/docs/workflows/phase-2-implementation.md +896 -0
  115. package/templates/docs/workflows/phase-3-validation.md +792 -0
  116. package/templates/docs/workflows/phase-4-finalization.md +927 -0
  117. package/templates/docs/workflows/quick-fix-protocol.md +505 -0
  118. package/templates/docs/workflows/task-atomization.md +537 -0
  119. package/templates/docs/workflows/task-completion-protocol.md +448 -0
  120. package/templates/hooks/on-notification.sh +28 -0
  121. package/templates/schemas/checkpoint.schema.json +97 -0
  122. package/templates/schemas/code-registry.schema.json +84 -0
  123. package/templates/schemas/pdr.schema.json +314 -0
  124. package/templates/schemas/problems.schema.json +55 -0
  125. package/templates/schemas/tech-analysis.schema.json +404 -0
  126. package/templates/schemas/telemetry.schema.json +298 -0
  127. package/templates/schemas/todos.schema.json +234 -0
  128. package/templates/schemas/workflows.schema.json +69 -0
  129. package/templates/scripts/add-changelogs.sh +105 -0
  130. package/templates/scripts/generate-code-registry.ts +270 -0
  131. package/templates/scripts/health-check.sh +343 -0
  132. package/templates/scripts/sync-registry.sh +40 -0
  133. package/templates/scripts/telemetry-report.ts +36 -0
  134. package/templates/scripts/validate-docs.sh +224 -0
  135. package/templates/scripts/validate-registry.sh +225 -0
  136. package/templates/scripts/validate-schemas.ts +283 -0
  137. package/templates/scripts/validate-structure.sh +165 -0
  138. package/templates/scripts/worktree-cleanup.sh +81 -0
  139. package/templates/scripts/worktree-create.sh +63 -0
  140. package/templates/sessions/planning/.gitkeep +0 -0
  141. package/templates/sessions/planning/archived/.gitkeep +0 -0
  142. package/templates/settings.json +202 -0
  143. package/templates/settings.local.json +138 -0
  144. package/templates/skills/README.md +197 -0
  145. package/templates/skills/_registry.json +473 -0
  146. package/templates/skills/audit/accessibility-audit.md +309 -0
  147. package/templates/skills/audit/performance-audit.md +257 -0
  148. package/templates/skills/audit/security-audit.md +217 -0
  149. package/templates/skills/auth/nextauth-patterns.md +308 -0
  150. package/templates/skills/brand-guidelines.md +240 -0
  151. package/templates/skills/documentation/markdown-formatter.md +302 -0
  152. package/templates/skills/git/git-commit-helper.md +321 -0
  153. package/templates/skills/i18n/i18n-patterns.md +251 -0
  154. package/templates/skills/patterns/error-handling-patterns.md +242 -0
  155. package/templates/skills/patterns/tdd-methodology.md +342 -0
  156. package/templates/skills/qa/qa-criteria-validator.md +383 -0
  157. package/templates/skills/qa/web-app-testing.md +398 -0
  158. package/templates/skills/react/react-hook-form-patterns.md +359 -0
  159. package/templates/skills/state/redux-toolkit-patterns.md +272 -0
  160. package/templates/skills/state/tanstack-query-patterns.md +299 -0
  161. package/templates/skills/state/zustand-patterns.md +301 -0
  162. package/templates/skills/tech/mermaid-diagram-specialist.md +195 -0
  163. package/templates/skills/tech/shadcn-specialist.md +252 -0
  164. package/templates/skills/tech/vercel-specialist.md +297 -0
  165. package/templates/skills/testing/api-app-testing.md +254 -0
  166. package/templates/skills/testing/performance-testing.md +275 -0
  167. package/templates/skills/testing/security-testing.md +348 -0
  168. package/templates/skills/utils/add-memory.md +295 -0
  169. package/templates/skills/utils/json-data-auditor.md +283 -0
  170. package/templates/skills/utils/pdf-creator-editor.md +342 -0
  171. package/templates/tools/format-markdown.sh +185 -0
@@ -0,0 +1,342 @@
1
+ ---
2
+ name: pdf-generator
3
+ category: utils
4
+ description: Generate professional PDF documents from data using templates and styling
5
+ usage: When creating invoices, reports, confirmations, contracts, or converting documentation to PDF
6
+ input: Content data, template requirements, styling specifications
7
+ output: Generated PDF files with proper formatting and metadata
8
+ config_required:
9
+ - pdf_library: "PDF generation library (PDFKit, Puppeteer, jsPDF)"
10
+ - default_page_size: "Default page size"
11
+ - margin_size: "Default margins"
12
+ - font_family: "Default font family"
13
+ - brand_colors: "Brand color palette"
14
+ ---
15
+
16
+ # PDF Generator
17
+
18
+ ## âš™ī¸ Configuration
19
+
20
+ | Setting | Description | Example |
21
+ |---------|-------------|---------|
22
+ | `pdf_library` | Generation library | `pdfkit`, `puppeteer`, `jspdf` |
23
+ | `page_size` | Default page size | `A4`, `LETTER` |
24
+ | `margin` | Default margins | `50` (points), `20mm` |
25
+ | `orientation` | Page orientation | `portrait`, `landscape` |
26
+ | `font_family` | Default font | `Helvetica`, `Arial` |
27
+ | `brand_primary` | Primary color | `#3B82F6` |
28
+ | `brand_secondary` | Secondary color | `#10B981` |
29
+
30
+ ## Purpose
31
+
32
+ Generate professional PDF documents for invoices, reports, confirmations, and contracts with proper formatting and styling.
33
+
34
+ ## Capabilities
35
+
36
+ - Generate invoices with calculations
37
+ - Create booking confirmations
38
+ - Produce business reports
39
+ - Convert HTML to PDF
40
+ - Add headers/footers
41
+ - Embed images and logos
42
+ - Apply consistent styling
43
+
44
+ ## Library Selection
45
+
46
+ | Library | Use Case | Pros | Cons |
47
+ |---------|----------|------|------|
48
+ | **PDFKit** | Programmatic PDFs | Simple API, good control | No HTML/CSS |
49
+ | **Puppeteer** | HTML/CSS layouts | Full CSS support | Heavier, needs Chrome |
50
+ | **jsPDF** | Client-side | Browser-based | Limited features |
51
+ | **React-PDF** | React apps | Component-based | Learning curve |
52
+
53
+ ## Setup
54
+
55
+ ### PDFKit
56
+
57
+ ```typescript
58
+ import PDFDocument from 'pdfkit';
59
+
60
+ interface PDFConfig {
61
+ size?: 'A4' | 'LETTER';
62
+ margin?: number;
63
+ layout?: 'portrait' | 'landscape';
64
+ }
65
+
66
+ function createPDF(config: PDFConfig = {}) {
67
+ return new PDFDocument({
68
+ size: config.size || 'A4',
69
+ margin: config.margin || 50,
70
+ layout: config.layout || 'portrait',
71
+ });
72
+ }
73
+ ```
74
+
75
+ ### Puppeteer
76
+
77
+ ```typescript
78
+ import puppeteer from 'puppeteer';
79
+
80
+ async function generatePDFFromHTML(
81
+ html: string,
82
+ options = {}
83
+ ): Promise<Buffer> {
84
+ const browser = await puppeteer.launch({ headless: true });
85
+ const page = await browser.newPage();
86
+ await page.setContent(html, { waitUntil: 'networkidle0' });
87
+
88
+ const pdf = await page.pdf({
89
+ format: 'A4',
90
+ margin: { top: '20mm', right: '20mm', bottom: '20mm', left: '20mm' },
91
+ printBackground: true,
92
+ ...options
93
+ });
94
+
95
+ await browser.close();
96
+ return pdf;
97
+ }
98
+ ```
99
+
100
+ ## Invoice Template
101
+
102
+ ```typescript
103
+ interface InvoiceData {
104
+ invoiceNumber: string;
105
+ date: string;
106
+ from: { name: string; address: string; email: string };
107
+ to: { name: string; address: string; email: string };
108
+ items: Array<{
109
+ description: string;
110
+ quantity: number;
111
+ price: number;
112
+ total: number;
113
+ }>;
114
+ subtotal: number;
115
+ tax: number;
116
+ total: number;
117
+ }
118
+
119
+ function generateInvoice(data: InvoiceData): Promise<Buffer> {
120
+ return new Promise((resolve, reject) => {
121
+ const doc = new PDFDocument({ size: 'A4', margin: 50 });
122
+ const chunks: Buffer[] = [];
123
+
124
+ doc.on('data', chunk => chunks.push(chunk));
125
+ doc.on('end', () => resolve(Buffer.concat(chunks)));
126
+
127
+ // Header
128
+ doc.fontSize(20).text('INVOICE', 50, 50);
129
+ doc.fontSize(10)
130
+ .text(`Invoice #: ${data.invoiceNumber}`, 50, 80)
131
+ .text(`Date: ${data.date}`, 50, 95);
132
+
133
+ // From/To sections
134
+ doc.fontSize(12).text('From:', 50, 140);
135
+ doc.fontSize(10).text(data.from.name, 50, 160);
136
+
137
+ doc.fontSize(12).text('To:', 300, 140);
138
+ doc.fontSize(10).text(data.to.name, 300, 160);
139
+
140
+ // Items table
141
+ let y = 250;
142
+ data.items.forEach(item => {
143
+ doc.text(item.description, 50, y);
144
+ doc.text(item.quantity.toString(), 300, y);
145
+ doc.text(`$${item.total.toFixed(2)}`, 450, y);
146
+ y += 25;
147
+ });
148
+
149
+ // Totals
150
+ y += 20;
151
+ doc.text('Total:', 370, y);
152
+ doc.text(`$${data.total.toFixed(2)}`, 450, y);
153
+
154
+ doc.end();
155
+ });
156
+ }
157
+ ```
158
+
159
+ ## HTML Template (Puppeteer)
160
+
161
+ ```html
162
+ <!DOCTYPE html>
163
+ <html>
164
+ <head>
165
+ <style>
166
+ body {
167
+ font-family: Arial, sans-serif;
168
+ padding: 40px;
169
+ }
170
+ .header {
171
+ background: #3B82F6;
172
+ color: white;
173
+ padding: 30px;
174
+ text-align: center;
175
+ }
176
+ .section {
177
+ margin: 30px 0;
178
+ }
179
+ table {
180
+ width: 100%;
181
+ border-collapse: collapse;
182
+ }
183
+ th {
184
+ background: #3B82F6;
185
+ color: white;
186
+ padding: 12px;
187
+ }
188
+ td {
189
+ padding: 12px;
190
+ border-bottom: 1px solid #E5E7EB;
191
+ }
192
+ .total {
193
+ font-size: 24px;
194
+ color: #3B82F6;
195
+ font-weight: bold;
196
+ }
197
+ </style>
198
+ </head>
199
+ <body>
200
+ <div class="header">
201
+ <h1>INVOICE</h1>
202
+ <p>Invoice #{{invoiceNumber}}</p>
203
+ </div>
204
+
205
+ <div class="section">
206
+ <h2>Bill To</h2>
207
+ <p>{{customer.name}}</p>
208
+ <p>{{customer.address}}</p>
209
+ </div>
210
+
211
+ <table>
212
+ <thead>
213
+ <tr>
214
+ <th>Description</th>
215
+ <th>Quantity</th>
216
+ <th>Price</th>
217
+ <th>Total</th>
218
+ </tr>
219
+ </thead>
220
+ <tbody>
221
+ {{#each items}}
222
+ <tr>
223
+ <td>{{description}}</td>
224
+ <td>{{quantity}}</td>
225
+ <td>${{price}}</td>
226
+ <td>${{total}}</td>
227
+ </tr>
228
+ {{/each}}
229
+ </tbody>
230
+ </table>
231
+
232
+ <div class="total">
233
+ Total: ${{total}}
234
+ </div>
235
+ </body>
236
+ </html>
237
+ ```
238
+
239
+ ## Styling Best Practices
240
+
241
+ | Element | Recommendation |
242
+ |---------|----------------|
243
+ | **Fonts** | Use web-safe fonts or embed custom |
244
+ | **Images** | Optimize before embedding |
245
+ | **Colors** | Use brand colors consistently |
246
+ | **Layout** | Test print layout before finalizing |
247
+ | **Margins** | Standard: 20mm all sides |
248
+ | **Page breaks** | Set explicitly for long content |
249
+ | **Headers/Footers** | Include page numbers |
250
+
251
+ ## Common Patterns
252
+
253
+ ### Confirmation Document
254
+
255
+ ```typescript
256
+ interface Confirmation {
257
+ id: string;
258
+ code: string;
259
+ customerName: string;
260
+ details: Record<string, string>;
261
+ date: string;
262
+ }
263
+
264
+ async function generateConfirmation(data: Confirmation): Promise<Buffer> {
265
+ const html = `
266
+ <div class="header">
267
+ <h1>Confirmation</h1>
268
+ <div class="code">${data.code}</div>
269
+ </div>
270
+ <div class="details">
271
+ <p><strong>Name:</strong> ${data.customerName}</p>
272
+ <p><strong>Date:</strong> ${data.date}</p>
273
+ ${Object.entries(data.details)
274
+ .map(([key, value]) => `<p><strong>${key}:</strong> ${value}</p>`)
275
+ .join('')}
276
+ </div>
277
+ `;
278
+
279
+ return generatePDFFromHTML(html);
280
+ }
281
+ ```
282
+
283
+ ### Report with Charts
284
+
285
+ ```typescript
286
+ async function generateReport(data: ReportData): Promise<Buffer> {
287
+ const html = `
288
+ <h1>Monthly Report</h1>
289
+ <div class="metrics">
290
+ <div class="metric">
291
+ <div class="value">${data.totalSales}</div>
292
+ <div class="label">Total Sales</div>
293
+ </div>
294
+ </div>
295
+ <table>
296
+ <thead><tr><th>Item</th><th>Value</th></tr></thead>
297
+ <tbody>
298
+ ${data.items.map(item => `
299
+ <tr><td>${item.name}</td><td>${item.value}</td></tr>
300
+ `).join('')}
301
+ </tbody>
302
+ </table>
303
+ `;
304
+
305
+ return generatePDFFromHTML(html);
306
+ }
307
+ ```
308
+
309
+ ## Metadata
310
+
311
+ ```typescript
312
+ doc.info = {
313
+ Title: 'Invoice #12345',
314
+ Author: 'Company Name',
315
+ Subject: 'Invoice',
316
+ Keywords: 'invoice, billing',
317
+ CreationDate: new Date(),
318
+ };
319
+ ```
320
+
321
+ ## Best Practices
322
+
323
+ | Practice | Description |
324
+ |----------|-------------|
325
+ | **Templates** | Reuse templates for consistency |
326
+ | **Validation** | Test with various data scenarios |
327
+ | **Compression** | Compress for web delivery |
328
+ | **Metadata** | Set title, author, subject |
329
+ | **Accessibility** | Include proper structure tags |
330
+ | **Testing** | Test on multiple PDF viewers |
331
+ | **File Size** | Optimize images and fonts |
332
+
333
+ ## Checklist
334
+
335
+ - [ ] Library selected appropriately
336
+ - [ ] Template created and tested
337
+ - [ ] Styling matches brand guidelines
338
+ - [ ] All data rendered correctly
339
+ - [ ] Metadata configured
340
+ - [ ] File size optimized
341
+ - [ ] Tested in PDF viewers
342
+ - [ ] Responsive to data variations
@@ -0,0 +1,185 @@
1
+ #!/bin/bash
2
+
3
+ # Markdown Formatter Script - Final working version
4
+ # Fixes markdown formatting issues using reliable shell commands
5
+
6
+ set -euo pipefail
7
+
8
+ # Colors for output
9
+ GREEN='\033[0;32m'
10
+ YELLOW='\033[1;33m'
11
+ RED='\033[0;31m'
12
+ NC='\033[0m' # No Color
13
+
14
+ echo -e "${GREEN}🔧 Markdown Formatter v1.0${NC}"
15
+ echo -e "${GREEN}================================${NC}"
16
+
17
+ # Function to show usage
18
+ show_usage() {
19
+ echo "Usage: $0 [options] [file_or_directory]"
20
+ echo ""
21
+ echo "Options:"
22
+ echo " -h, --help Show this help message"
23
+ echo " -v, --validate-only Validate only, don't fix"
24
+ echo " -r, --rules RULES Comma-separated list of rules (e.g., MD040,MD031)"
25
+ echo " -q, --quiet Quiet mode"
26
+ echo ""
27
+ echo "Examples:"
28
+ echo " $0 # Fix all .md files in .claude/"
29
+ echo " $0 file.md # Fix specific file"
30
+ echo " $0 --validate-only # Check without fixing"
31
+ echo " $0 --rules MD040,MD031,MD022 # Apply specific rules only"
32
+ }
33
+
34
+ # Default options
35
+ VALIDATE_ONLY=false
36
+ QUIET=false
37
+ RULES=""
38
+ TARGET_PATH=""
39
+
40
+ # Parse command line arguments
41
+ while [[ $# -gt 0 ]]; do
42
+ case $1 in
43
+ -h|--help)
44
+ show_usage
45
+ exit 0
46
+ ;;
47
+ -v|--validate-only)
48
+ VALIDATE_ONLY=true
49
+ shift
50
+ ;;
51
+ -r|--rules)
52
+ RULES="$2"
53
+ shift 2
54
+ ;;
55
+ -q|--quiet)
56
+ QUIET=true
57
+ shift
58
+ ;;
59
+ -*)
60
+ echo -e "${RED}Error: Unknown option $1${NC}" >&2
61
+ show_usage >&2
62
+ exit 1
63
+ ;;
64
+ *)
65
+ TARGET_PATH="$1"
66
+ shift
67
+ ;;
68
+ esac
69
+ done
70
+
71
+ # Function to log messages
72
+ log() {
73
+ if [[ "$QUIET" != "true" ]]; then
74
+ echo -e "$1"
75
+ fi
76
+ }
77
+
78
+ # Function to apply markdown fixes to a file
79
+ fix_markdown_file() {
80
+ local file="$1"
81
+ local basename_file=$(basename "$file")
82
+
83
+ log " 📝 Processing: $basename_file"
84
+
85
+ if [[ "$VALIDATE_ONLY" == "true" ]]; then
86
+ # TODO: Add validation logic here
87
+ log " â„šī¸ Validation mode - no changes made"
88
+ return 0
89
+ fi
90
+
91
+ # Create backup
92
+ cp "$file" "${file}.bak"
93
+
94
+ # Apply fixes using sed
95
+ local temp_file="${file}.tmp"
96
+
97
+ # MD040: Add language to bare code fences
98
+ sed 's/^```$/```text/g' "$file" > "$temp_file"
99
+
100
+ # MD026: Remove trailing punctuation from headings
101
+ sed 's/^\(#{1,6}[[:space:]].*\)[.!?:]\+$/\1/g' "$temp_file" > "${temp_file}.2"
102
+
103
+ # MD009: Remove trailing spaces
104
+ sed 's/[[:space:]]\+$//g' "${temp_file}.2" > "${temp_file}.3"
105
+
106
+ # MD012: Remove multiple consecutive blank lines
107
+ sed '/^$/N;/^\n$/d' "${temp_file}.3" > "${temp_file}.4"
108
+
109
+ # Move final result back
110
+ mv "${temp_file}.4" "$file"
111
+
112
+ # Clean up temporary files
113
+ rm -f "$temp_file" "${temp_file}.2" "${temp_file}.3" "${file}.bak"
114
+
115
+ log " ✅ Fixed"
116
+ }
117
+
118
+ # Function to find markdown files
119
+ find_markdown_files() {
120
+ local search_path="$1"
121
+
122
+ if [[ -f "$search_path" ]]; then
123
+ echo "$search_path"
124
+ elif [[ -d "$search_path" ]]; then
125
+ find "$search_path" -name "*.md" -type f
126
+ else
127
+ echo -e "${RED}Error: Path not found: $search_path${NC}" >&2
128
+ exit 1
129
+ fi
130
+ }
131
+
132
+ # Main execution
133
+ main() {
134
+ # Determine target path
135
+ if [[ -z "$TARGET_PATH" ]]; then
136
+ TARGET_PATH=".claude"
137
+ fi
138
+
139
+ log "${GREEN}📋 Finding markdown files...${NC}"
140
+
141
+ # Get list of files to process
142
+ local files
143
+ files=$(find_markdown_files "$TARGET_PATH")
144
+
145
+ if [[ -z "$files" ]]; then
146
+ log "${YELLOW}âš ī¸ No markdown files found${NC}"
147
+ exit 0
148
+ fi
149
+
150
+ local file_count
151
+ file_count=$(echo "$files" | wc -l)
152
+
153
+ log "${GREEN}📊 Found $file_count markdown file(s)${NC}"
154
+ log ""
155
+
156
+ # Process each file
157
+ local processed=0
158
+ local errors=0
159
+
160
+ while IFS= read -r file; do
161
+ if [[ -f "$file" ]]; then
162
+ if fix_markdown_file "$file"; then
163
+ ((processed++))
164
+ else
165
+ log " ${RED}❌ Error processing $file${NC}"
166
+ ((errors++))
167
+ fi
168
+ fi
169
+ done <<< "$files"
170
+
171
+ log ""
172
+ log "${GREEN}📊 Summary:${NC}"
173
+ log " Processed: $processed files"
174
+ if [[ $errors -gt 0 ]]; then
175
+ log " ${RED}Errors: $errors files${NC}"
176
+ exit 1
177
+ else
178
+ log " ${GREEN}✅ All files processed successfully${NC}"
179
+ fi
180
+ }
181
+
182
+ # Run main function
183
+ main
184
+
185
+ echo -e "${GREEN}🎉 Markdown formatting complete!${NC}"