Skip to content

Commit 718c5c6

Browse files
committed
Add helper script to resolve internal links.
1 parent 5551595 commit 718c5c6

3 files changed

Lines changed: 58 additions & 0 deletions

File tree

.claude/scripts/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Claude Helper Scripts
2+
3+
Utility scripts to support Claude Code when working with this documentation repository.
4+
5+
## resolve-doc-url.sh
6+
7+
Resolves a documentation URL to its source markdown file.
8+
9+
### Usage
10+
11+
```bash
12+
.claude/scripts/resolve-doc-url.sh "/path/to/page/"
13+
```
14+
15+
### Examples
16+
17+
```bash
18+
# Find the file for a specific URL
19+
.claude/scripts/resolve-doc-url.sh "/community-tools/contribute-to-mendix-docs/"
20+
# Output: content/en/docs/community-tools/contribute-to-mendix-docs/_index.md
21+
22+
# Check if a URL exists
23+
.claude/scripts/resolve-doc-url.sh "/some/page/"
24+
# Exit code 0 if found, 1 if not found
25+
```
26+
27+
### Benefits
28+
29+
- **Fast**: Uses grep optimized for file-only output
30+
- **Token-efficient**: Returns only the file path, no surrounding context
31+
- **Reliable**: Matches exact URL in front matter using fixed-string search
32+
33+
### When to Use
34+
35+
- Following cross-references between documentation pages
36+
- Validating internal links
37+
- Finding files by their published URL
38+
- Checking if a URL is already in use

.claude/scripts/resolve-doc-url.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
# Resolve a documentation URL to its source markdown file
3+
# Usage: resolve-doc-url.sh "/path/to/page/"
4+
5+
if [ -z "$1" ]; then
6+
echo "Usage: resolve-doc-url.sh <url>"
7+
echo "Example: resolve-doc-url.sh '/community-tools/contribute-to-mendix-docs/'"
8+
exit 1
9+
fi
10+
11+
# Search for the URL in front matter
12+
# Using grep with -l (files only) and -F (fixed string) for speed
13+
grep -rl --include="*.md" "^url: $1$" content/en/docs/
14+
15+
# Exit code 0 if found, 1 if not found

CLAUDE.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,14 @@ Call tools in parallel for independent operations (reading multiple files, multi
9999
* **Glob** – Use to find files by pattern (e.g., `*.md`, `**/*config*`)
100100
* **Grep** – Use to search file contents for specific text or patterns
101101
* **Write** – Use only for creating new files (prefer Edit for existing files)
102+
* **Helper Scripts** – Use `.claude/scripts/resolve-doc-url.sh` to resolve documentation URLs (e.g., `/path/to/page/`) to their source markdown files. This is faster and more token-efficient than using Grep to search front matter.
102103

103104
### Cross-Reference Verification
104105

106+
When following or verifying documentation links:
107+
* Use `.claude/scripts/resolve-doc-url.sh "/path/to/page/"` to quickly find the source file for a URL
108+
* This is more efficient than Grep for URL-to-file lookups
109+
105110
When modifying URLs or anchor IDs:
106111
1. Use Grep to search for the old URL/anchor across all documentation files
107112
2. Identify all references that need updating

0 commit comments

Comments
 (0)