بنقرة واحدة
write-and-commit
Create file and commit atomically (60-75% faster than step-by-step)
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Create file and commit atomically (60-75% faster than step-by-step)
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Guide for writing clear, descriptive commit messages
Merge task branch to base branch with linear history (works from task worktree)
MANDATORY: Use instead of `git rebase` - provides automatic backup and conflict recovery
MANDATORY: Use instead of `git rebase -i` for squashing - unified commit messages
Analyze mistakes with conversation length as potential cause (CAT-specific)
Run scheduled retrospective analysis, derive action items, and track effectiveness
| name | write-and-commit |
| description | Create file and commit atomically (60-75% faster than step-by-step) |
| allowed-tools | Bash, Write |
Purpose: Create a new file and commit it in a single atomic operation, reducing LLM round-trips from 4-5 to 2-3.
Performance: 60-75% faster than traditional workflow
[LLM Round 1] Write file
→ Write tool: Create file with content
[LLM Round 2] Make executable (if needed)
→ Bash: chmod +x file.sh
[LLM Round 3] Stage file
→ Bash: git add file.sh
[LLM Round 4] Commit file
→ Bash: git commit -m "Add file"
[LLM Round 5] Report success
→ Report commit SHA to user
Total: 20-30 seconds, 4-5 LLM round-trips
[LLM Round 1] Change and execute
→ Write content to temp file
→ Write commit message to temp file
→ Bash: write-and-commit.sh file.sh /tmp/content /tmp/msg --executable
[LLM Round 2] Report success
→ Parse JSON result
→ Report commit SHA to user
Total: 5-8 seconds, 2-3 LLM round-trips
Savings: 60-75% faster
# Step 1: Prepare content and commit message (in LLM)
cat > /tmp/content-$$.txt <<'EOF'
File content goes here...
EOF
cat > /tmp/commit-msg-$$.txt <<'EOF'
Add new feature file
Description of what this file does.
EOF
# Step 2: Execute atomic creation
~/.claude/scripts/write-and-commit.sh \
"path/to/file.txt" \
"/tmp/content-$$.txt" \
"/tmp/commit-msg-$$.txt"
# For scripts that need executable permissions
~/.claude/scripts/write-and-commit.sh \
".claude/scripts/my-script.sh" \
"/tmp/content-$$.txt" \
"/tmp/commit-msg-$$.txt" \
--executable
Script returns JSON:
{
"status": "success",
"message": "File created and committed successfully",
"duration_seconds": 2,
"file_path": "path/to/file.txt",
"executable": false,
"commit_sha": "abc123def456",
"working_directory": "/path/to/project",
"timestamp": "2025-11-08T00:15:30-05:00"
}
User: Create a script to clean up temporary files
LLM Round 1 (Planning + Execution):
# Draft script content
cat > /tmp/cleanup-script-$$.sh <<'SCRIPT'
#!/bin/bash
# Clean up temporary files
find /tmp -name "*.tmp" -mtime +7 -delete
SCRIPT
# Draft commit message
cat > /tmp/commit-msg-$$.txt <<'MSG'
Add temporary file cleanup script
Removes .tmp files older than 7 days from /tmp directory.
MSG
# Execute atomic creation
~/.claude/scripts/write-and-commit.sh \
".claude/scripts/cleanup-temp.sh" \
"/tmp/cleanup-script-$$.sh" \
"/tmp/commit-msg-$$.txt" \
--executable
Script Output:
{
"status": "success",
"commit_sha": "3f8a920",
"duration_seconds": 2,
...
}
LLM Round 2 (Verification):
Created cleanup script successfully!
- File: .claude/scripts/cleanup-temp.sh
- Executable: Yes
- Commit: 3f8a920
- Duration: 2 seconds
On any error, script:
Recovery: If script fails after file creation but before commit:
# File exists but not committed
git reset HEAD <file> # Unstage
rm <file> # Remove if unwanted
# Creating .gitignore
cat > /tmp/content.txt <<'EOF'
*.tmp
*.log
build/
EOF
write-and-commit.sh ".gitignore" /tmp/content.txt /tmp/msg.txt
# Creating README for a subdirectory
cat > /tmp/content.txt <<'EOF'
# Component Documentation
...
EOF
write-and-commit.sh "docs/component/README.md" /tmp/content.txt /tmp/msg.txt
# Creating a test file
cat > /tmp/content.txt <<'EOF'
public class MyTest {
@Test
public void testFeature() {
// Test implementation
}
}
EOF
write-and-commit.sh "src/test/java/MyTest.java" /tmp/content.txt /tmp/msg.txt
# Creating a hook script
cat > /tmp/content.txt <<'EOF'
#!/bin/bash
# Hook implementation
EOF
write-and-commit.sh ".claude/hooks/my-hook.sh" /tmp/content.txt /tmp/msg.txt --executable
❌ Wrong: Create files one-by-one with write-and-commit
write-and-commit.sh file1.txt /tmp/content1 /tmp/msg1
write-and-commit.sh file2.txt /tmp/content2 /tmp/msg2
write-and-commit.sh file3.txt /tmp/content3 /tmp/msg3
# Result: 3 separate commits
✅ Correct: Use traditional workflow, commit together
Write file1.txt
Write file2.txt
Write file3.txt
git add file1.txt file2.txt file3.txt
git commit -m "Add related files"
# Result: 1 commit with all files
❌ Wrong: Commit immediately if unsure about content ✅ Correct: Create with Write tool, review, then commit manually
Expected Usage: 10-20 times per day
Time Savings per Use: ~15 seconds
Daily Impact: 150-300 seconds (2.5-5 minutes)
Monthly Impact: 50-100 minutes (almost 2 hours)