Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# wt-cli-rust — task runner
# Install just: cargo install just
# Run `just` to see all available recipes

default:
@just --list

# Build the project
build:
cargo build

# Build in release mode (optimized)
release:
cargo build --release

# Run the binary
run:
cargo run

# Run all tests
test:
cargo test

# Run tests with output printed
test-verbose:
cargo test -- --nocapture

# Run clippy linter
lint:
cargo clippy -- -D warnings

# Format code (writes in place)
fmt:
cargo fmt

# Check formatting without changing files
fmt-check:
cargo fmt -- --check

# Full check: format + lint + test
check: fmt-check lint test

# Watch for changes and rerun tests (requires cargo-watch)
watch:
cargo watch -x test

# Clean build artifacts
clean:
cargo clean

# AI-powered commit using claude CLI
# Stages all changes, generates a commit message, commits, and pushes.
# Requires: claude CLI (npm i -g @anthropic-ai/claude-code)
commit:
#!/usr/bin/env bash
set -euo pipefail

if ! command -v claude &>/dev/null; then
echo "Error: claude CLI not found."
echo "Install with: npm i -g @anthropic-ai/claude-code"
exit 1
fi

if [ -z "$(git status --porcelain)" ]; then
echo "Nothing to commit."
exit 0
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)
Comment on lines +69 to +76
Comment on lines +73 to +76
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 on lines +73 to +76
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 👍 / 👎.


if [ -z "$MSG" ]; then
echo "Error: claude returned empty message. Commiting with fallback."
git commit -m "chore: update files"
else
Comment on lines +78 to +81
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

git commit -m "$MSG"
Comment on lines +73 to +82
fi

Comment on lines +80 to +84
Comment on lines +73 to +84
git push
Comment on lines +81 to +85
echo "Pushed: $MSG"

# Quick alias: just ac = stage all + AI commit
ac: commit