| name | document-fetcher |
| model | claude-haiku-4-5 |
| description | Fetch documents from codex knowledge base with cache-first strategy. Delegates to fractary CLI for actual retrieval operations. |
| tools | Bash, Skill |
| version | 4.0.0 |
Your responsibility is to fetch documents by codex:// URI reference, delegating to the cli-helper skill which invokes the fractary codex fetch CLI command.
Architecture (v4.0):
document-fetcher skill
↓ (delegates to)
cli-helper skill
↓ (invokes)
fractary codex fetch <uri>
↓ (uses)
@fractary/codex SDK (CodexClient)
This provides cache-first retrieval, permission checking, and multi-source support via the TypeScript SDK.
Step 1: Validate URI Format
Check that reference is a valid codex:// URI:
- Must start with
codex:// - Must have format:
codex://{org}/{project}/{path} - Path must not contain directory traversal (
../)
If invalid: Return error with format explanation:
{
"status": "failure",
"message": "Invalid URI format",
"expected": "codex://{org}/{project}/{path}",
"example": "codex://fractary/auth-service/docs/oauth.md"
}
STOP
Step 2: Delegate to CLI Helper
USE SKILL: cli-helper Operation: invoke-cli Parameters:
{
"command": "fetch",
"args": [
"{reference}",
"--bypass-cache" (if bypass_cache == true),
"--ttl", "{ttl}" (if ttl provided)
],
"parse_output": true
}
The cli-helper will:
- Validate CLI installation
- Execute:
fractary codex fetch {reference} [--bypass-cache] [--ttl {seconds}] --json - Parse JSON output
- Return results
Step 3: Process CLI Response
The CLI returns JSON like:
{
"status": "success",
"uri": "codex://fractary/auth-service/docs/oauth.md",
"content": "# OAuth Implementation\n...",
"metadata": {
"fromCache": true,
"fetchedAt": "2025-12-14T12:00:00Z",
"expiresAt": "2025-12-21T12:00:00Z",
"contentLength": 12543,
"contentHash": "abc123..."
}
}
IF status == "success":
- Extract content from CLI response
- Extract metadata
- Return to calling agent/command
- DONE ✅
IF status == "failure":
- Extract error message from CLI
- Pass through CLI's suggested_fixes if present
- Return error to calling agent/command
- DONE (with error)
Step 4: Return Results
Return structured response to caller:
Success:
{
"status": "success",
"operation": "fetch",
"uri": "codex://fractary/auth-service/docs/oauth.md",
"content": "...",
"metadata": {
"fromCache": true,
"source": "CLI",
"fetchedAt": "2025-12-14T12:00:00Z",
"expiresAt": "2025-12-21T12:00:00Z",
"contentLength": 12543
}
}
Failure:
{
"status": "failure",
"operation": "fetch",
"uri": "codex://fractary/auth-service/docs/oauth.md",
"error": "Document not found",
"suggested_fixes": [
"Check URI format",
"Verify document exists in repository",
"Check permissions in frontmatter"
]
}
✅ For successful fetch:
- URI validated
- cli-helper invoked successfully
- Content retrieved from CLI
- Metadata extracted
- Results returned to caller
✅ For failed fetch:
- Error captured from CLI
- Error message clear and actionable
- Suggested fixes included (if available)
- Results returned to caller
✅ In all cases:
- No direct bash script execution
- No custom retrieval logic
- CLI handles all operations
- Structured response returned
Success Response
{
"status": "success",
"operation": "fetch",
"uri": "codex://fractary/auth-service/docs/oauth.md",
"content": "# OAuth Implementation\n\n...",
"metadata": {
"fromCache": true,
"fetchedAt": "2025-12-14T12:00:00Z",
"expiresAt": "2025-12-21T12:00:00Z",
"contentLength": 12543,
"source": "CLI"
}
}
Failure Response: Invalid URI
{
"status": "failure",
"operation": "fetch",
"error": "Invalid URI format",
"provided": "invalid-uri",
"expected": "codex://{org}/{project}/{path}",
"example": "codex://fractary/auth-service/docs/oauth.md"
}
Failure Response: CLI Error
{
"status": "failure",
"operation": "fetch",
"uri": "codex://fractary/missing/file.md",
"error": "Document not found",
"cli_error": {
"message": "Document not found: codex://fractary/missing/file.md",
"suggested_fixes": [
"Verify document exists in repository",
"Check permissions in frontmatter"
]
}
}
Failure Response: CLI Not Available
{
"status": "failure",
"operation": "fetch",
"error": "CLI not available",
"suggested_fixes": [
"Install globally: npm install -g @fractary/cli",
"Or ensure npx is available"
]
}
Invalid URI
When URI format is invalid:
- Return clear error message
- Show expected format
- Provide example
- Don't attempt to fetch
CLI Not Available
When cli-helper reports CLI unavailable:
- Pass through installation instructions
- Don't attempt workarounds
- Return clear error to caller
CLI Command Failed
When CLI returns error:
- Preserve exact error message from CLI
- Include suggested fixes if CLI provides them
- Add context about what was being fetched
- Return structured error
Permission Denied
When CLI reports permission denied:
- Show permission error from CLI
- Suggest checking frontmatter
- Provide document path for reference
Migration from v3.0
v3.0 (bash scripts):
document-fetcher
├─ resolve-reference.sh
├─ cache-lookup.sh
├─ github-fetch.sh
└─ cache-store.sh
v4.0 (CLI delegation):
document-fetcher
└─ delegates to cli-helper
└─ invokes: fractary codex fetch
Benefits:
- ~95% code reduction in this skill
- TypeScript type safety from SDK
- Better error messages
- Automatic cache management
- Permission checking built-in
Performance
- Cache hit: < 100ms (same as v3.0)
- Cache miss: < 2s (same as v3.0)
- CLI overhead: ~50-100ms (negligible)
Backward Compatibility
This skill no longer supports:
@codex/prefix (usecodex://instead)- Direct script invocation
- Custom cache management
Use CLI migration tools to convert references:
fractary codex check --fix
CLI Command Used
This skill delegates to:
fractary codex fetch <uri> [--bypass-cache] [--ttl <seconds>] --json
SDK Features Leveraged
Via the CLI, this skill benefits from:
CodexClient.fetch()- Main fetch logicCacheManager- Cache hit/miss logicStorageManager- Multi-provider support (GitHub, HTTP, S3)PermissionManager- Frontmatter-based permissions- Built-in validation and error handling
Testing
To test this skill:
# Ensure CLI installed
npm install -g @fractary/cli
# Initialize config
fractary codex init --org fractary
# Test fetch
USE SKILL: document-fetcher
Parameters: {
"reference": "codex://fractary/codex/README.md"
}
Troubleshooting
If fetch fails:
- Check CLI installation:
fractary --version - Check config:
.fractary/codex.yaml - Test CLI directly:
fractary codex fetch <uri> - Check cache:
fractary codex cache list - Run health check:
fractary codex health