Deterministic commit and push workflow using scripts (DRY compliant)
Deterministic commit and push workflow using a reusable script. Use this to commit staged changes and push to remote in one command, following conventional commits format.
/plugin marketplace add Shakes-tzd/contextune/plugin install contextune@ContextuneYou are executing a deterministic git commit and push workflow.
Cost: ~$0.002 (545 tokens) vs ~$0.037-0.086 (8K-25K tokens) for multi-tool approach Savings: 93-97% token reduction
Check git status to understand what files changed:
git status --short
Analyze the output:
M = Modified filesA = Added filesD = Deleted files?? = Untracked filesUse the plugin's commit script (works from any project):
"${CLAUDE_PLUGIN_ROOT}/scripts/commit_and_push.sh" "<files>" "<message>" "<branch>" "<remote>"
Note:
${CLAUDE_PLUGIN_ROOT}is automatically set by Claude Code to the plugin's installation directory (e.g.,~/.claude/plugins/contextune@Contextune/). This ensures the script is always accessible regardless of which project you're working in.
Parameters:
<files> - Files to commit (use . for all changes, or specific files)<message> - Commit message (follows conventional commits format)<branch> - Branch name (auto-detected from current branch, optional)<remote> - Remote name (auto-detected if not specified, optional)Example 1: Commit all changes
"${CLAUDE_PLUGIN_ROOT}/scripts/commit_and_push.sh" "." "feat: add new feature
Detailed description of changes.
š¤ Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>"
Example 2: Commit specific files
"${CLAUDE_PLUGIN_ROOT}/scripts/commit_and_push.sh" "src/feature.ts tests/feature.test.ts" "feat: implement feature X"
Example 3: Specify branch and remote
"${CLAUDE_PLUGIN_ROOT}/scripts/commit_and_push.sh" "." "fix: resolve bug" "develop" "origin"
Follow conventional commits:
<type>: <description>
[optional body]
[optional footer]
š¤ Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Types:
feat: - New featurefix: - Bug fixdocs: - Documentation changesrefactor: - Code refactoringtest: - Test changeschore: - Build/tooling changesExamples:
# Feature
"feat: add user authentication
Implemented JWT-based authentication with refresh tokens.
š¤ Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>"
# Bug fix
"fix: resolve memory leak in WebSocket handler
Fixed issue where connections were not properly cleaned up.
š¤ Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>"
# Documentation
"docs: update API documentation
Added examples for new endpoints.
š¤ Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>"
The commit_and_push.sh script handles:
git add <files> - Stage specified filesgit commit -m "<message>" - Commit with messagegit push <remote> <branch> - Push to remoteScript output:
ā
Committed and pushed to origin/master
If script fails:
No changes to commit:
ā¹ļø No changes to commit
No git remotes:
Error: No git remotes configured
git remote add origin <url>Permission denied:
Error: Permission denied
Merge conflicts:
Error: Merge conflict detected
git pull <remote> <branch>The commit script is part of the Contextune plugin and is automatically accessible via:
"${CLAUDE_PLUGIN_ROOT}/scripts/commit_and_push.sh"
Where CLAUDE_PLUGIN_ROOT resolves to:
~/.claude/plugins/contextune@Contextune/ (typical installation)Fallback (if env var not set):
git add <files> && git commit -m "<message>" && git push
Multi-tool approach (what NOT to do):
Tool 1: git status
Tool 2: git add .
Tool 3: git status --short
Tool 4: git diff --cached
Tool 5: git commit -m "message"
Tool 6: git log -1
Tool 7: git push origin master
Tool 8: git status
Cost: ~8K-25K tokens ($0.037-0.086)
Efficient approach (correct):
Tool 1: git add . && git commit -m "message" && git push
Cost: ~545 tokens ($0.002)
Savings: 93-97% reduction
This command is available via:
Explicit command: /ctx:git-commit
Natural language: Contextune detects and routes automatically:
PreToolUse hook: Intercepts manual git commands and suggests script
/ctx:git-pr - Create pull request using script/ctx:git-merge - Merge branches using script/ctx:cleanup - Cleanup worktrees and branches# Commit specific directories
"${CLAUDE_PLUGIN_ROOT}/scripts/commit_and_push.sh" "src/ tests/" "feat: implement feature"
# Commit specific file types
"${CLAUDE_PLUGIN_ROOT}/scripts/commit_and_push.sh" "*.ts *.tsx" "refactor: update types"
"${CLAUDE_PLUGIN_ROOT}/scripts/commit_and_push.sh" "." "feat: add authentication
Implemented features:
- JWT token generation
- Refresh token rotation
- User session management
Breaking changes:
- Auth API endpoints changed from /api/v1 to /api/v2
š¤ Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>"
${CLAUDE_PLUGIN_ROOT} - This resolves to the plugin's installation directorygit status) are always OK without scriptUNIFIED_DRY_STRATEGY.md - DRY strategy for git operations${CLAUDE_PLUGIN_ROOT}/scripts/commit_and_push.sh - Script source code${CLAUDE_PLUGIN_ROOT}/scripts/smart_execute.sh - Error recovery wrapper${CLAUDE_PLUGIN_ROOT}/scripts/create_pr.sh - Create pull request script${CLAUDE_PLUGIN_ROOT}/scripts/merge_and_cleanup.sh - Merge and cleanup script