Skip to content

feat: support user-level defaults for companion config (e.g. stopReviewGate) #213

@bk-squared

Description

@bk-squared

Summary

Currently codex-companion stores config per git-repo root, with no fallback source. Options like stopReviewGate have to be toggled individually for every repo. It would be great to support a user-level defaults file that workspace state can override.

Related

Scope (explicit)

Per-workspace state always wins. The user-level file is a baseline only — never overrides an explicit per-repo setting. No existing state schema changes.

Current behavior

scripts/lib/workspace.mjs resolves the workspace as the nearest git repo root, and scripts/lib/state.mjs keys state under \$CLAUDE_PLUGIN_DATA/state/<slug>-<sha256(realpath)[:16]>/state.json. getConfig() only reads that per-repo file — there is no lookup of a shared/user-level default. So enabling the review gate across N sibling repos under a shared workspace requires N separate `codex-companion setup --enable-review-gate` invocations.

Use case

I maintain a workspace with many sibling git repos (research / infra / teaching subtrees). I want the stop-time review gate enabled by default everywhere, while still being able to disable it in specific repos that don't need it. Running the setup command repeatedly across every new clone is friction, and easy to forget.

This is the same ergonomic pattern that git (`/.gitconfig` → repo `.git/config`), npm (`/.npmrc` → project), and Claude Code itself (`~/.claude/settings.json` → project `.claude/settings.json`) already provide.

Proposed behavior

Introduce a lower-priority defaults file, e.g. `$CLAUDE_PLUGIN_DATA/defaults.json` (or `~/.config/codex-companion/defaults.json`). `getConfig()` would shallow-merge in this order:

```
built-in defaults < user defaults < per-workspace state
```

The setup command could gain `--global` (or `--user`) to write the defaults file instead of the workspace state:

```
codex-companion setup --enable-review-gate --global
```

Why this feels like a small change

  • One new resolver + shallow merge in `lib/state.mjs::getConfig`.
  • One new flag branch in the setup command.
  • No schema change to existing per-workspace state.

Happy to send a PR if the maintainers are open to this direction — would prefer to confirm the preferred location (`$CLAUDE_PLUGIN_DATA/defaults.json` vs. `$XDG_CONFIG_HOME/...`) before coding.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions