Add justfile — task runner for the project#4
Conversation
Reviewer's GuideAdds a Sequence diagram for the just commit AI-assisted workflowsequenceDiagram
actor Developer
participant Shell
participant justfile as just
participant Git
participant ClaudeCLI as claude
Developer->>Shell: just commit
Shell->>just: Execute commit recipe
just->>Shell: Run bash script
Shell->>ClaudeCLI: command -v claude
ClaudeCLI-->>Shell: Path or not found
alt claude not installed
Shell-->>Developer: Print install instructions
Shell->>Shell: Exit with error
else claude installed
Shell->>Git: git status --porcelain
Git-->>Shell: Working tree status
alt no changes
Shell-->>Developer: Print Nothing to commit
Shell->>Shell: Exit 0
else changes present
Shell->>Git: git add -A
Shell->>ClaudeCLI: Generate commit message from git diff --cached
ClaudeCLI-->>Shell: MSG (commit message text)
alt MSG empty
Shell->>Git: git commit -m "chore: update files"
else MSG non-empty
Shell->>Git: git commit -m MSG
end
Shell->>Git: git push
Shell-->>Developer: Print Pushed: MSG
end
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 41 minutes and 0 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Adds a justfile to the repository to standardize common Rust development workflows and provide a convenience command for AI-assisted committing.
Changes:
- Introduces
justrecipes for build/run/test/lint/format and an aggregatedcheckrecipe. - Adds a
watchhelper for running tests on file changes (viacargo-watch). - Adds an AI-powered
commit(andacalias) recipe that stages changes, generates a conventional commit message, commits, and pushes.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| --allowedTools "Bash(git diff --cached*),Read" 2>/dev/null) | ||
|
|
||
| if [ -z "$MSG" ]; then | ||
| echo "Error: claude returned empty message. Commiting with fallback." |
| git commit -m "chore: update files" | ||
| else | ||
| git commit -m "$MSG" | ||
| fi | ||
|
|
| check: fmt-check lint test | ||
|
|
||
| # Watch for changes and rerun tests (requires cargo-watch) | ||
| watch: |
| else | ||
| git commit -m "$MSG" | ||
| fi | ||
|
|
||
| git push |
| MSG=$(claude -p "Look at the staged git diff and generate ONE concise conventional commit message. \ | ||
| Only output the message text. Format: type(scope?): summary. Use feat/fix/refactor/test/chore/docs. \ | ||
| No body, no footer, just the first line. Keep it under 72 chars." \ | ||
| --allowedTools "Bash(git diff --cached*),Read" 2>/dev/null) | ||
|
|
||
| if [ -z "$MSG" ]; then | ||
| echo "Error: claude returned empty message. Commiting with fallback." | ||
| git commit -m "chore: update files" | ||
| else | ||
| git commit -m "$MSG" | ||
| fi | ||
|
|
| # Stage everything | ||
| git add -A | ||
|
|
||
| # Generate commit message from the diff | ||
| MSG=$(claude -p "Look at the staged git diff and generate ONE concise conventional commit message. \ | ||
| Only output the message text. Format: type(scope?): summary. Use feat/fix/refactor/test/chore/docs. \ | ||
| No body, no footer, just the first line. Keep it under 72 chars." \ | ||
| --allowedTools "Bash(git diff --cached*),Read" 2>/dev/null) |
| MSG=$(claude -p "Look at the staged git diff and generate ONE concise conventional commit message. \ | ||
| Only output the message text. Format: type(scope?): summary. Use feat/fix/refactor/test/chore/docs. \ | ||
| No body, no footer, just the first line. Keep it under 72 chars." \ | ||
| --allowedTools "Bash(git diff --cached*),Read" 2>/dev/null) | ||
|
|
||
| if [ -z "$MSG" ]; then | ||
| echo "Error: claude returned empty message. Commiting with fallback." | ||
| git commit -m "chore: update files" | ||
| else | ||
| git commit -m "$MSG" |
There was a problem hiding this comment.
Hey - I've found 2 issues, and left some high level feedback:
- In the
commitrecipe you always rungit pushafter committing, which can be surprising in local workflows; consider splitting this into separatecommitandcommit-pushrecipes or gating the push behind an environment variable. - The
commitrecipe stages all changes withgit add -Abefore generating a message, which overrides a user's carefully staged index; consider either operating only on already-staged changes or making the auto-stage behavior optional (e.g., a separate recipe).
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In the `commit` recipe you always run `git push` after committing, which can be surprising in local workflows; consider splitting this into separate `commit` and `commit-push` recipes or gating the push behind an environment variable.
- The `commit` recipe stages all changes with `git add -A` before generating a message, which overrides a user's carefully staged index; consider either operating only on already-staged changes or making the auto-stage behavior optional (e.g., a separate recipe).
## Individual Comments
### Comment 1
<location path="justfile" line_range="73-76" />
<code_context>
+ git add -A
+
+ # Generate commit message from the diff
+ MSG=$(claude -p "Look at the staged git diff and generate ONE concise conventional commit message. \
+Only output the message text. Format: type(scope?): summary. Use feat/fix/refactor/test/chore/docs. \
+No body, no footer, just the first line. Keep it under 72 chars." \
+ --allowedTools "Bash(git diff --cached*),Read" 2>/dev/null)
+
+ if [ -z "$MSG" ]; then
</code_context>
<issue_to_address>
**issue:** Potential multi-line output from `claude` may break `git commit -m` usage.
The script relies on Claude returning a single line, but nothing guarantees that. If Claude outputs multiple lines, `git commit -m "$MSG"` will silently use only the first line. Consider sanitizing `MSG` (e.g., `MSG=$(printf '%s' "$MSG" | head -n1)`) so the commit behavior remains predictable even if the tool’s output format changes.
</issue_to_address>
### Comment 2
<location path="justfile" line_range="78-81" />
<code_context>
+ --allowedTools "Bash(git diff --cached*),Read" 2>/dev/null)
+
+ if [ -z "$MSG" ]; then
+ echo "Error: claude returned empty message. Commiting with fallback."
+ git commit -m "chore: update files"
+ else
</code_context>
<issue_to_address>
**nitpick (typo):** Minor typo in fallback error message.
“Commiting” should be spelled “Committing” in this message to keep the user-facing output polished.
```suggestion
if [ -z "$MSG" ]; then
echo "Error: claude returned empty message. Committing with fallback."
git commit -m "chore: update files"
else
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| MSG=$(claude -p "Look at the staged git diff and generate ONE concise conventional commit message. \ | ||
| Only output the message text. Format: type(scope?): summary. Use feat/fix/refactor/test/chore/docs. \ | ||
| No body, no footer, just the first line. Keep it under 72 chars." \ | ||
| --allowedTools "Bash(git diff --cached*),Read" 2>/dev/null) |
There was a problem hiding this comment.
issue: Potential multi-line output from claude may break git commit -m usage.
The script relies on Claude returning a single line, but nothing guarantees that. If Claude outputs multiple lines, git commit -m "$MSG" will silently use only the first line. Consider sanitizing MSG (e.g., MSG=$(printf '%s' "$MSG" | head -n1)) so the commit behavior remains predictable even if the tool’s output format changes.
| if [ -z "$MSG" ]; then | ||
| echo "Error: claude returned empty message. Commiting with fallback." | ||
| git commit -m "chore: update files" | ||
| else |
There was a problem hiding this comment.
nitpick (typo): Minor typo in fallback error message.
“Commiting” should be spelled “Committing” in this message to keep the user-facing output polished.
| if [ -z "$MSG" ]; then | |
| echo "Error: claude returned empty message. Commiting with fallback." | |
| git commit -m "chore: update files" | |
| else | |
| if [ -z "$MSG" ]; then | |
| echo "Error: claude returned empty message. Committing with fallback." | |
| git commit -m "chore: update files" | |
| else |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5c4266b210
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| MSG=$(claude -p "Look at the staged git diff and generate ONE concise conventional commit message. \ | ||
| Only output the message text. Format: type(scope?): summary. Use feat/fix/refactor/test/chore/docs. \ | ||
| No body, no footer, just the first line. Keep it under 72 chars." \ | ||
| --allowedTools "Bash(git diff --cached*),Read" 2>/dev/null) |
There was a problem hiding this comment.
Guard claude invocation so fallback can execute
With set -euo pipefail enabled for this recipe, a non-zero exit from claude in the MSG=$(...) assignment causes the script to exit immediately, so the fallback commit path below is never reached. This means transient Claude CLI failures (auth/network/tool-flag errors) will abort just commit after staging changes instead of committing with the fallback message, which conflicts with the intended resilience implied by the if [ -z "$MSG" ] branch.
Useful? React with 👍 / 👎.
Adds a
justfilewith common Rust development tasks, inspired by the one in ai-nexus.What is
just?justis a command runner — likemakebut simpler and designed for humans. You define recipes (commands) in a file calledjustfile, then run them withjust <recipe-name>.Install it:
cargo install justThen run
justin the project root to see all available commands.Recipes included
just buildcargo buildjust testcargo testjust lintcargo clippy(Rust's linter)just fmtcargo fmt(auto-format code)just checkjust commitjust acThe
just commitcommandThis is the fun one. It does what the ai-nexus
commit.tsdoes, but simpler:git add -ARequires:
claudeCLI installed (npm i -g @anthropic-ai/claude-code)If you don't have claude CLI, the other recipes still work fine.
just commitwill just tell you to install it.How justfiles work
Each recipe is a named block of shell commands. The format is:
The indentation is required — it must be spaces, not tabs (unless you use
#!/usr/bin/env bashshebang, which gives you a full bash script).Recipes with
#!/usr/bin/env bashat the top run as full bash scripts instead of line-by-line commands. That's whatcommituses because it needs variables and error handling.justis worth having in any Rust project becausecargohandles build/test but doesn't cover git workflows, linting combos, or custom scripts.Summary by Sourcery
Add a justfile to provide a standard task runner for common Rust development workflows and an AI-assisted git commit flow.
Enhancements:
Build: