<CONTEXT>
Initializes the codex plugin by configuring organization, repository, cache, and MCP server.
/plugin marketplace add fractary/claude-plugins/plugin install fractary-codex@fractaryYour role is to guide users through configuration setup for the codex plugin. You parse command arguments and invoke the codex-manager agent with the init operation.
Configuration location: .fractary/codex.yaml (project-level, YAML format - v4.0)
Legacy locations: .fractary/plugins/codex/config.json (deprecated) or ~/.config/fractary/codex/config.json (deprecated)
Cache location: .fractary/plugins/codex/cache/ (ephemeral, gitignored)
MCP server: Installed in .claude/settings.json
You provide a streamlined setup experience with auto-detection, config migration assistance, and sensible defaults. </CONTEXT>
<CRITICAL_RULES> IMPORTANT: ROUTING ONLY
IMPORTANT: USER-FRIENDLY EXPERIENCE
IMPORTANT: NEVER DO WORK
Options:
--org <name>: Specify organization name (auto-detect if omitted)--codex <repo>: Specify codex repository name (prompt if omitted)--yes or -y: Skip confirmations (use defaults)Examples:
/fractary-codex:init
/fractary-codex:init --org fractary --codex codex.fractary.com
/fractary-codex:init --yes
</INPUTS>
<WORKFLOW>
## Step 1: Parse Arguments
Extract options from command:
--org <name> (optional)--codex <repo> (optional)--yes or -y (optional)If --org not specified:
https://github.com/fractary/project.git → "fractary"git@github.com:fractary/project.git → "fractary"Output:
Detected organization: fractary
Is this correct? (Y/n)
If --codex not specified:
codex.* patternOutput:
Found codex repository: codex.fractary.com
Use this repository? (Y/n)
OR
Multiple codex repositories found:
1. codex.fractary.com
2. codex.fractary.ai
Select (1-2):
Use config-helper skill to detect existing configs:
USE SKILL: config-helper with operation="detect"
This returns:
status: "found" or "not_found"format: "json" or "yaml"location: "project" or "global"migration_needed: BooleanIf .fractary/codex.yaml exists:
✅ Configuration already exists!
Location: .fractary/codex.yaml (YAML)
Status: Up to date (v4.0)
Would you like to:
1. Keep existing config (skip initialization)
2. Reconfigure with new settings (backup existing)
3. Validate existing config only
Select (1-3):
For option 1: Exit initialization (nothing to do) For option 2: Backup existing, proceed with steps 5-6 For option 3: Validate only, then exit
If .fractary/plugins/codex/config.json or ~/.config/fractary/codex/config.json exists:
⚠️ Legacy config detected!
Found: {path}
Format: JSON (deprecated)
Location: {project|global}
This config format is deprecated. Migration to YAML recommended.
Would you like to:
1. Migrate settings to YAML and remove old config (recommended)
2. Create fresh YAML config and remove old config
3. Create fresh YAML config but keep old config (not recommended)
4. Cancel initialization
Select (1-4):
For option 1 (recommended):
For option 2:
For option 3:
For option 4:
If no config exists: Proceed to steps 2-3 (auto-detection)
Show what will be created:
Output:
Will create/configure:
✓ Project config: .fractary/codex.yaml (YAML format, v4.0)
✓ Cache directory: .fractary/plugins/codex/cache/
✓ MCP server: .claude/settings.json (mcpServers.fractary-codex)
Configuration:
Organization: {organization}
Codex Repository: {codex_repo}
Format: YAML (CLI compatible)
Version: 4.0
Continue? (Y/n)
Use cli-helper skill to create config via CLI:
USE SKILL: cli-helper
Operation: invoke-cli
Parameters:
{
"command": "init",
"args": [
"--org", "{organization}",
"--codex", "{codex_repo}",
"--format", "yaml",
"--output", ".fractary/codex.yaml"
],
"parse_output": true
}
The CLI will:
.fractary/codex.yamlAfter CLI creates config, invoke codex-manager for additional setup:
Use the @agent-fractary-codex:codex-manager agent with the following request:
{
"operation": "post-init-setup",
"parameters": {
"setup_cache": true,
"install_mcp": true,
"config_path": ".fractary/codex.yaml"
}
}
The agent will:
.fractary/plugins/codex/cache/
scripts/setup-cache-dir.sh.gitignore and .cache-index.json.gitignore.claude/settings.json
scripts/install-mcp.shmcpServers.fractary-codex configurationShow the results to the user, which includes:
Example output:
✅ Codex plugin initialized successfully!
Created:
- Project config: .fractary/codex.yaml (YAML, v4.0)
- Cache directory: .fractary/plugins/codex/cache/
- MCP server: .claude/settings.json (fractary-codex)
Configuration:
Organization: fractary
Codex Repository: codex.fractary.com
Format: YAML (CLI compatible)
Version: 4.0
Cache TTL: 7 days
Next steps:
1. Restart Claude Code to load the MCP server
2. Review and customize: cat .fractary/codex.yaml
3. Validate setup: fractary codex health
4. Run first sync: /fractary-codex:sync-project --dry-run
5. Use codex:// URIs to reference documents
CLI Commands:
- fractary codex health # Validate setup
- fractary codex cache list # View cache
- fractary codex sync project --dry-run # Preview sync
If migrated from JSON:
✅ Configuration migrated and initialized!
Migrated:
From: .fractary/plugins/codex/config.json (JSON, v3.0)
To: .fractary/codex.yaml (YAML, v4.0)
Status: Settings preserved, format updated
Created:
- Cache directory: .fractary/plugins/codex/cache/
- MCP server: .claude/settings.json (fractary-codex)
Configuration:
Organization: fractary
Codex Repository: codex.fractary.com
Format: YAML (CLI compatible)
Version: 4.0
Next steps:
1. Restart Claude Code to load the MCP server
2. Review new config: cat .fractary/codex.yaml
3. Test setup: fractary codex health
4. Remove old config (optional): rm .fractary/plugins/codex/config.json
</WORKFLOW>
<COMPLETION_CRITERIA> This command is complete when:
✅ For successful init:
✅ For failed init:
✅ For user cancellation:
Display the agent's success response, which shows:
Display error from agent with:
Display:
Initialization cancelled. No changes made.
Run /fractary-codex:init again when ready.
</OUTPUTS>
<ERROR_HANDLING> <INVALID_ARGUMENTS> If argument parsing fails:
<AUTO_DETECTION_FAILED> If organization auto-detection fails:
<CODEX_REPO_NOT_FOUND> If codex repository can't be found:
<AGENT_FAILURE> If codex-manager agent fails:
What was created:
.fractary/codex.yaml (YAML format, v4.0).fractary/plugins/codex/cache/.claude/settings.jsonHow to customize:
Project config: .fractary/codex.yaml
organization: Organization namecodex_repo: Codex repository nameproject_name: Current project name (for URI resolution)sync_patterns: Glob patterns to include (e.g., "docs/**", "CLAUDE.md")exclude_patterns: Glob patterns to exclude (e.g., "/.git/", "/node_modules/")sync_direction: "to-codex" | "from-codex" | "bidirectional"environments: Environment-to-branch mappings for codex repository
dev.branch: Branch for dev environment (default: "test")test.branch: Branch for test environment (default: "test")staging.branch: Branch for staging environment (default: "main")prod.branch: Branch for production environment (default: "main")cache.default_ttl: Cache TTL in seconds (default: 604800 = 7 days)cache.offline_mode: Enable offline mode (default: false)cache.fallback_to_stale: Use stale content when network fails (default: true)auth.default: Authentication mode ("inherit" = use git config)auth.fallback_to_public: Try unauthenticated if auth fails (default: true)sources.<org>: Per-source TTL and authentication overridesEnvironment configuration: By default, sync operations auto-detect the target environment based on your current branch:
test environment (syncs to "test" branch in codex)prod environment (syncs to "main" branch in codex, with confirmation)Override with explicit --env flag:
/fractary-codex:sync-project --env prod # Explicit, no confirmation
To disable separate test environment (all syncs go to main):
"environments": {
"test": { "branch": "main" },
"prod": { "branch": "main" }
}
Frontmatter (per-file control): Add to markdown/YAML files
---
codex_sync_include: ["pattern1", "pattern2"]
codex_sync_exclude: ["pattern1", "pattern2"]
---
Configuration schema: See .claude-plugin/config.schema.json for all options
Using codex:// URIs:
codex://org/project/path/to/file.mdcodex://fractary/current-repo/docs/guide.mdcodex://fractary/other-repo/README.mdSee [Guide](codex://fractary/project/docs/guide.md)Next steps:
/fractary-codex:sync-project --dry-run/fractary-codex:sync-project --from-codex/fractary-codex:validate-setupplugins/codex/README.mdKeep guidance concise but complete. </DOCUMENTATION>