@getpipher/workspace 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.
@@ -0,0 +1,927 @@
1
+ ---
2
+ name: workspace-organize-docs
3
+ description: Intelligently analyze and organize all .md files in repository (read-only advisor)
4
+ argument-hint: "[--apply] [--dry-run] [--backup] [--config CONFIG_FILE]"
5
+ allowed-tools: ["bash", "read", "write", "edit"]
6
+ ---
7
+
8
+ # Documentation Organization Advisor v2
9
+
10
+ Bismillah! I'll analyze all markdown files in your repository and propose an intelligent organization structure.
11
+
12
+ Arguments provided: $ARGUMENTS
13
+
14
+ ---
15
+
16
+ ## 🛡️ Safety Guarantees
17
+
18
+ **This command is READ-ONLY by default:**
19
+ - ✅ Scans all .md files in repository
20
+ - ✅ Analyzes content and categorizes intelligently
21
+ - ✅ Proposes organization structure
22
+ - ✅ Shows file movement plan with previews
23
+ - ✅ Detects and lists internal link updates needed
24
+ - ❌ **NEVER moves files without explicit confirmation**
25
+ - ❌ **NEVER modifies content automatically**
26
+
27
+ **All operations:**
28
+ - Display proposed changes for review
29
+ - Create backup before any moves (if --apply used)
30
+ - Update internal links after confirmation
31
+ - Preserve git history (uses git mv)
32
+
33
+ ---
34
+
35
+ ## Organization Philosophy
36
+
37
+ ### Flexible Structure Approaches
38
+
39
+ This command supports multiple documentation philosophies:
40
+
41
+ #### 1. **Default Structure** (Tutorial/Documentation-Heavy)
42
+ ```
43
+ repository-root/
44
+ ├── README.md ← Project overview (KEEP IN ROOT)
45
+ ├── AGENTS.md ← AI context file (KEEP IN ROOT; CLAUDE.md is CC's legacy name — keep it too if present)
46
+ ├── LICENSE ← Legal (keep in root)
47
+ ├── CHANGELOG.md ← Version history (keep in root)
48
+ │
49
+ └── docs/ ← ALL other documentation here
50
+ ├── README.md ← Docs index/navigation
51
+ ├── guides/ ← How-to guides and tutorials
52
+ ├── references/ ← API docs, command references
53
+ ├── planning/ ← PRD, execution plans
54
+ ├── technical/ ← Architecture documentation
55
+ └── examples/ ← Example code, tutorials
56
+ ```
57
+
58
+ #### 2. **Divio Documentation System** (Recommended for Libraries/Frameworks)
59
+ ```
60
+ docs/
61
+ ├── README.md
62
+ ├── tutorials/ ← Learning-oriented (getting started)
63
+ ├── how-to/ ← Problem-oriented (specific tasks)
64
+ ├── explanation/ ← Understanding-oriented (concepts)
65
+ └── reference/ ← Information-oriented (technical specs)
66
+ ```
67
+
68
+ #### 3. **Microsoft-Style** (Large Projects)
69
+ ```
70
+ docs/
71
+ ├── README.md
72
+ ├── get-started/ ← Quickstart, installation
73
+ ├── concepts/ ← Core ideas and architecture
74
+ ├── samples/ ← Code examples
75
+ ├── reference/ ← API reference
76
+ └── resources/ ← Additional materials
77
+ ```
78
+
79
+ #### 4. **API-First** (Backend/API Projects)
80
+ ```
81
+ docs/
82
+ ├── README.md
83
+ ├── api/ ← Endpoint documentation
84
+ │ ├── authentication.md
85
+ │ ├── endpoints/
86
+ │ └── schemas/
87
+ ├── deployment/ ← Hosting and deployment
88
+ ├── development/ ← Local setup and contributing
89
+ └── guides/ ← Integration guides
90
+ ```
91
+
92
+ #### 5. **Operations/SRE** (Internal Tools/Infrastructure)
93
+ ```
94
+ docs/
95
+ ├── README.md
96
+ ├── runbooks/ ← Operational procedures
97
+ ├── architecture/ ← System design
98
+ ├── troubleshooting/ ← Common issues
99
+ ├── monitoring/ ← Alerts and dashboards
100
+ └── security/ ← Security policies
101
+ ```
102
+
103
+ ---
104
+
105
+ ## Configuration Support
106
+
107
+ ### Option 1: Auto-Detection (Recommended)
108
+
109
+ If no config file exists, the command will:
110
+ 1. Analyze repository type (language, package files, existing docs)
111
+ 2. Detect project category:
112
+ - Library/Framework → Divio system
113
+ - API/Backend → API-first structure
114
+ - DevOps/Infra → Operations structure
115
+ - Tutorial/Learning → Default structure
116
+ 3. Propose appropriate organization
117
+ 4. Ask for confirmation before categorizing
118
+
119
+ ### Option 2: Configuration File (`.docs-organize.yml`)
120
+
121
+ Create `.docs-organize.yml` in repository root:
122
+
123
+ ```yaml
124
+ # Documentation organization configuration
125
+
126
+ # Choose structure type: default, divio, microsoft, api-first, operations, custom
127
+ structure_type: divio
128
+
129
+ # Files to always keep in repository root (regex patterns)
130
+ keep_in_root:
131
+ - README\.md
132
+ - AGENTS\.md
133
+ - CLAUDE\.md # CC's legacy name — keep too if present
134
+ - CHANGELOG\.md
135
+ - CONTRIBUTING\.md
136
+ - CODE_OF_CONDUCT\.md
137
+ - LICENSE
138
+ - SECURITY\.md
139
+
140
+ # Custom category definitions (only if structure_type: custom)
141
+ categories:
142
+ tutorials:
143
+ keywords: ["tutorial", "getting started", "introduction", "beginner"]
144
+ patterns: ["*tutorial*", "*getting-started*", "*intro*"]
145
+ weight: 0.7
146
+
147
+ how-to:
148
+ keywords: ["how to", "guide", "step by step", "walkthrough"]
149
+ patterns: ["*guide*", "*howto*", "*how-to*"]
150
+ weight: 0.6
151
+
152
+ reference:
153
+ keywords: ["api", "reference", "specification", "documentation"]
154
+ patterns: ["*api*", "*reference*", "*spec*"]
155
+ weight: 0.8
156
+
157
+ # Categorization weights (how to score files)
158
+ categorization:
159
+ filename_weight: 0.6 # Weight for filename pattern matching
160
+ content_weight: 0.3 # Weight for content analysis
161
+ location_weight: 0.1 # Weight for current location context
162
+ min_confidence: 0.5 # Minimum confidence to auto-categorize
163
+
164
+ # Link update behavior
165
+ links:
166
+ update_markdown: true # Update markdown links
167
+ update_html: false # Update HTML <a> tags
168
+ update_images: true # Update image references
169
+ check_external: false # Check external links (slow)
170
+
171
+ # Safety settings
172
+ safety:
173
+ require_git: true # Require git repository
174
+ check_uncommitted: true # Check for uncommitted changes
175
+ create_backup: true # Create backup branch
176
+ backup_prefix: "docs-reorg-backup"
177
+ confirmation_required: true # Require "YES I UNDERSTAND"
178
+
179
+ # Exclusions
180
+ exclude:
181
+ - node_modules
182
+ - vendor
183
+ - .git
184
+ - dist
185
+ - build
186
+ - target
187
+ - __pycache__
188
+ - venv
189
+ - .venv
190
+ ```
191
+
192
+ ### Option 3: Interactive Detection
193
+
194
+ If no config exists and auto-detection is uncertain:
195
+
196
+ ```
197
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
198
+ 🔍 PROJECT TYPE DETECTION
199
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
200
+
201
+ Detected:
202
+ - Language: TypeScript
203
+ - Project: React component library
204
+ - Existing docs: API references, examples
205
+
206
+ Suggested Structure: Divio Documentation System
207
+ ✓ tutorials/ - Getting started guides
208
+ ✓ how-to/ - Specific task instructions
209
+ ✓ explanation/ - Conceptual documentation
210
+ ✓ reference/ - API documentation
211
+
212
+ Does this fit your project? (y/n/suggest alternative):
213
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
214
+ ```
215
+
216
+ ---
217
+
218
+ ## Implementation Process
219
+
220
+ ### Phase 0: Configuration and Detection 🛫
221
+
222
+ #### 0.1: Parse Arguments
223
+ ```bash
224
+ APPLY_CHANGES=false
225
+ DRY_RUN=true
226
+ CREATE_BACKUP=true
227
+ CONFIG_FILE=".docs-organize.yml"
228
+
229
+ for arg in $ARGUMENTS; do
230
+ case $arg in
231
+ --apply)
232
+ APPLY_CHANGES=true
233
+ DRY_RUN=false
234
+ ;;
235
+ --dry-run)
236
+ DRY_RUN=true
237
+ APPLY_CHANGES=false
238
+ ;;
239
+ --backup)
240
+ CREATE_BACKUP=true
241
+ ;;
242
+ --no-backup)
243
+ CREATE_BACKUP=false
244
+ ;;
245
+ --config)
246
+ shift
247
+ CONFIG_FILE="$1"
248
+ ;;
249
+ --config=*)
250
+ CONFIG_FILE="${arg#*=}"
251
+ ;;
252
+ esac
253
+ done
254
+ ```
255
+
256
+ #### 0.2: Load or Generate Configuration
257
+
258
+ **Step 1: Check for existing config**
259
+ ```bash
260
+ if [ -f "$CONFIG_FILE" ]; then
261
+ echo "✅ Found configuration: $CONFIG_FILE"
262
+ # Parse YAML config (use Read tool)
263
+ else
264
+ echo "📋 No configuration found, using auto-detection..."
265
+ # Proceed to project type detection
266
+ fi
267
+ ```
268
+
269
+ **Step 2: Auto-detect project type if no config**
270
+
271
+ Use these heuristics:
272
+ 1. **Check package.json/Cargo.toml/pyproject.toml** - Language and project type
273
+ 2. **Analyze existing docs/** - Current organization patterns
274
+ 3. **Count doc types** - More API docs vs more tutorials
275
+ 4. **Check for patterns**:
276
+ - `openapi.yml` or `swagger.json` → API-first structure
277
+ - `Dockerfile`, `k8s/`, `.github/workflows/` → Operations structure
278
+ - `examples/`, `tutorials/` → Library/learning structure
279
+ - `docs/api/`, `docs/endpoints/` → API structure
280
+
281
+ **Step 3: Present detected structure and confirm**
282
+
283
+ #### 0.3: Repository Validation
284
+
285
+ ```bash
286
+ # Verify git repo
287
+ if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
288
+ if [ "$REQUIRE_GIT" = true ]; then
289
+ echo "❌ Not a git repository (required by config)"
290
+ exit 1
291
+ else
292
+ echo "⚠️ Not a git repository"
293
+ echo ""
294
+ echo "This command uses 'git mv' to preserve file history."
295
+ echo "Recommendation: Initialize git first or proceed with caution."
296
+ echo ""
297
+ read -p "Continue without git? (y/N): " CONTINUE
298
+ if [[ ! "$CONTINUE" =~ ^[Yy]$ ]]; then
299
+ exit 0
300
+ fi
301
+ GIT_AVAILABLE=false
302
+ fi
303
+ else
304
+ GIT_AVAILABLE=true
305
+ fi
306
+
307
+ # Check for uncommitted changes
308
+ if [ "$GIT_AVAILABLE" = true ] && [ "$CHECK_UNCOMMITTED" = true ]; then
309
+ if ! git diff-index --quiet HEAD --; then
310
+ echo "⚠️ Uncommitted changes detected"
311
+ echo ""
312
+ echo "Recommendation: Commit or stash changes before reorganizing."
313
+ echo "This prevents confusion about what changed."
314
+ echo ""
315
+ read -p "Continue anyway? (y/N): " CONTINUE
316
+ if [[ ! "$CONTINUE" =~ ^[Yy]$ ]]; then
317
+ exit 0
318
+ fi
319
+ fi
320
+ fi
321
+ ```
322
+
323
+ ---
324
+
325
+ ### Phase 1: Discovery and Analysis 🔍
326
+
327
+ #### 1.1: Find All Markdown Files
328
+
329
+ ```bash
330
+ echo "📂 Scanning for markdown files..."
331
+
332
+ # Build exclusion patterns from config
333
+ FIND_EXCLUDES=""
334
+ for exclude_dir in "${EXCLUDE_DIRS[@]}"; do
335
+ FIND_EXCLUDES="$FIND_EXCLUDES -not -path \"*/$exclude_dir/*\""
336
+ done
337
+
338
+ # Find all .md files
339
+ ALL_MD_FILES=$(eval "find . -type f -name '*.md' $FIND_EXCLUDES 2>/dev/null | sort")
340
+
341
+ TOTAL_COUNT=$(echo "$ALL_MD_FILES" | wc -l | tr -d ' ')
342
+ echo "Found $TOTAL_COUNT markdown files"
343
+ ```
344
+
345
+ #### 1.2: Categorize by Current Location
346
+
347
+ **Current state analysis:**
348
+
349
+ ```bash
350
+ # Root-level .md files
351
+ ROOT_DOCS=$(echo "$ALL_MD_FILES" | grep "^\\./[^/]*\\.md$")
352
+ ROOT_COUNT=$(echo "$ROOT_DOCS" | grep -c "\\.md$" || echo "0")
353
+
354
+ # Already in docs/
355
+ DOCS_DIR_FILES=$(echo "$ALL_MD_FILES" | grep "^\\./docs/")
356
+ DOCS_COUNT=$(echo "$DOCS_DIR_FILES" | grep -c "\\.md$" || echo "0")
357
+
358
+ # Scattered (outside docs/, not in root)
359
+ SCATTERED=$(echo "$ALL_MD_FILES" | grep -v "^\\./[^/]*\\.md$" | grep -v "^\\./docs/")
360
+ SCATTERED_COUNT=$(echo "$SCATTERED" | grep -c "\\.md$" || echo "0")
361
+
362
+ # Files to keep in root (from config)
363
+ KEEP_IN_ROOT_PATTERN=$(echo "${KEEP_IN_ROOT[@]}" | sed 's/ /|/g')
364
+ KEEP_IN_ROOT=$(echo "$ROOT_DOCS" | grep -E "($KEEP_IN_ROOT_PATTERN)$")
365
+ MOVE_FROM_ROOT=$(echo "$ROOT_DOCS" | grep -v -E "($KEEP_IN_ROOT_PATTERN)$")
366
+ MOVE_FROM_ROOT_COUNT=$(echo "$MOVE_FROM_ROOT" | grep -c "\\.md$" || echo "0")
367
+ ```
368
+
369
+ **Summary:**
370
+ - Total: {TOTAL_COUNT} files
371
+ - In root (keep): {KEEP_COUNT} files
372
+ - In root (should move): {MOVE_FROM_ROOT_COUNT} files
373
+ - In docs/ already: {DOCS_COUNT} files
374
+ - Scattered elsewhere: {SCATTERED_COUNT} files
375
+
376
+ ---
377
+
378
+ #### 1.3: Intelligent Categorization
379
+
380
+ **For each file, analyze using configured weights:**
381
+
382
+ ```python
383
+ # Pseudo-code for categorization logic
384
+
385
+ def categorize_file(file_path, config):
386
+ scores = {}
387
+
388
+ for category_name, category_config in config.categories.items():
389
+ # Filename scoring
390
+ filename_score = match_patterns(file_path, category_config.patterns)
391
+
392
+ # Content scoring (read first 50 lines)
393
+ content = read_file_preview(file_path, lines=50)
394
+ content_score = match_keywords(content, category_config.keywords)
395
+
396
+ # Location scoring
397
+ location_score = match_location_context(file_path, category_config)
398
+
399
+ # Weighted total
400
+ total_score = (
401
+ filename_score * config.categorization.filename_weight +
402
+ content_score * config.categorization.content_weight +
403
+ location_score * config.categorization.location_weight
404
+ ) * category_config.weight
405
+
406
+ scores[category_name] = total_score
407
+
408
+ # Get best match
409
+ best_category = max(scores, key=scores.get)
410
+ confidence = scores[best_category]
411
+
412
+ if confidence >= config.categorization.min_confidence:
413
+ return (best_category, confidence, "High" if confidence > 0.7 else "Medium")
414
+ else:
415
+ return (None, confidence, "Low")
416
+ ```
417
+
418
+ **Confidence levels:**
419
+ - **High** (>0.7): Clear category match (name + content align)
420
+ - **Medium** (0.5-0.7): Category inferred (partial match)
421
+ - **Low** (<0.5): Unclear category (needs manual review)
422
+
423
+ ---
424
+
425
+ ### Phase 2: Proposal Generation 📝
426
+
427
+ #### 2.1: Build Movement Plan
428
+
429
+ **For each file to move:**
430
+ ```
431
+ Source: ./path/to/current/DOC.md
432
+ Destination: docs/category/doc.md
433
+ Reasoning: [category match explanation]
434
+ Confidence: High/Medium/Low
435
+ Categorization:
436
+ - Filename match: 0.8 (matched pattern: *guide*)
437
+ - Content match: 0.6 (keywords: tutorial, how to, step by step)
438
+ - Location match: 0.2 (in scattered location)
439
+ - Total score: 0.68 → Medium confidence
440
+ ```
441
+
442
+ #### 2.2: Detect Conflicts
443
+
444
+ **Check for:**
445
+ - Destination file already exists
446
+ - Name conflicts within category
447
+ - Case-insensitive duplicates
448
+ - Similar names that may confuse
449
+
450
+ **Resolution strategies:**
451
+ - Append suffix: `doc.md` → `doc-v2.md`
452
+ - Merge similar files (with approval)
453
+ - Keep both with descriptive names
454
+
455
+ #### 2.3: Analyze Internal Links
456
+
457
+ **Scan all .md files for links (based on config):**
458
+ - Relative links: `[text](../other.md)`
459
+ - Absolute links: `[text](/docs/file.md)`
460
+ - Reference links: `[text]: other.md`
461
+ - Image links: `![alt](../images/pic.png)` (if update_images: true)
462
+ - HTML links: `<a href="...">` (if update_html: true)
463
+
464
+ **Build link update map:**
465
+ ```
466
+ File: src/component/GUIDE.md (moving to docs/tutorials/component.md)
467
+ Links to update:
468
+ - [Setup](../../SETUP.md) → [Setup](../how-to/setup.md)
469
+ - [API](../api/API.md) → [API](../reference/api.md)
470
+ ```
471
+
472
+ **Link update strategy:**
473
+ - Preserve link targets after file moves
474
+ - Update relative paths accordingly
475
+ - Verify linked files still exist
476
+ - Warn about broken links
477
+
478
+ ---
479
+
480
+ ### Phase 3: Generate Report 📊
481
+
482
+ **Comprehensive reorganization report:**
483
+
484
+ ```
485
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
486
+ 📚 DOCUMENTATION ORGANIZATION ANALYSIS
487
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
488
+
489
+ Repository: example-project
490
+ Structure Type: Divio Documentation System (auto-detected)
491
+ Total Markdown Files: 23
492
+ Analysis: 2025-10-14 10:30 UTC
493
+
494
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
495
+ 📊 CURRENT STATE
496
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
497
+
498
+ Files in root: 5
499
+ ✅ README.md (keep)
500
+ ✅ AGENTS.md (keep)
501
+ ⚠️ INSTALLATION.md (should move)
502
+ ⚠️ TROUBLESHOOTING.md (should move)
503
+ ⚠️ CREDITS.md (should move)
504
+
505
+ Files already in docs/: 3
506
+ ✅ docs/API.md (will reorganize to docs/reference/api.md)
507
+ ✅ docs/SETUP.md (will reorganize to docs/tutorials/setup.md)
508
+ ✅ docs/FAQ.md (will reorganize to docs/explanation/faq.md)
509
+
510
+ Scattered files: 15
511
+ ⚠️ tmux/TMUX_GUIDE.md
512
+ ⚠️ zsh/SHELL_CONFIG.md
513
+ ⚠️ claude/.claude/COMMANDS.md
514
+ ⚠️ scripts/SCRIPTS_README.md
515
+ ... [11 more files]
516
+
517
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
518
+ 🎯 PROPOSED ORGANIZATION (Divio System)
519
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
520
+
521
+ Total moves: 18 files
522
+ Updates needed: 12 internal links
523
+
524
+ 📂 Root (2 files - no changes)
525
+ ✅ README.md
526
+ ✅ AGENTS.md
527
+
528
+ 📂 docs/ (new Divio structure - 18 files)
529
+ │
530
+ ├── 📁 tutorials/ (7 files) - Learning-oriented
531
+ │ ├── getting-started.md ← MOVE: ./INSTALLATION.md
532
+ │ ├── tmux-setup.md ← MOVE: ./tmux/TMUX_GUIDE.md
533
+ │ ├── shell-config.md ← MOVE: ./zsh/SHELL_CONFIG.md
534
+ │ ├── first-steps.md ← MOVE: ./docs/SETUP.md
535
+ │ └── ...
536
+ │
537
+ ├── 📁 how-to/ (4 files) - Problem-oriented
538
+ │ ├── troubleshooting.md ← MOVE: ./TROUBLESHOOTING.md
539
+ │ ├── configure-tmux.md ← MOVE: ./tmux/CONFIG.md
540
+ │ └── ...
541
+ │
542
+ ├── 📁 explanation/ (3 files) - Understanding-oriented
543
+ │ ├── architecture.md ← MOVE: ./ARCHITECTURE.md
544
+ │ ├── faq.md ← MOVE: ./docs/FAQ.md
545
+ │ └── ...
546
+ │
547
+ └── 📁 reference/ (4 files) - Information-oriented
548
+ ├── api.md ← REORGANIZE: ./docs/API.md
549
+ ├── commands.md ← MOVE: ./claude/.claude/COMMANDS.md
550
+ ├── scripts.md ← MOVE: ./scripts/SCRIPTS_README.md
551
+ └── ...
552
+
553
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
554
+ 🔗 INTERNAL LINKS TO UPDATE
555
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
556
+
557
+ 12 files contain links that need updating:
558
+
559
+ 1. README.md
560
+ Current links work, no updates needed ✅
561
+
562
+ 2. INSTALLATION.md → docs/tutorials/getting-started.md
563
+ Links to update:
564
+ - [Troubleshooting](TROUBLESHOOTING.md)
565
+ → [Troubleshooting](../how-to/troubleshooting.md)
566
+ - [Tmux Guide](tmux/TMUX_GUIDE.md)
567
+ → [Tmux Setup](tmux-setup.md)
568
+
569
+ ... [10 more files with link updates]
570
+
571
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
572
+ ⚠️ POTENTIAL ISSUES
573
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
574
+
575
+ 1. 🟡 Low Confidence: scripts/NOTES.md (score: 0.42)
576
+ Category: Unclear (contains mixed content)
577
+ Suggested: docs/explanation/scripts-notes.md
578
+ Recommendation: Review content manually
579
+
580
+ 2. 🟢 Broken Link: INSTALLATION.md links to DEPRECATED.md (file not found)
581
+ Action: Remove link or update after reorganization
582
+
583
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
584
+ 💡 RECOMMENDATIONS
585
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
586
+
587
+ 1. 📋 Create docs/README.md as Navigation Hub
588
+
589
+ 2. 🗂️ Standardize File Naming
590
+ Recommended convention:
591
+ - All lowercase
592
+ - Hyphens for spaces: getting-started.md
593
+ - Descriptive names: tmux-setup.md
594
+
595
+ 3. 🔍 Review Low-Confidence Categorizations
596
+ Files needing manual review: 1
597
+ - scripts/NOTES.md (mixed content)
598
+
599
+ 4. 💾 Save Configuration
600
+ Run: --config .docs-organize.yml --save
601
+ Preserves detected structure for future use
602
+
603
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
604
+ 🚀 NEXT STEPS
605
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
606
+
607
+ Choose an option:
608
+
609
+ 1️⃣ Show Detailed Plan for Specific File
610
+ Example: "Show details for tmux/TMUX_GUIDE.md"
611
+
612
+ 2️⃣ Preview Link Updates
613
+ Show exact link changes for all files
614
+
615
+ 3️⃣ Export This Report
616
+ Save to: docs-reorganization-plan-2025-10-14.md
617
+
618
+ 4️⃣ Save Configuration
619
+ Create .docs-organize.yml with detected settings
620
+
621
+ 5️⃣ Apply Reorganization (with backup)
622
+ Execute the moves and link updates
623
+
624
+ 6️⃣ Apply with Manual Review
625
+ Step-by-step confirmation for each move
626
+
627
+ 7️⃣ Try Different Structure
628
+ Switch to: [default/microsoft/api-first/operations]
629
+
630
+ 8️⃣ Cancel
631
+ No changes will be made
632
+
633
+ Which option? (1-8)
634
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
635
+ ```
636
+
637
+ ---
638
+
639
+ ### Phase 4: Interactive Options
640
+
641
+ [Rest of the implementation remains similar to v1, but with:]
642
+ - Configuration-aware execution
643
+ - Structure-specific categorization
644
+ - Flexible category handling
645
+ - Project-type detection feedback
646
+
647
+ ---
648
+
649
+ ## Generated docs/README.md
650
+
651
+ **Structure-specific navigation hub based on detected type:**
652
+
653
+ ### For Divio Structure:
654
+ ```markdown
655
+ # Documentation
656
+
657
+ Complete documentation for [Project Name] using the [Divio Documentation System](https://documentation.divio.com/).
658
+
659
+ ## 📚 Quick Navigation
660
+
661
+ ### 🎓 Tutorials - *Learning-oriented*
662
+ When you want to learn how to use the project.
663
+
664
+ - [Getting Started](tutorials/getting-started.md)
665
+ - [Your First Project](tutorials/first-project.md)
666
+
667
+ ### 🔧 How-To Guides - *Problem-oriented*
668
+ When you need to solve a specific problem.
669
+
670
+ - [Troubleshooting](how-to/troubleshooting.md)
671
+ - [Configuration](how-to/configuration.md)
672
+
673
+ ### 💡 Explanation - *Understanding-oriented*
674
+ When you want to understand concepts and decisions.
675
+
676
+ - [Architecture](explanation/architecture.md)
677
+ - [Design Decisions](explanation/design-decisions.md)
678
+ - [FAQ](explanation/faq.md)
679
+
680
+ ### 📖 Reference - *Information-oriented*
681
+ When you need technical specifications.
682
+
683
+ - [API Reference](reference/api.md)
684
+ - [CLI Commands](reference/commands.md)
685
+
686
+ ---
687
+
688
+ **Documentation Structure**: Divio Documentation System
689
+ - **Tutorials**: Step-by-step lessons for beginners
690
+ - **How-To Guides**: Recipes for specific tasks
691
+ - **Explanation**: Background and context
692
+ - **Reference**: Technical descriptions
693
+
694
+ Last updated: 2025-10-14
695
+ Generated by: `/docs:organize` command
696
+ ```
697
+
698
+ ### For API-First Structure:
699
+ ```markdown
700
+ # API Documentation
701
+
702
+ Complete API documentation for [Project Name].
703
+
704
+ ## 🚀 Quick Start
705
+
706
+ - [Authentication](api/authentication.md)
707
+ - [Getting Started](get-started/quickstart.md)
708
+
709
+ ## 📡 API Reference
710
+
711
+ ### Core APIs
712
+ - [Users API](api/endpoints/users.md)
713
+ - [Projects API](api/endpoints/projects.md)
714
+
715
+ ### Schemas
716
+ - [Request/Response Schemas](api/schemas/)
717
+
718
+ ## 🛠️ Development
719
+
720
+ - [Local Setup](development/setup.md)
721
+ - [Contributing](development/contributing.md)
722
+
723
+ ## 🚢 Deployment
724
+
725
+ - [Production Deployment](deployment/production.md)
726
+ - [Environment Variables](deployment/configuration.md)
727
+
728
+ ---
729
+
730
+ Last updated: 2025-10-14
731
+ Generated by: `/docs:organize` command
732
+ ```
733
+
734
+ ---
735
+
736
+ ## Advanced Features
737
+
738
+ ### 1. Project Type Auto-Detection
739
+
740
+ **Detection heuristics:**
741
+
742
+ ```python
743
+ def detect_project_type(repo_path):
744
+ indicators = {
745
+ "library": 0,
746
+ "api": 0,
747
+ "operations": 0,
748
+ "learning": 0,
749
+ "application": 0
750
+ }
751
+
752
+ # Check package files
753
+ if exists("package.json"):
754
+ package = read_json("package.json")
755
+ if "library" in package.keywords or package.get("main"):
756
+ indicators["library"] += 3
757
+ if "express" in package.dependencies or "fastify" in package.dependencies:
758
+ indicators["api"] += 3
759
+
760
+ # Check for API indicators
761
+ if exists("openapi.yml") or exists("swagger.json"):
762
+ indicators["api"] += 5
763
+
764
+ # Check for operations indicators
765
+ if exists("Dockerfile") or exists_dir("k8s") or exists_dir(".github/workflows"):
766
+ indicators["operations"] += 3
767
+
768
+ # Check existing docs structure
769
+ if exists_dir("docs/tutorials") or exists_dir("docs/examples"):
770
+ indicators["library"] += 2
771
+ indicators["learning"] += 2
772
+
773
+ if exists_dir("docs/api") or exists_dir("docs/endpoints"):
774
+ indicators["api"] += 4
775
+
776
+ if exists_dir("docs/runbooks") or exists_dir("docs/operations"):
777
+ indicators["operations"] += 4
778
+
779
+ # Return highest scoring type
780
+ return max(indicators, key=indicators.get)
781
+ ```
782
+
783
+ ### 2. Smart Link Detection
784
+
785
+ **Handles various markdown link formats:**
786
+
787
+ ```markdown
788
+ Standard: [text](path/to/file.md)
789
+ Reference: [text][ref]
790
+ Reference def: [ref]: path/to/file.md
791
+ Image: ![alt](path/to/image.png)
792
+ Relative: [text](../../../file.md)
793
+ Anchor: [text](file.md#section)
794
+ HTML: <a href="file.md">text</a>
795
+ ```
796
+
797
+ **Link update algorithm:**
798
+ 1. Parse current file location
799
+ 2. Parse link target location
800
+ 3. Calculate relative path after moves
801
+ 4. Update link in file
802
+ 5. Preserve anchors and query strings
803
+
804
+ ### 3. Conflict Resolution
805
+
806
+ **Strategy for conflicts:**
807
+
808
+ 1. **Same name, different content**
809
+ - Compare file content (diff)
810
+ - Offer: merge, rename, keep both
811
+
812
+ 2. **Similar names**
813
+ - Flag potential confusion
814
+ - Suggest: clarify names
815
+
816
+ 3. **Circular links**
817
+ - Detect and warn
818
+ - Ensure updates don't break
819
+
820
+ ### 4. Configuration Templates
821
+
822
+ **Generate config for common structures:**
823
+
824
+ ```bash
825
+ # Generate configuration template
826
+ /docs:organize --generate-config divio
827
+ /docs:organize --generate-config microsoft
828
+ /docs:organize --generate-config api-first
829
+ ```
830
+
831
+ Creates `.docs-organize.yml` with sensible defaults for chosen structure.
832
+
833
+ ---
834
+
835
+ ## Safety Measures
836
+
837
+ 1. **Backup Branch** - Always create backup before moves
838
+ 2. **Git MV** - Preserve file history
839
+ 3. **Link Validation** - Verify links before and after
840
+ 4. **Rollback Option** - Easy to revert
841
+ 5. **Progress Tracking** - Can resume if interrupted
842
+ 6. **Dry Run Default** - Must explicitly apply
843
+ 7. **Configuration Validation** - Check YAML syntax before running
844
+ 8. **Confirmation Required** - Type "YES I UNDERSTAND" to proceed
845
+
846
+ ---
847
+
848
+ ## Integration with Workflow
849
+
850
+ ✅ **Complements `/planning:sync`:**
851
+ - `/planning:sync` detects scattered docs → suggests `/docs:organize`
852
+ - `/docs:organize` fixes organization → keeps planning docs synced
853
+
854
+ ✅ **Context-File Alignment (AGENTS.md):**
855
+ - "Clarify Before Acting" - Multiple confirmation points
856
+ - Read-only by default - Zero risk without --apply
857
+ - Evidence-based suggestions - Shows reasoning for each categorization
858
+ - Respects existing structure - Preserves intentional organization
859
+
860
+ ✅ **Best Practices:**
861
+ - Run after major documentation additions
862
+ - Use before public releases for professional appearance
863
+ - Integrate into CI/CD for documentation linting
864
+ - Generate config and commit for team consistency
865
+
866
+ ---
867
+
868
+ ## Usage Examples
869
+
870
+ ```bash
871
+ # Dry run with auto-detection (safe, read-only analysis)
872
+ /docs:organize
873
+
874
+ # Dry run with specific config
875
+ /docs:organize --config .docs-organize.yml
876
+
877
+ # Generate configuration template
878
+ /docs:organize --generate-config divio
879
+
880
+ # Apply reorganization (with confirmation)
881
+ /docs:organize --apply
882
+
883
+ # Apply with backup (recommended)
884
+ /docs:organize --apply --backup
885
+
886
+ # Apply without backup (use with caution)
887
+ /docs:organize --apply --no-backup
888
+
889
+ # Try different structure type
890
+ /docs:organize --structure microsoft --dry-run
891
+
892
+ # Export report without applying
893
+ /docs:organize --export docs-plan.md
894
+ ```
895
+
896
+ ---
897
+
898
+ ## Error Handling
899
+
900
+ **Common scenarios:**
901
+
902
+ - **Not a git repo**: Warns, offers to continue without git mv
903
+ - **Uncommitted changes**: Warns, suggests commit first
904
+ - **Conflicts detected**: Shows conflicts, offers resolutions
905
+ - **Broken links**: Lists broken links, suggests fixes
906
+ - **Permission errors**: Reports issues, provides solutions
907
+ - **Invalid YAML config**: Shows syntax errors, line numbers
908
+ - **Low confidence categorization**: Flags for manual review
909
+
910
+ ---
911
+
912
+ ## Comparison: v1 vs v2
913
+
914
+ | Feature | v1 (Original) | v2 (General Abstraction) |
915
+ |---------|---------------|--------------------------|
916
+ | **Structure** | Hard-coded (guides/references/planning) | Configurable + Auto-detect |
917
+ | **Project Types** | Tutorial/docs-heavy only | 5+ structure types supported |
918
+ | **Configuration** | None | YAML config + templates |
919
+ | **Categorization** | Keyword-only | Weighted scoring system |
920
+ | **Keep-in-root** | Hard-coded list | Configurable regex patterns |
921
+ | **Detection** | None | Auto-detect project type |
922
+ | **Flexibility** | Low | High (custom categories) |
923
+ | **Safe for any repo** | Mostly (but opinionated) | Yes (adapts to project) |
924
+
925
+ ---
926
+
927
+ Alhamdulillah! This v2 command brings intelligent, flexible organization to any documentation repository, adapting to your project's needs while maintaining safety and clarity. InshaAllah, it will help you maintain excellent documentation organization across diverse project types! 📚✨