cc-md-search-cli 1.0.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,247 @@
1
+ # Documentation Path Configuration Guide
2
+
3
+ ## Overview
4
+
5
+ The CC-MD-Search skill includes **configurable documentation paths** so Claude Code automatically knows where to search your documentation without you having to specify it every time.
6
+
7
+ ## Why Configure the Path?
8
+
9
+ **Before configuration:**
10
+ ```
11
+ You: "How do I set up authentication?"
12
+ Claude Code: "Which directory should I search?"
13
+ You: "./docs"
14
+ Claude Code: [searches and answers]
15
+ ```
16
+
17
+ **After configuration:**
18
+ ```
19
+ You: "How do I set up authentication?"
20
+ Claude Code: [automatically searches ./docs and answers]
21
+ ```
22
+
23
+ ## Configuration Steps
24
+
25
+ ### Step 1: Edit the Skill File
26
+
27
+ Open `skills/SKILL.md` and find the Configuration section at the top:
28
+
29
+ ```bash
30
+ # Current (placeholder)
31
+ DOCS_PATH="./docs"
32
+ ```
33
+
34
+ Change it to your actual documentation path:
35
+
36
+ ```bash
37
+ # Your actual path
38
+ DOCS_PATH="./documentation"
39
+ ```
40
+
41
+ ### Step 2: Copy to Claude Code Skills Directory
42
+
43
+ ```bash
44
+ # Find your Claude Code skills directory
45
+ # Usually: ~/.claude/skills/
46
+
47
+ # Copy the configured skill
48
+ cp skills/SKILL.md ~/.claude/skills/md-search.md
49
+ ```
50
+
51
+ ### Step 3: Verify Configuration
52
+
53
+ ```bash
54
+ # Test that the CLI can find your docs
55
+ ccmds list ./docs
56
+
57
+ # Try a search
58
+ ccmds find "setup" ./docs -l 5
59
+ ```
60
+
61
+ ## Configuration Examples
62
+
63
+ ### Single Documentation Folder
64
+
65
+ ```bash
66
+ DOCS_PATH="./docs"
67
+ ```
68
+
69
+ ### Nested Documentation
70
+
71
+ ```bash
72
+ DOCS_PATH="./documentation/markdown"
73
+ ```
74
+
75
+ ### Project Root
76
+
77
+ ```bash
78
+ DOCS_PATH="."
79
+ ```
80
+
81
+ ### Monorepo Setup
82
+
83
+ ```bash
84
+ # Main docs
85
+ DOCS_PATH="./docs"
86
+
87
+ # Additional paths (optional)
88
+ WEB_DOCS_PATH="./packages/web/docs"
89
+ API_DOCS_PATH="./packages/api/docs"
90
+ ```
91
+
92
+ ## How Claude Code Uses This
93
+
94
+ Once configured, Claude Code will **automatically search** your documentation when you ask questions like:
95
+
96
+ - "How do I set up authentication?" → Searches `./docs`
97
+ - "What's the API for user management?" → Searches `./docs`
98
+ - "Where is the deployment guide?" → Searches `./docs`
99
+ - "How do I configure the database?" → Searches `./docs`
100
+
101
+ **No manual path specification needed!**
102
+
103
+ ## Recommended Documentation Structure
104
+
105
+ Organize your docs for best search results:
106
+
107
+ ```
108
+ docs/
109
+ ├── setup/ # Installation & setup guides
110
+ │ ├── quickstart.md
111
+ │ └── environment.md
112
+ ├── api/ # API documentation
113
+ │ ├── authentication.md
114
+ │ ├── endpoints.md
115
+ │ └── webhooks.md
116
+ ├── guides/ # How-to guides
117
+ │ ├── deployment.md
118
+ │ ├── testing.md
119
+ │ └── configuration.md
120
+ ├── architecture/ # System design docs
121
+ │ ├── overview.md
122
+ │ ├── database.md
123
+ │ └── caching.md
124
+ ├── troubleshooting/ # Common issues
125
+ │ └── faq.md
126
+ └── reference/ # Quick references
127
+ └── env-vars.md
128
+ ```
129
+
130
+ ## Using Frontmatter (Recommended)
131
+
132
+ Add YAML frontmatter to your markdown files for better searchability:
133
+
134
+ ```markdown
135
+ ---
136
+ title: API Authentication Guide
137
+ tags: [api, auth, security, jwt, oauth]
138
+ category: api
139
+ updated: 2025-01-17
140
+ difficulty: intermediate
141
+ ---
142
+
143
+ # API Authentication
144
+
145
+ Your content here...
146
+ ```
147
+
148
+ Benefits:
149
+ - Better fuzzy search results
150
+ - Categorization
151
+ - Date tracking
152
+ - Difficulty levels
153
+ - Related tag matching
154
+
155
+ ## Updating Configuration
156
+
157
+ To change your configured path later:
158
+
159
+ 1. Edit `skills/SKILL.md` and update `DOCS_PATH`
160
+ 2. Re-copy to Claude Code skills directory
161
+ 3. Verify with `ccmds list [new-path]`
162
+
163
+ ## Advanced Configuration
164
+
165
+ ### Multiple Projects
166
+
167
+ If you work on multiple projects, create separate skill files:
168
+
169
+ ```bash
170
+ skills/
171
+ ├── SKILL.md # Default: DOCS_PATH="./docs"
172
+ ├── SKILL-project-a.md # DOCS_PATH="./project-a/docs"
173
+ └── SKILL-project-b.md # DOCS_PATH="./project-b/documentation"
174
+ ```
175
+
176
+ Then copy the appropriate skill to Claude Code's skills directory for each project.
177
+
178
+ ### Project-Specific Paths
179
+
180
+ For projects with multiple doc locations:
181
+
182
+ ```bash
183
+ # Main documentation
184
+ DOCS_PATH="./docs"
185
+
186
+ # Additional paths (reference in queries)
187
+ # Web: ./web-app/README.md, ./web-app/docs
188
+ # API: ./api/docs
189
+ # CMS: ./cms/docs
190
+ ```
191
+
192
+ Claude Code can search these additional locations when specifically asked:
193
+ ```
194
+ "Search the API-specific docs for authentication"
195
+ → ccmds find "authentication" ./api/docs
196
+ ```
197
+
198
+ ## Troubleshooting
199
+
200
+ ### Path Not Found
201
+
202
+ ```bash
203
+ # Check if path exists
204
+ ls ./docs
205
+
206
+ # Check if it contains markdown files
207
+ ccmds list ./docs --count
208
+ ```
209
+
210
+ ### Changes Not Applied
211
+
212
+ ```bash
213
+ # Verify the SKILL.md was updated
214
+ grep "DOCS_PATH" skills/SKILL.md
215
+
216
+ # Should show: DOCS_PATH="./your-configured-path"
217
+ ```
218
+
219
+ ### Claude Code Not Using Configured Path
220
+
221
+ 1. Make sure you copied `skills/SKILL.md` to Claude Code's skills directory
222
+ 2. Restart your Claude Code session
223
+ 3. Verify the path in the skill file is correct
224
+
225
+ ## Configuration Checklist
226
+
227
+ - [ ] Edit `skills/SKILL.md` and set your `DOCS_PATH`
228
+ - [ ] Verify path with `ccmds list ./docs`
229
+ - [ ] Check markdown file count looks correct
230
+ - [ ] Copy `skills/SKILL.md` to Claude Code skills directory
231
+ - [ ] Test with Claude Code: "Find setup documentation"
232
+ - [ ] Confirm Claude Code searches automatically
233
+
234
+ ## Pro Tips
235
+
236
+ 1. **Keep docs organized** - Use subdirectories for different topics
237
+ 2. **Add frontmatter** - Improves search quality significantly
238
+ 3. **Use consistent naming** - Makes files easier to find
239
+ 4. **Regular updates** - Keep documentation current
240
+ 5. **Test searches** - Verify your docs are searchable
241
+ 6. **Add README files** - Each subdirectory should have one
242
+
243
+ ## Related Documentation
244
+
245
+ - **[README.md](./README.md)** - Quick start and command reference
246
+ - **[skills/SKILL.md](./skills/SKILL.md)** - Complete Claude Code skill reference
247
+ - **[skill-template.md](./skill-template.md)** - Template for creating custom configurations
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Bertram Eber
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,224 @@
1
+ # CC-MD-Search-CLI
2
+
3
+ **Claude Code Markdown Search - Efficient documentation search CLI for Claude Code integration**
4
+
5
+ Fast, context-efficient markdown documentation search tool designed for [Claude Code](https://claude.ai/claude-code). Quickly find relevant information across large documentation sets without loading entire files into context.
6
+
7
+ ## Features
8
+
9
+ - **Fuzzy Search** - Find relevant docs even with typos or variations
10
+ - **Pattern/Regex Search** - Exact matches with regex support
11
+ - **Frontmatter Aware** - Parses YAML metadata for better search
12
+ - **Multiple Output Modes** - compact, detailed, files, json
13
+ - **Claude Code Skill** - Pre-built skill template for AI integration
14
+ - **Context Efficient** - Minimize token usage when searching docs
15
+
16
+ ## Installation
17
+
18
+ ### Prerequisites
19
+
20
+ - [Bun](https://bun.sh/) (recommended) or Node.js 18+
21
+ - npm or pnpm
22
+
23
+ ### Install
24
+
25
+ ```bash
26
+ # Clone the repository
27
+ git clone https://github.com/bjeber/cc-md-search-cli.git
28
+ cd cc-md-search-cli
29
+
30
+ # Install dependencies
31
+ bun install
32
+ # or: npm install
33
+
34
+ # Link the CLI globally
35
+ npm link
36
+ ```
37
+
38
+ After linking, the `ccmds` command will be available globally.
39
+
40
+ ## Quick Start
41
+
42
+ ```bash
43
+ # List all markdown files in a directory
44
+ ccmds list ./docs
45
+
46
+ # Fuzzy search for relevant documents
47
+ ccmds find "authentication" ./docs -l 5
48
+
49
+ # Pattern search with regex
50
+ ccmds grep "TODO|FIXME" ./docs -c 3
51
+
52
+ # Show a specific file
53
+ ccmds show ./docs/api/auth.md
54
+ ```
55
+
56
+ ## Commands
57
+
58
+ ### `ccmds find <query> [directory]` - Fuzzy Search
59
+
60
+ Find relevant documents using fuzzy matching. Great for exploratory searches.
61
+
62
+ ```bash
63
+ ccmds find "user authentication" ./docs -l 5 -o compact
64
+ ccmds find "deploy production" ./docs -o files
65
+ ```
66
+
67
+ **Options:**
68
+ - `-l, --limit <number>` - Maximum results (default: 10)
69
+ - `-o, --output <mode>` - Output format: compact, detailed, files, json
70
+
71
+ ### `ccmds grep <pattern> [directory]` - Pattern Search
72
+
73
+ Search for exact text patterns with regex support.
74
+
75
+ ```bash
76
+ ccmds grep "ERROR_[0-9]+" ./docs -c 3
77
+ ccmds grep "GraphQL" ./docs --case-sensitive
78
+ ```
79
+
80
+ **Options:**
81
+ - `-c, --context <lines>` - Lines of context around matches (default: 2)
82
+ - `-s, --case-sensitive` - Case sensitive search
83
+ - `-o, --output <mode>` - Output format
84
+
85
+ ### `ccmds list [directory]` - List Files
86
+
87
+ List all markdown files in a directory.
88
+
89
+ ```bash
90
+ ccmds list ./docs
91
+ ccmds list ./docs --count
92
+ ```
93
+
94
+ **Options:**
95
+ - `-c, --count` - Show only file count
96
+
97
+ ### `ccmds show <file>` - Display File
98
+
99
+ Show the full content of a markdown file.
100
+
101
+ ```bash
102
+ ccmds show ./docs/api/auth.md
103
+ ccmds show ./docs/guide.md --frontmatter-only
104
+ ccmds show ./docs/guide.md --body-only
105
+ ```
106
+
107
+ **Options:**
108
+ - `-f, --frontmatter-only` - Show only YAML frontmatter
109
+ - `-b, --body-only` - Show only body content
110
+
111
+ ## Claude Code Integration
112
+
113
+ To use this tool with Claude Code, install the skill to your Claude Code skills directory.
114
+
115
+ ### 1. Install the Skill
116
+
117
+ ```bash
118
+ # Create the skill directory
119
+ mkdir -p ~/.claude/skills/md-search
120
+
121
+ # Copy the skill file
122
+ cp skills/SKILL.md ~/.claude/skills/md-search/SKILL.md
123
+ ```
124
+
125
+ ### 2. Use with Claude Code
126
+
127
+ Once installed, the skill will be available as `/md-search`. Claude Code can automatically search your documentation when you ask questions:
128
+
129
+ - "How do I set up authentication?"
130
+ - "What are the API endpoints?"
131
+ - "Where is the deployment guide?"
132
+
133
+ Claude will use `ccmds` to search your documentation with minimal context usage.
134
+
135
+ ### 3. Skill Structure
136
+
137
+ The skill follows Claude Code's skill format:
138
+
139
+ ```
140
+ ~/.claude/skills/md-search/
141
+ └── SKILL.md # Skill definition with YAML frontmatter
142
+ ```
143
+
144
+ The SKILL.md includes:
145
+ - **YAML frontmatter** with `name` and `description` for skill registration
146
+ - **Command reference** for all `ccmds` commands
147
+ - **Workflow strategies** for efficient documentation search
148
+ - **Best practices** for context-efficient searches
149
+
150
+ ## Output Modes
151
+
152
+ | Mode | Description | Use Case |
153
+ |------|-------------|----------|
154
+ | `files` | File paths only | Quick overview, piping to other commands |
155
+ | `compact` | Paths + snippets | Default, balanced context |
156
+ | `detailed` | Full context | Deep investigation |
157
+ | `json` | JSON output | Programmatic processing |
158
+
159
+ ## Workflow Tips
160
+
161
+ ### Progressive Search
162
+
163
+ 1. Start broad with `find` to discover relevant docs
164
+ 2. Narrow down with `grep` for specific patterns
165
+ 3. Use `show` to read the exact file you need
166
+
167
+ ```bash
168
+ # Discover
169
+ ccmds find "database" ./docs -o files
170
+
171
+ # Narrow down
172
+ ccmds grep "migration" ./docs/database -c 5
173
+
174
+ # Read specific file
175
+ ccmds show ./docs/database/migrations.md
176
+ ```
177
+
178
+ ### Quick Lookup
179
+
180
+ ```bash
181
+ # Find and show top result
182
+ ccmds find "installation" ./docs -l 1 -o files | xargs ccmds show
183
+ ```
184
+
185
+ ## Documentation Structure (Recommended)
186
+
187
+ For best search results, organize your docs with clear structure:
188
+
189
+ ```
190
+ docs/
191
+ ├── setup/ # Installation & setup
192
+ ├── api/ # API documentation
193
+ ├── guides/ # How-to guides
194
+ ├── architecture/ # System design
195
+ ├── troubleshooting/ # Common issues
196
+ └── reference/ # Quick references
197
+ ```
198
+
199
+ ### Frontmatter
200
+
201
+ Add YAML frontmatter for better search relevance:
202
+
203
+ ```markdown
204
+ ---
205
+ title: API Authentication Guide
206
+ tags: [api, auth, security]
207
+ category: api
208
+ ---
209
+
210
+ # API Authentication
211
+ ...
212
+ ```
213
+
214
+ ## Configuration
215
+
216
+ See [CONFIGURATION.md](./CONFIGURATION.md) for detailed configuration options.
217
+
218
+ ## License
219
+
220
+ MIT License - see [LICENSE](./LICENSE) file.
221
+
222
+ ## Contributing
223
+
224
+ Contributions are welcome! Please open an issue or submit a pull request.
package/bun.lock ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "lockfileVersion": 1,
3
+ "configVersion": 1,
4
+ "workspaces": {
5
+ "": {
6
+ "name": "cc-md-search-cli",
7
+ "dependencies": {
8
+ "commander": "^11.1.0",
9
+ "fuse.js": "^7.0.0",
10
+ "gray-matter": "^4.0.3",
11
+ },
12
+ },
13
+ },
14
+ "packages": {
15
+ "argparse": ["argparse@1.0.10", "", { "dependencies": { "sprintf-js": "~1.0.2" } }, "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg=="],
16
+
17
+ "commander": ["commander@11.1.0", "", {}, "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ=="],
18
+
19
+ "esprima": ["esprima@4.0.1", "", { "bin": { "esparse": "./bin/esparse.js", "esvalidate": "./bin/esvalidate.js" } }, "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A=="],
20
+
21
+ "extend-shallow": ["extend-shallow@2.0.1", "", { "dependencies": { "is-extendable": "^0.1.0" } }, "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug=="],
22
+
23
+ "fuse.js": ["fuse.js@7.1.0", "", {}, "sha512-trLf4SzuuUxfusZADLINj+dE8clK1frKdmqiJNb1Es75fmI5oY6X2mxLVUciLLjxqw/xr72Dhy+lER6dGd02FQ=="],
24
+
25
+ "gray-matter": ["gray-matter@4.0.3", "", { "dependencies": { "js-yaml": "^3.13.1", "kind-of": "^6.0.2", "section-matter": "^1.0.0", "strip-bom-string": "^1.0.0" } }, "sha512-5v6yZd4JK3eMI3FqqCouswVqwugaA9r4dNZB1wwcmrD02QkV5H0y7XBQW8QwQqEaZY1pM9aqORSORhJRdNK44Q=="],
26
+
27
+ "is-extendable": ["is-extendable@0.1.1", "", {}, "sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw=="],
28
+
29
+ "js-yaml": ["js-yaml@3.14.2", "", { "dependencies": { "argparse": "^1.0.7", "esprima": "^4.0.0" }, "bin": { "js-yaml": "bin/js-yaml.js" } }, "sha512-PMSmkqxr106Xa156c2M265Z+FTrPl+oxd/rgOQy2tijQeK5TxQ43psO1ZCwhVOSdnn+RzkzlRz/eY4BgJBYVpg=="],
30
+
31
+ "kind-of": ["kind-of@6.0.3", "", {}, "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw=="],
32
+
33
+ "section-matter": ["section-matter@1.0.0", "", { "dependencies": { "extend-shallow": "^2.0.1", "kind-of": "^6.0.0" } }, "sha512-vfD3pmTzGpufjScBh50YHKzEu2lxBWhVEHsNGoEXmCmn2hKGfeNLYMzCJpe8cD7gqX7TJluOVpBkAequ6dgMmA=="],
34
+
35
+ "sprintf-js": ["sprintf-js@1.0.3", "", {}, "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g=="],
36
+
37
+ "strip-bom-string": ["strip-bom-string@1.0.0", "", {}, "sha512-uCC2VHvQRYu+lMh4My/sFNmF2klFymLX1wHJeXnbEJERpV/ZsVuonzerjfrGpIGF7LBVa1O7i9kjiWvJiFck8g=="],
38
+ }
39
+ }
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "cc-md-search-cli",
3
+ "version": "1.0.0",
4
+ "description": "Claude Code Markdown Search - Efficient documentation search CLI for Claude Code integration",
5
+ "type": "module",
6
+ "bin": {
7
+ "ccmds": "./src/cli.js"
8
+ },
9
+ "scripts": {
10
+ "build": "echo 'No build needed for Bun'",
11
+ "link": "npm link"
12
+ },
13
+ "keywords": [
14
+ "markdown",
15
+ "search",
16
+ "cli",
17
+ "claude-code",
18
+ "documentation",
19
+ "fuzzy-search"
20
+ ],
21
+ "author": "Bertram Eber",
22
+ "license": "MIT",
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "https://github.com/bjeber/cc-md-search-cli.git"
26
+ },
27
+ "homepage": "https://github.com/bjeber/cc-md-search-cli#readme",
28
+ "bugs": {
29
+ "url": "https://github.com/bjeber/cc-md-search-cli/issues"
30
+ },
31
+ "dependencies": {
32
+ "commander": "^11.1.0",
33
+ "gray-matter": "^4.0.3",
34
+ "fuse.js": "^7.0.0"
35
+ }
36
+ }
@@ -0,0 +1,77 @@
1
+ ---
2
+ name: md-search
3
+ description: This skill enables efficient searching of markdown documentation using the ccmds CLI. Use this skill when the user asks about documentation, needs to find information across many markdown files, or wants to discover content without knowing exact file names. Provides fuzzy search, regex pattern matching, and context-efficient output modes.
4
+ ---
5
+
6
+ # Markdown Search CLI Skill - Configuration Template
7
+
8
+ ## ⚙️ CONFIGURATION - EDIT THIS SECTION
9
+
10
+ **IMPORTANT: Set your documentation path here before using this skill:**
11
+
12
+ ```
13
+ DOCS_PATH="./your-docs-folder-here"
14
+ ```
15
+
16
+ Replace `./your-docs-folder-here` with the actual path to your documentation.
17
+
18
+ ### Common Configuration Examples:
19
+
20
+ ```bash
21
+ # Single docs folder:
22
+ DOCS_PATH="./docs"
23
+
24
+ # Project-specific:
25
+ DOCS_PATH="./my-project-docs"
26
+
27
+ # Documentation subfolder:
28
+ DOCS_PATH="./documentation/markdown"
29
+
30
+ # Nested in project:
31
+ DOCS_PATH="./src/docs"
32
+ ```
33
+
34
+ ### Project-Specific Paths (Optional):
35
+
36
+ If you have documentation scattered across multiple locations, you can define additional paths:
37
+
38
+ ```bash
39
+ # Additional paths (optional)
40
+ WEB_DOCS_PATH="./web-app/docs"
41
+ API_DOCS_PATH="./api/docs"
42
+ CMS_DOCS_PATH="./cms/docs"
43
+ ```
44
+
45
+ ### Auto-Search Behavior:
46
+
47
+ When configured, Claude Code will **automatically search** the configured `DOCS_PATH` when the user asks questions about:
48
+ - Setup, installation, configuration
49
+ - API endpoints, usage
50
+ - Architecture, design decisions
51
+ - Troubleshooting, debugging
52
+ - Guides, tutorials, how-tos
53
+ - Any project documentation
54
+
55
+ **No need to ask** - just search immediately using the configured path.
56
+
57
+ ---
58
+
59
+ ## 📋 Quick Start Checklist
60
+
61
+ Before using this skill:
62
+ - [ ] Replace `./your-docs-folder-here` with your actual docs path
63
+ - [ ] Verify the path exists: `ls ./your-docs-folder-here`
64
+ - [ ] Test the search: `ccmds list ./your-docs-folder-here`
65
+ - [ ] (Optional) Configure additional project-specific paths
66
+ - [ ] Save this file to your Claude Code skills directory
67
+
68
+ ---
69
+
70
+ Once configured, see the full SKILL.md file for:
71
+ - Complete command reference
72
+ - Workflow strategies
73
+ - Output mode selection
74
+ - Best practices
75
+ - Example interactions
76
+
77
+ **After configuration, copy the configured DOCS_PATH to the main SKILL.md file.**
@@ -0,0 +1,254 @@
1
+ ---
2
+ name: md-search
3
+ description: This skill enables efficient searching of markdown documentation using the ccmds CLI. Use this skill when the user asks about documentation, needs to find information across many markdown files, or wants to discover content without knowing exact file names. Provides fuzzy search, regex pattern matching, and context-efficient output modes.
4
+ ---
5
+
6
+ # Markdown Search CLI Skill
7
+
8
+ ## Overview
9
+ This skill enables efficient searching of markdown documentation databases using the `ccmds` CLI tool. Use this to find relevant information in large documentation sets without loading entire files into context.
10
+
11
+ ## When to Use
12
+ - User asks about documentation, guides, or references
13
+ - Need to find specific information across many files
14
+ - Want to discover related content without knowing exact file names
15
+ - Need to minimize context usage when working with large doc bases
16
+
17
+ ## Tool: `ccmds`
18
+
19
+ ### Available Commands
20
+
21
+ #### 1. `ccmds find <query> [directory]` - Fuzzy/Semantic Search
22
+ **Use when**: You need to discover relevant documents but don't know exact terms.
23
+
24
+ **Options**:
25
+ - `-l, --limit <number>`: Max results (default: 10)
26
+ - `-o, --output <mode>`: Output format (compact, detailed, files, json)
27
+
28
+ **Examples**:
29
+ ```bash
30
+ # Find docs about authentication
31
+ ccmds find "user authentication" ./docs -l 5 -o compact
32
+
33
+ # Discover deployment guides
34
+ ccmds find "deploy production" ./docs -o files
35
+ ```
36
+
37
+ **Best for**:
38
+ - Exploratory searches
39
+ - Finding related topics
40
+ - When user's question is conceptual
41
+ - Tolerant of typos/variations
42
+
43
+ #### 2. `ccmds grep <pattern> [directory]` - Pattern/Regex Search
44
+ **Use when**: You need exact matches or specific patterns.
45
+
46
+ **Options**:
47
+ - `-c, --context <lines>`: Lines of context (default: 2)
48
+ - `-s, --case-sensitive`: Case sensitive matching
49
+ - `-o, --output <mode>`: Output format
50
+
51
+ **Examples**:
52
+ ```bash
53
+ # Find exact error codes
54
+ ccmds grep "ERROR_[0-9]+" ./docs -c 3
55
+
56
+ # Find all TODO items
57
+ ccmds grep "TODO|FIXME" ./docs -o files
58
+
59
+ # Case-sensitive API search
60
+ ccmds grep "GraphQL" ./docs --case-sensitive
61
+ ```
62
+
63
+ **Best for**:
64
+ - Finding specific terms/codes
65
+ - Regex pattern matching
66
+ - Code snippets or examples
67
+ - Known terminology
68
+
69
+ #### 3. `ccmds list [directory]` - List Files
70
+ **Use when**: You need an overview of available documentation.
71
+
72
+ **Options**:
73
+ - `-c, --count`: Show only count
74
+
75
+ **Examples**:
76
+ ```bash
77
+ # List all markdown files
78
+ ccmds list ./docs
79
+
80
+ # Count files
81
+ ccmds list ./docs --count
82
+ ```
83
+
84
+ #### 4. `ccmds show <file>` - Display File
85
+ **Use when**: You've identified the right file and need full content.
86
+
87
+ **Options**:
88
+ - `-f, --frontmatter-only`: Show only YAML frontmatter
89
+ - `-b, --body-only`: Show only body content
90
+
91
+ **Examples**:
92
+ ```bash
93
+ # Show full file
94
+ ccmds show ./docs/api/auth.md
95
+
96
+ # Show only metadata
97
+ ccmds show ./docs/guides/setup.md --frontmatter-only
98
+ ```
99
+
100
+ ## Workflow Strategies
101
+
102
+ ### Strategy 1: Progressive Search
103
+ 1. Start with `find` to discover relevant docs (compact output)
104
+ 2. Use `grep` on specific files/directories for details
105
+ 3. Use `show` only when you've identified the exact file needed
106
+
107
+ ```bash
108
+ # Step 1: Discover
109
+ ccmds find "database migration" ./docs -o files
110
+
111
+ # Step 2: Narrow down (if needed)
112
+ ccmds grep "migration.*schema" ./docs/database -c 5
113
+
114
+ # Step 3: Read specific file
115
+ ccmds show ./docs/database/migrations.md
116
+ ```
117
+
118
+ ### Strategy 2: Quick Answer
119
+ For simple lookups, combine commands:
120
+
121
+ ```bash
122
+ # Find and show the top result
123
+ ccmds find "installation steps" ./docs -l 1 -o files | xargs ccmds show
124
+ ```
125
+
126
+ ### Strategy 3: Comprehensive Research
127
+ For complex questions requiring multiple sources:
128
+
129
+ ```bash
130
+ # Find all relevant docs
131
+ ccmds find "error handling" ./docs -l 10 -o json > results.json
132
+
133
+ # Then grep for specific patterns across those files
134
+ ccmds grep "catch.*Error" ./docs/api ./docs/guides -o compact
135
+ ```
136
+
137
+ ## Output Mode Selection
138
+
139
+ Choose output mode based on context needs:
140
+
141
+ | Mode | Use Case | Context Size |
142
+ |------|----------|--------------|
143
+ | `files` | Just need file paths | Minimal |
144
+ | `compact` | Quick overview + snippets | Small |
145
+ | `detailed` | Need full context around matches | Medium |
146
+ | `json` | Programmatic processing | Variable |
147
+
148
+ ## Best Practices
149
+
150
+ ### ✅ DO:
151
+ - Start with `find` for broad queries
152
+ - Use `compact` output by default
153
+ - Limit results to stay within context (`-l` flag)
154
+ - Use `files` output when just identifying sources
155
+ - Chain commands for efficiency
156
+ - Search specific subdirectories when possible
157
+
158
+ ### ❌ DON'T:
159
+ - Don't load entire files unless necessary
160
+ - Don't use `detailed` output for many results
161
+ - Don't search everything when topic is localized
162
+ - Don't ignore frontmatter (may contain useful metadata)
163
+ - Don't forget regex special characters need escaping in `grep`
164
+
165
+ ## Example User Interactions
166
+
167
+ ### Example 1: Finding Setup Instructions
168
+ **User**: "How do I set up the development environment?"
169
+
170
+ **Approach**:
171
+ ```bash
172
+ ccmds find "development environment setup" ./docs -l 3 -o compact
173
+ ```
174
+
175
+ ### Example 2: Looking for API Endpoints
176
+ **User**: "What are the authentication endpoints?"
177
+
178
+ **Approach**:
179
+ ```bash
180
+ # First find API docs
181
+ ccmds find "authentication endpoints" ./docs/api -l 5 -o files
182
+
183
+ # Then grep for specific patterns
184
+ ccmds grep "POST|GET.*auth" ./docs/api -c 2
185
+ ```
186
+
187
+ ### Example 3: Finding Error Codes
188
+ **User**: "What does error code E404 mean?"
189
+
190
+ **Approach**:
191
+ ```bash
192
+ ccmds grep "E404" ./docs -c 5 -o compact
193
+ ```
194
+
195
+ ### Example 4: Research Topic
196
+ **User**: "Tell me everything about caching strategies"
197
+
198
+ **Approach**:
199
+ ```bash
200
+ # Discover all caching docs
201
+ ccmds find "caching strategy" ./docs -l 5 -o compact
202
+
203
+ # Review, then show most relevant
204
+ ccmds show ./docs/architecture/caching.md
205
+ ```
206
+
207
+ ## Integration Tips
208
+
209
+ ### For Claude Code Users:
210
+ 1. **Set up alias** in your project directory
211
+ 2. **Document location**: Tell Claude where docs are (`./docs`, `./documentation`, etc.)
212
+ 3. **Use in skill**: Reference this skill in your Claude Code configuration
213
+ 4. **Combine with context**: Use search results to decide what to load fully
214
+
215
+ ### Configuration Example:
216
+ ```json
217
+ {
218
+ "tools": {
219
+ "ccmds": {
220
+ "command": "ccmds",
221
+ "docs_path": "./docs"
222
+ }
223
+ }
224
+ }
225
+ ```
226
+
227
+ ## Performance Notes
228
+
229
+ - **Fast**: Searches hundreds of files in milliseconds
230
+ - **Memory efficient**: Streams file reading
231
+ - **Regex cache**: Pattern compilation is optimized
232
+ - **Fuzzy search**: Fuse.js provides quick relevance scoring
233
+
234
+ ## Troubleshooting
235
+
236
+ **No results found?**
237
+ - Try fuzzy search (`find`) instead of exact (`grep`)
238
+ - Check directory path
239
+ - Verify file extensions (.md or .markdown)
240
+
241
+ **Too many results?**
242
+ - Use `-l` to limit
243
+ - Search in specific subdirectory
244
+ - Make query more specific
245
+ - Use `grep` instead of `find`
246
+
247
+ **Results not relevant?**
248
+ - Use `grep` for exact matches
249
+ - Check frontmatter with `--frontmatter-only`
250
+ - Try different search terms
251
+
252
+ ## Summary
253
+
254
+ The `ccmds` CLI is designed for **efficient documentation search** with **minimal context usage**. Use progressive discovery (`find` → `grep` → `show`) to navigate large doc bases intelligently.
package/src/cli.js ADDED
@@ -0,0 +1,238 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { Command } from 'commander';
4
+ import { readFileSync, readdirSync, statSync } from 'fs';
5
+ import { join, relative } from 'path';
6
+ import matter from 'gray-matter';
7
+ import Fuse from 'fuse.js';
8
+
9
+ const program = new Command();
10
+
11
+ // Recursively find all markdown files
12
+ function findMarkdownFiles(dir, baseDir = dir) {
13
+ let files = [];
14
+ const items = readdirSync(dir);
15
+
16
+ for (const item of items) {
17
+ const fullPath = join(dir, item);
18
+ const stat = statSync(fullPath);
19
+
20
+ if (stat.isDirectory()) {
21
+ files = files.concat(findMarkdownFiles(fullPath, baseDir));
22
+ } else if (item.endsWith('.md') || item.endsWith('.markdown')) {
23
+ files.push({
24
+ path: fullPath,
25
+ relativePath: relative(baseDir, fullPath)
26
+ });
27
+ }
28
+ }
29
+
30
+ return files;
31
+ }
32
+
33
+ // Parse markdown file with frontmatter
34
+ function parseMarkdownFile(filePath) {
35
+ const content = readFileSync(filePath, 'utf-8');
36
+ const { data: frontmatter, content: body } = matter(content);
37
+
38
+ return {
39
+ filePath,
40
+ frontmatter,
41
+ body,
42
+ fullContent: content
43
+ };
44
+ }
45
+
46
+ // Grep-style search
47
+ function grepSearch(files, query, options) {
48
+ const results = [];
49
+ const regex = new RegExp(query, options.caseSensitive ? 'g' : 'gi');
50
+
51
+ for (const file of files) {
52
+ const parsed = parseMarkdownFile(file.path);
53
+ const lines = parsed.body.split('\n');
54
+ const matches = [];
55
+
56
+ lines.forEach((line, index) => {
57
+ if (regex.test(line)) {
58
+ const start = Math.max(0, index - options.context);
59
+ const end = Math.min(lines.length, index + options.context + 1);
60
+
61
+ matches.push({
62
+ lineNumber: index + 1,
63
+ line: line.trim(),
64
+ context: lines.slice(start, end).join('\n')
65
+ });
66
+ }
67
+ });
68
+
69
+ if (matches.length > 0) {
70
+ results.push({
71
+ file: file.relativePath,
72
+ matches,
73
+ frontmatter: parsed.frontmatter
74
+ });
75
+ }
76
+ }
77
+
78
+ return results;
79
+ }
80
+
81
+ // Fuzzy search for finding relevant documents
82
+ function fuzzySearch(files, query, options) {
83
+ const documents = files.map(file => {
84
+ const parsed = parseMarkdownFile(file.path);
85
+ return {
86
+ file: file.relativePath,
87
+ title: parsed.frontmatter.title || file.relativePath,
88
+ body: parsed.body,
89
+ frontmatter: parsed.frontmatter,
90
+ tags: parsed.frontmatter.tags || []
91
+ };
92
+ });
93
+
94
+ const fuse = new Fuse(documents, {
95
+ keys: [
96
+ { name: 'title', weight: 2 },
97
+ { name: 'body', weight: 1 },
98
+ { name: 'tags', weight: 1.5 }
99
+ ],
100
+ threshold: 0.4,
101
+ includeScore: true,
102
+ minMatchCharLength: 2
103
+ });
104
+
105
+ const results = fuse.search(query);
106
+ return results.slice(0, options.limit).map(result => ({
107
+ file: result.item.file,
108
+ score: result.score,
109
+ title: result.item.title,
110
+ frontmatter: result.item.frontmatter,
111
+ preview: result.item.body.substring(0, 200) + '...'
112
+ }));
113
+ }
114
+
115
+ // Format output
116
+ function formatOutput(results, mode) {
117
+ if (mode === 'json') {
118
+ return JSON.stringify(results, null, 2);
119
+ }
120
+
121
+ if (mode === 'files') {
122
+ return results.map(r => r.file).join('\n');
123
+ }
124
+
125
+ if (mode === 'compact') {
126
+ return results.map(r => {
127
+ let output = `\n📄 ${r.file}`;
128
+ if (r.score !== undefined) {
129
+ output += ` (relevance: ${(1 - r.score).toFixed(2)})`;
130
+ }
131
+ if (r.matches) {
132
+ output += `\n ${r.matches.length} match(es)`;
133
+ r.matches.slice(0, 3).forEach(m => {
134
+ output += `\n Line ${m.lineNumber}: ${m.line.substring(0, 80)}`;
135
+ });
136
+ } else if (r.preview) {
137
+ output += `\n ${r.preview}`;
138
+ }
139
+ return output;
140
+ }).join('\n');
141
+ }
142
+
143
+ // Default: detailed
144
+ return results.map(r => {
145
+ let output = `\n${'='.repeat(60)}\n📄 ${r.file}\n${'='.repeat(60)}`;
146
+
147
+ if (r.frontmatter && Object.keys(r.frontmatter).length > 0) {
148
+ output += '\n\nFrontmatter:\n' + JSON.stringify(r.frontmatter, null, 2);
149
+ }
150
+
151
+ if (r.matches) {
152
+ r.matches.forEach(m => {
153
+ output += `\n\n--- Line ${m.lineNumber} ---\n${m.context}`;
154
+ });
155
+ } else if (r.preview) {
156
+ output += `\n\nPreview:\n${r.preview}`;
157
+ }
158
+
159
+ return output;
160
+ }).join('\n');
161
+ }
162
+
163
+ // Main CLI
164
+ program
165
+ .name('ccmds')
166
+ .description('Claude Code Markdown Search - CLI for efficient document querying')
167
+ .version('1.0.0');
168
+
169
+ program
170
+ .command('grep')
171
+ .description('Search for exact text patterns (regex supported)')
172
+ .argument('<query>', 'Search query (regex pattern)')
173
+ .argument('[directory]', 'Directory to search', '.')
174
+ .option('-c, --context <lines>', 'Lines of context around matches', '2')
175
+ .option('-s, --case-sensitive', 'Case sensitive search', false)
176
+ .option('-o, --output <mode>', 'Output mode: detailed, compact, files, json', 'compact')
177
+ .action((query, directory, options) => {
178
+ const files = findMarkdownFiles(directory);
179
+ const results = grepSearch(files, query, {
180
+ context: parseInt(options.context),
181
+ caseSensitive: options.caseSensitive
182
+ });
183
+
184
+ console.log(formatOutput(results, options.output));
185
+ console.log(`\n✓ Found ${results.length} file(s) with matches`);
186
+ });
187
+
188
+ program
189
+ .command('find')
190
+ .description('Fuzzy search for relevant documents')
191
+ .argument('<query>', 'Search query')
192
+ .argument('[directory]', 'Directory to search', '.')
193
+ .option('-l, --limit <number>', 'Maximum results to return', '10')
194
+ .option('-o, --output <mode>', 'Output mode: detailed, compact, files, json', 'compact')
195
+ .action((query, directory, options) => {
196
+ const files = findMarkdownFiles(directory);
197
+ const results = fuzzySearch(files, query, {
198
+ limit: parseInt(options.limit)
199
+ });
200
+
201
+ console.log(formatOutput(results, options.output));
202
+ console.log(`\n✓ Found ${results.length} relevant document(s)`);
203
+ });
204
+
205
+ program
206
+ .command('list')
207
+ .description('List all markdown files')
208
+ .argument('[directory]', 'Directory to search', '.')
209
+ .option('-c, --count', 'Show only count', false)
210
+ .action((directory, options) => {
211
+ const files = findMarkdownFiles(directory);
212
+
213
+ if (options.count) {
214
+ console.log(files.length);
215
+ } else {
216
+ files.forEach(f => console.log(f.relativePath));
217
+ }
218
+ });
219
+
220
+ program
221
+ .command('show')
222
+ .description('Show full content of a markdown file')
223
+ .argument('<file>', 'File path')
224
+ .option('-f, --frontmatter-only', 'Show only frontmatter', false)
225
+ .option('-b, --body-only', 'Show only body content', false)
226
+ .action((file, options) => {
227
+ const parsed = parseMarkdownFile(file);
228
+
229
+ if (options.frontmatterOnly) {
230
+ console.log(JSON.stringify(parsed.frontmatter, null, 2));
231
+ } else if (options.bodyOnly) {
232
+ console.log(parsed.body);
233
+ } else {
234
+ console.log(parsed.fullContent);
235
+ }
236
+ });
237
+
238
+ program.parse();