()
| 40 | } |
| 41 | |
| 42 | function getCommitAndPRInstructions(): string { |
| 43 | // Defense-in-depth: undercover instructions must survive even if the user |
| 44 | // has disabled git instructions entirely. Attribution stripping and model-ID |
| 45 | // hiding are mechanical and work regardless, but the explicit "don't blow |
| 46 | // your cover" instructions are the last line of defense against the model |
| 47 | // volunteering an internal codename in a commit message. |
| 48 | const undercoverSection = |
| 49 | process.env.USER_TYPE === 'ant' && isUndercover() |
| 50 | ? getUndercoverInstructions() + '\n' |
| 51 | : '' |
| 52 | |
| 53 | if (!shouldIncludeGitInstructions()) return undercoverSection |
| 54 | |
| 55 | // For ant users, use the short version pointing to skills |
| 56 | if (process.env.USER_TYPE === 'ant') { |
| 57 | const skillsSection = !isEnvTruthy(process.env.CLAUDE_CODE_SIMPLE) |
| 58 | ? `For git commits and pull requests, use the \`/commit\` and \`/commit-push-pr\` skills: |
| 59 | - \`/commit\` - Create a git commit with staged changes |
| 60 | - \`/commit-push-pr\` - Commit, push, and create a pull request |
| 61 | |
| 62 | These skills handle git safety protocols, proper commit message formatting, and PR creation. |
| 63 | |
| 64 | Before creating a pull request, run \`/simplify\` to review your changes, then test end-to-end (e.g. via \`/tmux\` for interactive features). |
| 65 | |
| 66 | ` |
| 67 | : '' |
| 68 | return `${undercoverSection}# Git operations |
| 69 | |
| 70 | ${skillsSection}IMPORTANT: NEVER skip hooks (--no-verify, --no-gpg-sign, etc) unless the user explicitly requests it. |
| 71 | |
| 72 | Use the gh command via the Bash tool for other GitHub-related tasks including working with issues, checks, and releases. If given a Github URL use the gh command to get the information needed. |
| 73 | |
| 74 | # Other common operations |
| 75 | - View comments on a Github PR: gh api repos/foo/bar/pulls/123/comments` |
| 76 | } |
| 77 | |
| 78 | // For external users, include full inline instructions |
| 79 | const { commit: commitAttribution, pr: prAttribution } = getAttributionTexts() |
| 80 | |
| 81 | return `# Committing changes with git |
| 82 | |
| 83 | Only create commits when requested by the user. If unclear, ask first. When the user asks you to create a new git commit, follow these steps carefully: |
| 84 | |
| 85 | You can call multiple tools in a single response. When multiple independent pieces of information are requested and all commands are likely to succeed, run multiple tool calls in parallel for optimal performance. The numbered steps below indicate which commands should be batched in parallel. |
| 86 | |
| 87 | Git Safety Protocol: |
| 88 | - NEVER update the git config |
| 89 | - NEVER run destructive git commands (push --force, reset --hard, checkout ., restore ., clean -f, branch -D) unless the user explicitly requests these actions. Taking unauthorized destructive actions is unhelpful and can result in lost work, so it's best to ONLY run these commands when given direct instructions |
| 90 | - NEVER skip hooks (--no-verify, --no-gpg-sign, etc) unless the user explicitly requests it |
| 91 | - NEVER run force push to main/master, warn the user if they request it |
| 92 | - CRITICAL: Always create NEW commits rather than amending, unless the user explicitly requests a git amend. When a pre-commit hook fails, the commit did NOT happen — so --amend would modify the PREVIOUS commit, which may result in destroying work or losing previous changes. Instead, after hook failure, fix the issue, re-stage, and create a NEW commit |
| 93 | - When staging files, prefer adding specific files by name rather than using "git add -A" or "git add .", which can accidentally include sensitive files (.env, credentials) or large binaries |
| 94 | - NEVER commit changes unless the user explicitly asks you to. It is VERY IMPORTANT to only commit when explicitly asked, otherwise the user will feel that you are being too proactive |
| 95 | |
| 96 | 1. Run the following bash commands in parallel, each using the ${BASH_TOOL_NAME} tool: |
| 97 | - Run a git status command to see all untracked files. IMPORTANT: Never use the -uall flag as it can cause memory issues on large repos. |
| 98 | - Run a git diff command to see both staged and unstaged changes that will be committed. |
| 99 | - Run a git log command to see recent commit messages, so that you can follow this repository's commit message style. |
no test coverage detected