Skip to content

Add opencode config to mirror Claude Code setup - #133

Open
rishid wants to merge 3 commits into
masterfrom
claude/opencode-config-setup-dgskyi
Open

Add opencode config to mirror Claude Code setup#133
rishid wants to merge 3 commits into
masterfrom
claude/opencode-config-setup-dgskyi

Conversation

@rishid

@rishid rishid commented Jul 29, 2026

Copy link
Copy Markdown
Owner

Summary

Ports the Claude Code global config in tilde/dot_claude/ to opencode's equivalent locations under ~/.config/opencode/, so opencode can be used alongside (or instead of) Claude Code with the same permissions, instructions, and commands.

  • tilde/private_dot_config/opencode/opencode.json~/.config/opencode/opencode.json. Sets the default model, configures the anthropic and openrouter providers (API keys read from env vars), disables autoupdate (mise already pins the opencode version in mise/config.toml), and converts the Bash allowlist from dot_claude/settings.json into opencode's permission.bash pattern syntax (Bash(cmd:*)"cmd *": "allow", default "*": "ask").
  • tilde/private_dot_config/opencode/AGENTS.md~/.config/opencode/AGENTS.md. Consolidates tilde/dot_claude/instructions/*.md (code quality, editor, git, reminders) — those files aren't referenced by any CLAUDE.md @import, so Claude Code likely never actually loaded them; this makes the same guidance active for opencode.
  • tilde/private_dot_config/opencode/commands/chezmoi-apply.md~/.config/opencode/commands/chezmoi-apply.md. Direct port of the existing /chezmoi-apply slash command.
  • tilde/private_dot_config/shell/encrypted_opencode-keys.sh.age~/.config/shell/opencode-keys.sh (age-encrypted, same pattern as the existing encrypted_akamai.bash.age). Holds stub ANTHROPIC_API_KEY / OPENROUTER_API_KEY values — real keys need to be filled in via chezmoi edit ~/.config/shell/opencode-keys.sh. Sourced from both profile.sh (bash/zsh) and config.fish (fish) behind a test -f guard, so it degrades gracefully before the file is decrypted.

No changes needed for skills or the project CLAUDE.md: opencode natively auto-discovers .claude/skills/ / ~/.claude/skills/, and falls back to CLAUDE.md for project/global instructions when no AGENTS.md is present — so the existing skill install script and repo-root CLAUDE.md already work for opencode as-is.

Not ported: Claude Code's custom statusLine shell script has no native opencode equivalent yet (there's an open feature request upstream for it), so it was intentionally left out rather than faked.

Test plan

  • opencode.json validated as well-formed JSON
  • Encrypted secrets file confirmed to be valid age ciphertext for the repo's age recipient
  • chezmoi apply on a real machine to confirm the new files deploy to the expected ~/.config/opencode/ and ~/.config/shell/ paths
  • Fill in real ANTHROPIC_API_KEY / OPENROUTER_API_KEY via chezmoi edit, then verify opencode picks up the config and providers
  • Run /chezmoi-apply inside opencode to confirm the ported command works

Generated by Claude Code

claude added 3 commits July 29, 2026 00:29
Ports the Claude Code global config in tilde/dot_claude/ to opencode's
equivalent locations under ~/.config/opencode/:

- opencode.json: model/provider config (Anthropic + OpenRouter, keys via
  env vars), converts the Bash permission allowlist from settings.json
  into opencode's bash permission pattern syntax, autoupdate disabled
  since mise pins the opencode version.
- AGENTS.md: consolidates tilde/dot_claude/instructions/*.md, which
  weren't wired into any CLAUDE.md import and so were never actually
  loaded by Claude Code.
- commands/chezmoi-apply.md: ports the /chezmoi-apply slash command.

Existing skills under ~/.claude/skills/ and the project CLAUDE.md need
no changes — opencode auto-discovers .claude/skills/ and falls back to
CLAUDE.md when no AGENTS.md is present.

Provider API keys are stubbed and stored age-encrypted (same pattern as
encrypted_akamai.bash.age), decrypted by chezmoi to
~/.config/shell/opencode-keys.sh and sourced from both fish and bash.
Real keys need to be filled in via `chezmoi edit`.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JJkxjsGjWuZqV6tevUrVm4
rishid already sets provider env vars (e.g. for Claude Code) in the
existing host-specific encrypted_config.bos-lhv9i4.fish.age, sourced
automatically by fish's config.fish. Reuse that instead of the new
shell-shared encrypted_opencode-keys.sh.age from the previous commit,
which just duplicated the same purpose.

opencode reads ANTHROPIC_API_KEY and OPENROUTER_API_KEY from the
environment (same as referenced via {env:...} in opencode.json), so
those are the two vars to add to the hostname config.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JJkxjsGjWuZqV6tevUrVm4
Follow-up to 150ae5c — these two edits wired up sourcing for the
encrypted_opencode-keys.sh.age file that commit deleted.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JJkxjsGjWuZqV6tevUrVm4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants