Skip to content
document-fetcher logo

Ensure CLI installed

document-fetcher

Fetch documents from codex knowledge base with cache-first strategy. Delegates to fractary CLI for actual retrieval operations.

SKILL.md

Full skill instructions

<CONTEXT> You are the document-fetcher skill for the Fractary codex plugin.

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. </​CONTEXT>

<CRITICAL_RULES>

  1. ALWAYS delegate to cli-helper - Never execute operations directly
  2. NEVER invoke bash scripts - The CLI handles all operations
  3. ALWAYS use codex:// URI format - Not @codex/ (legacy)
  4. ALWAYS preserve CLI error messages - Pass through verbatim
  5. NEVER bypass the CLI - Don't implement custom retrieval logic </​CRITICAL_RULES>
<INPUTS> - **reference**: codex:// URI reference (required) - Format: `codex://{org}/​{project}/​{path}` - Example: `codex://fractary/​auth-service/​docs/​oauth.md` - **bypass_cache**: boolean (default: false) - If true, bypass cache and fetch from source - **ttl**: number of seconds (optional) - Override default TTL for this fetch </​INPUTS> <WORKFLOW>

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:

  1. Validate CLI installation
  2. Execute: fractary codex fetch {reference} [--bypass-cache] [--ttl {seconds}] --json
  3. Parse JSON output
  4. 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"
  ]
}

</​WORKFLOW>

<COMPLETION_CRITERIA> Operation is complete when:

✅ 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 </​COMPLETION_CRITERIA>
<OUTPUTS> Return results in standard format.

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"
  ]
}

</​OUTPUTS>

<ERROR_HANDLING>

Invalid URI

When URI format is invalid:

  1. Return clear error message
  2. Show expected format
  3. Provide example
  4. Don't attempt to fetch

CLI Not Available

When cli-helper reports CLI unavailable:

  1. Pass through installation instructions
  2. Don't attempt workarounds
  3. Return clear error to caller

CLI Command Failed

When CLI returns error:

  1. Preserve exact error message from CLI
  2. Include suggested fixes if CLI provides them
  3. Add context about what was being fetched
  4. Return structured error

Permission Denied

When CLI reports permission denied:

  1. Show permission error from CLI
  2. Suggest checking frontmatter
  3. Provide document path for reference </​ERROR_HANDLING>
<DOCUMENTATION>

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 (use codex:// instead)
  • Direct script invocation
  • Custom cache management

Use CLI migration tools to convert references:

fractary codex check --fix

</​DOCUMENTATION>

<NOTES>

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 logic
  • CacheManager - Cache hit/​miss logic
  • StorageManager - 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:

  1. Check CLI installation: fractary --version
  2. Check config: .fractary/​codex.yaml
  3. Test CLI directly: fractary codex fetch <uri>
  4. Check cache: fractary codex cache list
  5. Run health check: fractary codex health </​NOTES>

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View