rg — Cross-Repository Search
Multi-Repository Search
rg accepts multiple paths as arguments. Combined with shell brace expansion, you search across the entire documentation system in a single invocation — no loops, no scripts. The key is knowing your directory layout and using rg’s path-aware output to identify which repo each match lives in.
rg -l ':description:' ~/atelier/_bibliotheca/domus-{captures,infra-ops,ise-linux,netapi-docs,secrets-ops,docs}/docs/ 2>/dev/null | head -20
Shell brace expansion generates 6 paths before rg runs. rg searches them all in parallel. 2>/dev/null suppresses errors for repos that may not exist locally. This is the foundation pattern — every multi-repo command starts here.
rg --stats 'include::partial' -g '*.adoc' ~/atelier/_bibliotheca/domus-{captures,infra-ops,ise-linux,netapi-docs,secrets-ops}/docs/ 2>&1 | tail -8
--stats appends a summary block: files searched, files with matches, total matches, bytes processed, elapsed time. When searching multiple repos, this gives you aggregate numbers. For per-repo breakdown, run each repo separately or use the JSON approach.
rg -l 'antora\.yml' ~/atelier/_bibliotheca/domus-*/docs/ 2>/dev/null | awk -F'/' '{print $6}' | sort -u
-F'/' splits the path on slashes. Field 6 is the repo directory name (domus-captures, domus-infra-ops, etc.). sort -u deduplicates. Adjust the field number based on your home directory depth — count slashes in your path.
rg -g '*.adoc' -g '!**/partials/**' 'xref:' ~/atelier/_bibliotheca/domus-{captures,infra-ops}/docs/ 2>/dev/null | head -15
-g '*.adoc' includes only AsciiDoc files. -g '!/partials/' excludes partials directories. Glob negation with ! is rg’s include/exclude mechanism — more intuitive than grep’s --include/--exclude-dir pair.
for repo in captures infra-ops ise-linux netapi-docs secrets-ops; do
count=$(rg -c 'include::' -g '*.adoc' ~/atelier/_bibliotheca/domus-${repo}/docs/ 2>/dev/null | awk -F: '{s+=$2} END {print s+0}')
printf "%-20s %d includes\n" "domus-${repo}" "$count"
done
Loop approach when you need per-repo numbers in a formatted table. awk sums the per-file counts from rg -c. The +0 in awk ensures a numeric zero when no matches exist, preventing empty output.
echo "=== DEFINED ==="
rg -n 'ad-dc-ip:' ~/atelier/_bibliotheca/domus-{captures,infra-ops,ise-linux,netapi-docs,secrets-ops}/docs/antora.yml 2>/dev/null
echo ""
echo "=== USED ==="
rg -n '{ad-dc-ip}' -g '*.adoc' ~/atelier/_bibliotheca/domus-{captures,infra-ops,ise-linux,netapi-docs,secrets-ops}/docs/ 2>/dev/null | head -10
Two searches: one for the attribute definition in antora.yml (colon suffix), one for usage in AsciiDoc files (curly braces). Mismatches between definition and usage indicate either missing attributes or unused definitions.
rg -Po 'xref:(\w[\w-]*)::' -g '*.adoc' ~/atelier/_bibliotheca/domus-captures/docs/ --no-filename -r '$1' | sort -u
Extracts the component name from every cross-component xref (the part before ::). Each result should match a valid Antora component. Cross-reference against your antora-playbook.yml sources to find broken refs.
rg -l 'CLAUDE\.md' ~/atelier/_bibliotheca/ --max-depth 2 2>/dev/null
--max-depth 2 limits recursion to avoid descending into deeply nested directories. Without it, rg searches everything — which is fine for content, but slow for structural queries. Increase depth for deeper trees.