Skip to content

Add justfile — task runner for the project#4

Open
OctavianTocan wants to merge 1 commit intomainfrom
rust-mentor/justfile
Open

Add justfile — task runner for the project#4
OctavianTocan wants to merge 1 commit intomainfrom
rust-mentor/justfile

Conversation

@OctavianTocan
Copy link
Copy Markdown
Owner

@OctavianTocan OctavianTocan commented Apr 24, 2026

Adds a justfile with common Rust development tasks, inspired by the one in ai-nexus.

What is just?

just is a command runner — like make but simpler and designed for humans. You define recipes (commands) in a file called justfile, then run them with just <recipe-name>.

Install it: cargo install just

Then run just in the project root to see all available commands.

Recipes included

Recipe What it does
just build cargo build
just test cargo test
just lint cargo clippy (Rust's linter)
just fmt cargo fmt (auto-format code)
just check Format check + lint + test (full CI)
just commit AI-powered commit using claude CLI
just ac Alias for commit

The just commit command

This is the fun one. It does what the ai-nexus commit.ts does, but simpler:

  1. Checks if claude CLI is installed
  2. Stages all changes with git add -A
  3. Sends the diff to claude and asks for a conventional commit message
  4. Commits with that message
  5. Pushes

Requires: claude CLI installed (npm i -g @anthropic-ai/claude-code)

If you don't have claude CLI, the other recipes still work fine. just commit will just tell you to install it.

How justfiles work

Each recipe is a named block of shell commands. The format is:

recipe-name:
    shell command here

The indentation is required — it must be spaces, not tabs (unless you use #!/usr/bin/env bash shebang, which gives you a full bash script).

Recipes with #!/usr/bin/env bash at the top run as full bash scripts instead of line-by-line commands. That's what commit uses because it needs variables and error handling.

just is worth having in any Rust project because cargo handles 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:

  • Add aggregated check recipe to run formatting checks, linting, and tests in one command.
  • Provide AI-powered commit and alias recipes that stage changes, generate a conventional commit message via claude CLI, commit, and push.

Build:

  • Introduce justfile with recipes for build, release, run, test, lint, format, watch, and clean commands.

Copilot AI review requested due to automatic review settings April 24, 2026 21:26
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Apr 24, 2026

Reviewer's Guide

Adds a justfile task runner configuration to streamline Rust project workflows, including build/test/lint/format helpers and an AI-assisted commit script using the claude CLI.

Sequence diagram for the just commit AI-assisted workflow

sequenceDiagram
    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
Loading

File-Level Changes

Change Details Files
Introduce a justfile with common Rust development tasks and defaults.
  • Define a default recipe that lists all available just recipes
  • Add convenience recipes for building, releasing, running, testing, linting, formatting, cleaning, and watching the project
  • Create a composite check recipe that runs format check, lint, and tests
justfile
Add an AI-assisted git commit workflow via just commit and alias just ac.
  • Implement a bash-scripted commit recipe that checks for the claude CLI and exits with guidance if missing
  • Stage all changes, call the claude CLI to generate a conventional commit message from the staged diff, and commit with either the generated or a fallback message
  • Push the commit and echo the final commit message, and add an ac alias recipe that invokes commit
justfile

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 24, 2026

Warning

Rate limit exceeded

@OctavianTocan has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 41 minutes and 0 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3ad050b9-e71f-4ddd-9e7e-95cf53f81bf4

📥 Commits

Reviewing files that changed from the base of the PR and between dc20a5e and 5c4266b.

📒 Files selected for processing (1)
  • justfile
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch rust-mentor/justfile

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 just recipes for build/run/test/lint/format and an aggregated check recipe.
  • Adds a watch helper for running tests on file changes (via cargo-watch).
  • Adds an AI-powered commit (and ac alias) 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.

Comment thread justfile
--allowedTools "Bash(git diff --cached*),Read" 2>/dev/null)

if [ -z "$MSG" ]; then
echo "Error: claude returned empty message. Commiting with fallback."
Comment thread justfile
Comment on lines +80 to +84
git commit -m "chore: update files"
else
git commit -m "$MSG"
fi

Comment thread justfile
check: fmt-check lint test

# Watch for changes and rerun tests (requires cargo-watch)
watch:
Comment thread justfile
Comment on lines +81 to +85
else
git commit -m "$MSG"
fi

git push
Comment thread justfile
Comment on lines +73 to +84
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

Comment thread justfile
Comment on lines +69 to +76
# 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)
Comment thread justfile
Comment on lines +73 to +82
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"
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 2 issues, and left some high level feedback:

  • 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).
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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread justfile
Comment on lines +73 to +76
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)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread justfile
Comment on lines +78 to +81
if [ -z "$MSG" ]; then
echo "Error: claude returned empty message. Commiting with fallback."
git commit -m "chore: update files"
else
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick (typo): Minor typo in fallback error message.

“Commiting” should be spelled “Committing” in this message to keep the user-facing output polished.

Suggested change
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

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread justfile
Comment on lines +73 to +76
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)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants