Skip to content

Commit 6df66bb

Browse files
authored
Merge pull request #460 (docs)
docs: strengthen AGENT.md git safety guidelines
2 parents fb40002 + 90db35f commit 6df66bb

File tree

1 file changed

+64
-13
lines changed

1 file changed

+64
-13
lines changed

AGENT.md

Lines changed: 64 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,21 @@ README.md files:
156156

157157
### Pre-commit Checklist (MANDATORY)
158158

159-
Before finishing any task, ALWAYS run:
159+
Before committing any changes, ALWAYS run:
160160

161-
1. `pnpm lint` - Fix all ESLint issues
162-
2. `pnpm type-check` - Resolve all TypeScript errors
163-
3. `pnpm test` - Ensure all tests pass
164-
4. Check IDE diagnostics panel for warnings
165-
5. Update AGENT.md if guidelines change
166-
6. Update README.md if public API changes
167-
7. Review documentation formatting follows guidelines
161+
1. `pnpm -r precommit` - Run all precommit checks across the workspace
162+
2. Fix any issues found by the precommit checks
163+
3. Check IDE diagnostics panel for warnings
164+
4. Update AGENT.md if guidelines change
165+
5. Update README.md if public API changes
166+
6. Review documentation formatting follows guidelines
167+
168+
The `pnpm -r precommit` command will:
169+
170+
- Run ESLint and fix linting issues
171+
- Check TypeScript types
172+
- Run tests
173+
- Ensure code quality standards are met
168174

169175
### DO
170176

@@ -186,6 +192,13 @@ Before finishing any task, ALWAYS run:
186192
- Use relative imports between packages (use workspace deps)
187193
- Do not skip pre-commit checks
188194
- Do not ignore warnings or AGENT.md guidelines
195+
- **NEVER commit without explicitly listing files (no `git commit` alone)**
196+
- **NEVER use `git add .` or `git add -A` before committing**
197+
- **NEVER trust the staging area - it may contain unintended changes**
198+
- **NEVER DELETE FILES WITHOUT EXPLICIT PERMISSION** - Only delete files if:
199+
- The user explicitly asks you to delete them
200+
- You have 100% certainty you created them as temporary files in the current session
201+
- Examples of deletable temporary files: `.commit-msg-*` files you created
189202

190203
### Git Workflow
191204

@@ -198,10 +211,29 @@ Before finishing any task, ALWAYS run:
198211
- Focus commit messages on the final result, not the iterations to get there
199212
- When creating new files, describe what the file provides, not that it was created
200213

201-
#### Direct Commits (Recommended)
214+
#### Direct Commits (MANDATORY - NO EXCEPTIONS)
215+
216+
🚨 **CRITICAL**: NEVER use the staging area or commit without explicit files
217+
218+
##### FORBIDDEN commands that will commit unintended files
219+
220+
```bash
221+
# NEVER DO THESE:
222+
git commit # ❌ Commits everything staged
223+
git commit -a # ❌ Stages and commits all tracked files
224+
git commit -am "message" # ❌ Stages and commits all tracked files
225+
git add . && git commit # ❌ Stages everything then commits
226+
git add -A && git commit # ❌ Stages everything then commits
227+
```
202228

203-
**NEVER use the staging area** - always specify files directly in the
204-
commit command to ensure you're committing exactly what you intend:
229+
##### ALWAYS specify files directly in the commit command
230+
231+
##### Before committing, ALWAYS
232+
233+
1. Run `git status` to see what's staged and unstaged
234+
2. Verify you're committing ONLY the intended files
235+
3. If multiple unrelated changes are staged, unstage unwanted files first
236+
4. Double-check file list in commit command matches your intention
205237

206238
##### Commit Message Files
207239

@@ -213,10 +245,22 @@ commit command to ensure you're committing exactly what you intend:
213245
- **Clean up** commit message files after use
214246

215247
```bash
216-
# First write commit message to file using Write tool
248+
# CORRECT WORKFLOW:
249+
# 1. Check what changes exist
250+
git status --porcelain
251+
252+
# 2. Review specific file changes
253+
git diff src/file1.ts src/file2.vue
254+
255+
# 3. Write commit message to file using Write tool
217256
# Use CWD-relative path for the commit message file
257+
258+
# 4. VERIFY the file list is correct before pressing enter!
218259
git commit -sF .commit-msg-feature src/file1.ts src/file2.vue
219260

261+
# 5. Clean up
262+
rm .commit-msg-feature
263+
220264
# For fixup commits (no message file needed)
221265
git commit --fixup=<commit-sha> src/components/story/utils.ts
222266
```
@@ -367,6 +411,12 @@ Each package has its own AGENT.md file with specific details:
367411
### Claude Code Specific Instructions
368412

369413
- Use TodoWrite tool for complex multi-step tasks
414+
- **CRITICAL: Always enumerate files explicitly in git commit commands**
415+
- **NEVER use bare `git commit` without file arguments**
416+
- **Check `git status --porcelain` before every commit**
417+
- NEVER apologize or explain why you did something wrong
418+
- Fix issues immediately without commentary
419+
- Stay focused on the task at hand
370420

371421
### GitHub Copilot Specific Instructions
372422

@@ -380,10 +430,11 @@ Each package has its own AGENT.md file with specific details:
380430
- Follow the pre-commit checklist strictly
381431
- Use Write tool for commit messages, not echo, -m, or heredocs
382432
- Create commit message files in CWD (e.g., `.commit-msg-*`)
383-
- Don't rely on git staging for commits, use direct file references
384433
- Use `pnpm -F` instead of `cd` to work with specific packages
385434
- Don't change working directory permanently unless instructed
386435
- When working across multiple packages, prefer `pnpm -r`
436+
- NEVER USE `cd` IN BASH COMMANDS - NO EXCEPTIONS
437+
- Always use absolute paths or pnpm -F for package operations
387438

388439
## Debugging Tips
389440

0 commit comments

Comments
 (0)