feat(git-master): add GIT_MASTER=1 env prefix for all git commands#2332
Open
devxoul wants to merge 2 commits intocode-yeongyu:devfrom
Open
feat(git-master): add GIT_MASTER=1 env prefix for all git commands#2332devxoul wants to merge 2 commits intocode-yeongyu:devfrom
devxoul wants to merge 2 commits intocode-yeongyu:devfrom
Conversation
When git-master skill is loaded, all git commands are prefixed with the configured env variable (default: GIT_MASTER=1). This enables custom git hooks to detect git-master skill usage. Set to empty string to disable.
Add unit tests for env prefix injection (default, disabled, custom value) and update existing skill-content tests to include git_env_prefix field.
There was a problem hiding this comment.
No issues found across 4 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Auto-approved: The PR safely introduces a new configuration option with comprehensive tests. The logic for template injection is robust and handles default, custom, and disabled states correctly.
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
git_env_prefixconfig togit_masterconfig section (default:"GIT_MASTER=1", set to""to disable).GIT_MASTER=1 git commit ...).Why This Matters
The git-master skill enforces atomic commits, conventional commit style, history analysis, and careful git discipline — but there is no way to guarantee the agent always loads it. This feature bridges that gap by giving hooks a reliable signal to detect (or enforce) git-master usage.
The primary motivation: a hook (OpenCode, Claude Code, or even git) can inspect git commands and reject them unless
GIT_MASTER=1is in the command, effectively forcing the agent to always load the git-master skill for any git operation. This ensures atomic commits, style detection, and all git-master discipline is always applied — no more silent fallback to unstructured commits.Use Cases
1. Enforce git-master skill loading via hooks
The killer use case. A
tool.execute.beforehook (works in both OpenCode and Claude Code) detects git commands in Bash tool calls and rejects them ifGIT_MASTER=1prefix is missing — forcing the agent to load the git-master skill before touching git:This guarantees every agent git operation goes through git-master's atomic commit analysis, conventional commit enforcement, and history-aware style detection.
2. Git hooks also work
Since the env var is set at the shell level, traditional git hooks can see it too. A
pre-commithook can enforce stricter rules only for agent commits:3. Audit trail / observability
Scripts or CI pipelines can distinguish agent-made commits from human commits. Since the env var is present during the git operation, hooks can tag commits with metadata:
4. Customizable prefix for team integration
Teams can set their own prefix to integrate with existing tooling:
{ "git_master": { "git_env_prefix": "AGENT_COMMIT=1" // match your team's conventions // "git_env_prefix": "AI_AUTHORED=true" // or integrate with AI detection tools // "git_env_prefix": "" // disable entirely } }Roadmap
A follow-up PR can address the "enforce git-master loading" option directly — e.g., a built-in hook that rejects git operations without the skill loaded. But it's better to land this bridge first; it lays the groundwork that the enforce feature will build on.
Configuration
Changes
src/config/schema/git-master.ts— Addgit_env_prefixfield to schema with"GIT_MASTER=1"default.src/features/opencode-skill-loader/git-master-template-injection.ts— Inject env prefix section into skill template when enabled. Refactor injection logic into helper functions.src/features/opencode-skill-loader/git-master-template-injection.test.ts— New: unit tests for env prefix injection (default value, disabled via empty string, custom value).src/features/opencode-skill-loader/skill-content.test.ts— Update existing tests to includegit_env_prefixfield.Testing