Add opencode config to mirror Claude Code setup - #133
Open
rishid wants to merge 3 commits into
Open
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 theanthropicandopenrouterproviders (API keys read from env vars), disablesautoupdate(mise already pins the opencode version inmise/config.toml), and converts the Bash allowlist fromdot_claude/settings.jsoninto opencode'spermission.bashpattern syntax (Bash(cmd:*)→"cmd *": "allow", default"*": "ask").tilde/private_dot_config/opencode/AGENTS.md→~/.config/opencode/AGENTS.md. Consolidatestilde/dot_claude/instructions/*.md(code quality, editor, git, reminders) — those files aren't referenced by anyCLAUDE.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-applyslash command.tilde/private_dot_config/shell/encrypted_opencode-keys.sh.age→~/.config/shell/opencode-keys.sh(age-encrypted, same pattern as the existingencrypted_akamai.bash.age). Holds stubANTHROPIC_API_KEY/OPENROUTER_API_KEYvalues — real keys need to be filled in viachezmoi edit ~/.config/shell/opencode-keys.sh. Sourced from bothprofile.sh(bash/zsh) andconfig.fish(fish) behind atest -fguard, 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 toCLAUDE.mdfor project/global instructions when noAGENTS.mdis present — so the existing skill install script and repo-rootCLAUDE.mdalready work for opencode as-is.Not ported: Claude Code's custom
statusLineshell 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.jsonvalidated as well-formed JSONchezmoi applyon a real machine to confirm the new files deploy to the expected~/.config/opencode/and~/.config/shell/pathsANTHROPIC_API_KEY/OPENROUTER_API_KEYviachezmoi edit, then verifyopencodepicks up the config and providers/chezmoi-applyinside opencode to confirm the ported command worksGenerated by Claude Code