Fetch documents from codex knowledge base with cache-first strategy. Delegates to fractary CLI for actual retrieval operations.
Fetches documents from the codex knowledge base using codex:// URIs. Delegates to the fractary CLI for cache-first retrieval when you reference codex:// documents.
/plugin marketplace add fractary/claude-plugins/plugin install fractary-codex@fractaryThis skill inherits all available tools. When active, it can use any tool Claude has access to.
scripts/cache-lookup.shscripts/cache-store.shscripts/check-permissions.shscripts/github-fetch.shscripts/parse-frontmatter.shscripts/resolve-reference.shscripts/route-source.shworkflow/fetch-with-permissions.mdYour 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. </CONTEXT>
<CRITICAL_RULES>
Check that reference is a valid codex:// URI:
codex://codex://{org}/{project}/{path}../)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
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:
fractary codex fetch {reference} [--bypass-cache] [--ttl {seconds}] --jsonThe 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":
IF status == "failure":
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"
]
}
</WORKFLOW>
<COMPLETION_CRITERIA> Operation is complete when:
✅ For successful fetch:
✅ For failed fetch:
✅ In all cases:
{
"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"
}
}
{
"status": "failure",
"operation": "fetch",
"error": "Invalid URI format",
"provided": "invalid-uri",
"expected": "codex://{org}/{project}/{path}",
"example": "codex://fractary/auth-service/docs/oauth.md"
}
{
"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"
]
}
}
{
"status": "failure",
"operation": "fetch",
"error": "CLI not available",
"suggested_fixes": [
"Install globally: npm install -g @fractary/cli",
"Or ensure npx is available"
]
}
</OUTPUTS>
<ERROR_HANDLING>
When URI format is invalid:
When cli-helper reports CLI unavailable:
When CLI returns error:
When CLI reports permission denied:
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:
This skill no longer supports:
@codex/ prefix (use codex:// instead)Use CLI migration tools to convert references:
fractary codex check --fix
</DOCUMENTATION>
<NOTES>
This skill delegates to:
fractary codex fetch <uri> [--bypass-cache] [--ttl <seconds>] --json
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 permissionsTo 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"
}
If fetch fails:
fractary --version.fractary/codex.yamlfractary codex fetch <uri>fractary codex cache listfractary codex health
</NOTES>