Slash Command45 repo starsupdated 3mo ago
atomic-commits
Analyze staged changes and organize them into intuitive atomic commits following conventional commits.
Install in Claude Code
Copymkdir -p ~/.claude/commands && curl -fsSL https://raw.githubusercontent.com/spencermarx/obsidian-ai/HEAD/.claude/commands/atomic-commits.md -o ~/.claude/commands/atomic-commits.mdThen start a new Claude Code session; the slash command loads automatically.
Definition
atomic-commits.md
# Atomic Commits
Analyze staged changes along with relevant requirements and OpenSpec files, then organize and commit them as intuitive atomic commits following conventional commits.
## Prerequisites
- Ensure there are staged changes (`git diff --staged`)
- Review any related OpenSpec change documents in `openspec/changes/`
## Steps
1. **Analyze Staged Changes**
- Run `git diff --staged --name-only` to list all staged files
- Run `git diff --staged` to understand the actual changes
- Group changes by logical concern (feature, fix, refactor, docs, spec, etc.)
2. **Identify Related OpenSpec Documents**
- Check if any staged changes relate to OpenSpec change documents in `openspec/changes/`
- If OpenSpec files are staged, note which ones are non-archived (not in `openspec/changes/archive/`)
- Read relevant OpenSpec documents to understand the context and requirements
3. **Plan Atomic Commits**
- Organize changes into logical, atomic commits that each represent a single cohesive change
- Order commits in a sequence that makes sense (dependencies first, features second, cleanup last)
- **OpenSpec commits**: Any commit related to OpenSpec documents should use the prefix `spec: ...`
- **Archive commit**: If non-archived OpenSpec change documents are included, plan the **final commit** to archive them using `openspec archive <id> --yes`
4. **Execute Commits Sequentially**
- For each atomic commit:
a. Unstage all files: `git reset HEAD`
b. Stage only the files for this specific commit: `git add <files>`
c. Commit with a conventional commit message: `git commit -m "<type>(<scope>): <description>"`
- Conventional commit types: `feat`, `fix`, `refact`, `doc`, `test`, `chore`, `style`, `perf`, `ci`, `build`, `spec`
5. **Archive OpenSpec Changes (Final Commit)**
- If OpenSpec change documents were part of the staged changes and are non-archived:
- Run `openspec archive <id> --yes` for each relevant change ID
- Commit the archive with: `git commit -m "spec: archive <change-id>"`
6. **Verify Commit History**
- Run `git log --oneline -n <number-of-commits>` to verify the commit sequence
- Ensure each commit is atomic, well-described, and follows conventional commits
## Conventional Commit Types
| Type | Description |
|------------|------------------------------------------------------|
| `feat` | A new feature |
| `fix` | A bug fix |
| `refact` | Code change that neither fixes a bug nor adds a feature |
| `doc` | Documentation only changes |
| `test` | Adding or correcting tests |
| `chore` | Maintenance tasks, dependencies, tooling |
| `style` | Formatting, white-space, semi-colons, etc. |
| `perf` | Performance improvements |
| `ci` | CI/CD configuration changes |
| `build` | Build system or external dependency changes |
| `spec` | OpenSpec document changes (proposals, archives) |
## Example Commit Sequence
```
feat(scheduler): add address autocomplete to new customer form
fix(scheduler): resolve phone validation edge case
refactor(scheduler): extract address validation utility
test(scheduler): add unit tests for address validation
spec: archive add-address-autocomplete-new-customer
```
## Notes
- Each commit should be independently buildable and testable when possible
- Commit messages should be clear and descriptive
- Use scope to indicate the affected area (e.g., `scheduler`, `api`, `ui`)
- The OpenSpec archive commit should always be last when applicableMore from this repository
addressSlash Command
Address code review feedback — corroborate, validate, and implement changes from a review's final.md.
create-reviewerSlash Command
Create a new custom reviewer from a natural language description.
doctorSlash Command
Check OCR installation and verify all dependencies are available.
historySlash Command
List past OCR review sessions.
mapSlash Command
Generate a Code Review Map to help navigate large, complex changesets.
postSlash Command
Post the current OCR review to a GitHub PR.
reviewSlash Command
Run an AI-powered multi-agent code review on your changes.
reviewersSlash Command
List all available reviewer personas for code review.