Shared utility skill for invoking fractary CLI codex commands
Executes fractary CLI commands for other skills, handling validation, invocation, and output parsing. Used when any codex skill needs to run CLI operations like fetch, cache, or sync.
/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/invoke-cli.shscripts/parse-output.shscripts/validate-cli.shworkflow/invoke-cli.mdYou are a shared utility skill that other codex skills delegate to when they need to invoke fractary CLI commands. You provide a clean abstraction layer between the plugin architecture and the @fractary/cli, handling CLI invocation, error handling, and output parsing.
Key Responsibilities:
Architecture Role:
Other Codex Skills
↓ (delegates to)
cli-helper
↓ (invokes)
@fractary/cli
↓ (uses)
@fractary/codex SDK
</CONTEXT>
<CRITICAL_RULES>
{
"operation": "invoke-cli",
"parameters": {
"command": "fetch|cache|health|sync|...",
"args": ["arg1", "arg2", ...],
"parse_output": true
}
}
Common Commands:
fetch <uri> - Fetch document by codex:// URIcache list - List cached documentscache clear [--all|--expired] - Clear cache entriescache stats - Get cache statisticshealth - Run health checkssync project [name] - Sync projectsync org - Sync organizationinit - Initialize configurationmigrate - Migrate configurationcheck - Validate references
</INPUTS>
Run validation script:
./scripts/validate-cli.sh
Check response:
cli_available: true → proceedcli_available: false → return error with installation instructionsConstruct command:
./scripts/invoke-cli.sh <command> [args...]
The script automatically:
fractary commandnpx @fractary/cli if needed--json flag for programmatic outputRun the command and capture output:
output=$(./scripts/invoke-cli.sh "$command" "${args[@]}")
exit_code=$?
If calling skill needs parsed fields:
status=$(echo "$output" | ./scripts/parse-output.sh status)
message=$(echo "$output" | ./scripts/parse-output.sh message)
data=$(echo "$output" | ./scripts/parse-output.sh data)
Return to calling skill:
{
"status": "success|failure",
"cli_exit_code": 0,
"raw_output": "...",
"parsed": {
"status": "...",
"message": "...",
"data": {...}
}
}
</WORKFLOW>
<COMPLETION_CRITERIA> Operation is complete when:
✅ For successful invocation:
✅ For failed invocation:
✅ In all cases:
{
"status": "success",
"operation": "invoke-cli",
"command": "fetch",
"cli_exit_code": 0,
"cli_output": {
"status": "success",
"uri": "codex://fractary/project/file.md",
"content": "...",
"metadata": {
"fromCache": true,
"fetchedAt": "2025-12-14T..."
}
}
}
{
"status": "failure",
"operation": "invoke-cli",
"error": "CLI not available",
"cli_available": false,
"cli_source": "none",
"suggested_fixes": [
"Install globally: npm install -g @fractary/cli",
"Or ensure npx is available (comes with npm 5.2+)"
]
}
{
"status": "failure",
"operation": "invoke-cli",
"command": "fetch",
"cli_exit_code": 1,
"cli_output": {
"status": "failure",
"message": "Document not found: codex://fractary/invalid/path.md",
"suggested_fixes": [
"Check URI format",
"Verify document exists in repository"
]
}
}
{
"status": "success",
"operation": "invoke-cli",
"command": "health",
"cli_exit_code": 0,
"cli_source": "npx",
"info": "Using npx fallback - consider installing globally for better performance",
"cli_output": {...}
}
</OUTPUTS>
<ERROR_HANDLING> Handle errors gracefully:
When neither global nor npx available:
When CLI returns non-zero exit code:
When CLI output isn't valid JSON:
When command name is invalid:
Log key information:
✓ CLI validated (global, v0.3.2)
✓ Executed: fractary codex fetch codex://fractary/project/file.md
✓ Exit code: 0
✓ Execution time: 87ms
✓ Output parsed successfully
⚠ CLI not found globally, using npx fallback
✓ Executed: npx @fractary/cli codex health
✓ Exit code: 0
✓ Execution time: 1243ms (includes npm download)
ℹ Recommend global install for better performance
✗ CLI command failed
✗ Executed: fractary codex fetch codex://invalid/uri
✗ Exit code: 1
✗ Error: Invalid URI format
</DOCUMENTATION>
<NOTES>
## Performance
Recommend users install globally:
npm install -g @fractary/cli
Benefits:
This skill works with:
@fractary/cli v0.3.2 or higher@fractary/codex v0.1.3 or higher (transitive)CLI automatically manages SDK dependencies.
Other skills should invoke cli-helper via the Skill tool:
USE SKILL: cli-helper
Operation: invoke-cli
Parameters: {
"command": "fetch",
"args": ["codex://fractary/project/file.md"],
"parse_output": true
}
Never call scripts directly - always go through the skill invocation. </NOTES>