关于 configure-justfile
configure-justfile 是面向开发者和编码 Agent 的技能,用于按项目约定检查和配置 Justfile。它能根据检测到的项目类型创建或更新配方与设置。
主要功能
- 01检测项目类型和任务文件
- 02审查必需及可选配方
- 03检查 Justfile 设置与注释
- 04创建或更新配方
- 05支持从 Makefile 迁移
- 06支持仅检查或自动修复
适用场景
- 01为新项目创建 Justfile
- 02按团队约定审查配方
- 03将任务定义从 Makefile 迁移
- 04在 CI 中检查任务运行器规范
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ laurigates/ claude-plugins --skill configure-justfile安装后在 Claude Code 中输入/configure-justfile确认已加载。
详细介绍
/configure:justfile
根据项目标准检查并配置项目 Justfile。
何时使用此技能
| 在以下情况下使用此技能…… | 在以下情况下采用其他方法…… |
|---|---|
| 为项目设置新的 Justfile | 项目已完全使用 Make,且不打算迁移——使用 /configure:makefile |
| 审查现有 Justfile,检查是否缺少标准配方 | 编写复杂的自定义配方——使用 justfile-expert 技能 |
| 从 Makefile 迁移到 Justfile | 项目不需要任务运行器(单文件脚本) |
| 确保 Justfile 遵循团队约定(分组、注释、设置) | 调试特定配方故障——直接使用 just 命令 |
| 对项目任务运行器执行 CI/CD 合规性检查 | 只需列出可用配方——直接运行 just --list |
上下文
- 项目根目录:!
pwd - Justfile:!
find . -maxdepth 1 \( -name 'justfile' -o -name 'Justfile' \) - Makefile:!
find . -maxdepth 1 -name 'Makefile' - 软件包文件:!
find . -maxdepth 1 \( -name 'package.json' -o -name 'pyproject.toml' -o -name 'Cargo.toml' -o -name 'go.mod' \) - Docker 文件:!
find . -maxdepth 1 \( -name 'Dockerfile' -o -name 'docker-compose.yml' \) - 环境文件:!
find . -maxdepth 1 -name '.env' - 项目标准:!
find . -maxdepth 1 -name '.project-standards.yaml'
参数
从命令参数中解析:
--check-only:报告合规状态,不进行修改(CI/CD 模式)--fix:自动应用修复,不提示确认
执行
执行此 Justfile 合规性检查:
第 1 步:检测 Justfile 和项目类型
- 检查项目根目录中是否存在
justfile或Justfile - 如果存在,读取并分析当前配方和设置
- 根据文件标识检测项目类型:
| 标识 | 项目类型 |
|---|---|
pyproject.toml 或 requirements.txt | Python |
package.json | Node.js |
Cargo.toml | Rust |
go.mod | Go |
| 以上均无 | 通用 |
第 2 步:分析必需和可选配方
检查必需配方:
| 配方 | 用途 | 严重级别 |
|---|---|---|
default | 帮助命令的别名(第一个配方) | 缺失则失败 |
help | 显示可用配方 | 缺失则失败 |
test | 运行测试套件 | 缺失则失败 |
lint | 运行代码检查工具 | 缺失则失败 |
build | 构建项目产物 | 缺失则警告 |
clean | 删除临时文件 | 缺失则警告 |
检查依赖上下文的配方:
| 配方 | 必需条件 | 严重级别 |
|---|---|---|
format | 项目使用自动格式化工具时 | 警告 |
start | 项目有可运行的服务时 | 信息 |
stop | 项目有后台服务时 | 信息 |
dev | 项目支持监视模式时 | 信息 |
第 3 步:检查合规性设置
验证 Justfile 设置:
| 检查项 | 标准 | 严重级别 |
|---|---|---|
| 文件存在 | 存在 justfile | 缺失则失败 |
| 默认配方 | 第一个配方是 default | 缺失则警告 |
| 加载 dotenv | 存在 set dotenv-load | 信息 |
| 帮助配方 | 列出所有配方 | 缺失则失败 |
| 特定语言配置 | 命令与项目类型匹配 | 不匹配则失败 |
| 配方注释 | 配方带有说明 | 信息 |
第 4 步:生成合规性报告
打印格式化的合规性报告:
Justfile Compliance Report
==============================
Project Type: python (detected)
Justfile: Found
Recipe Status:
default ✅ PASS
help ✅ PASS (just --list)
test ✅ PASS (uv run pytest)
lint ✅ PASS (uv run ruff check)
build ✅ PASS (docker build)
clean ✅ PASS
format ✅ PASS (uv run ruff format)
start ⚠️ INFO (not applicable)
stop ⚠️ INFO (not applicable)
dev ✅ PASS (uv run uvicorn --reload)
Settings Status:
dotenv-load ✅ PASS
positional-arguments ℹ️ INFO (not set)
Missing Recipes: none
Issues: 0 found
如果指定了 --check-only,则在此处停止。
第 5 步:创建或更新 Justfile(如果指定了 --fix 或用户确认)
如果指定了 --fix 标志或用户确认:
- 缺少 Justfile:根据项目类型从标准模板创建
- 缺少配方:添加带有适当命令的配方
- 缺少设置:如果存在
.env,则添加set dotenv-load - 缺少帮助配方:添加使用
just --list的帮助配方
使用下方模板部分中的特定语言命令。
第 6 步:更新标准跟踪记录
更新 .project-standards.yaml:
components:
justfile: "2025.1"
Justfile 模板
通用结构
# Justfile for {{PROJECT_NAME}}
# Run `just` or `just help` to see available recipes
set dotenv-load
set positional-arguments
# Default recipe - show help
default:
@just --list
# Show available recipes with descriptions
help:
@just --list --unsorted
####################
# Development
####################
# Run linters
lint:
{{LINT_COMMAND}}
# Format code
format:
{{FORMAT_COMMAND}}
# Run tests
test *args:
{{TEST_COMMAND}} {{args}}
# Development mode with watch
dev:
{{DEV_COMMAND}}
####################
# Build & Deploy
####################
# Build project
build:
{{BUILD_COMMAND}}
# Clean build artifacts
clean:
{{CLEAN_COMMAND}}
# Start service
start:
{{START_COMMAND}}
# Stop service
stop:
{{STOP_COMMAND}}
特定语言的命令
Python(基于 uv):
lint:
uv run ruff check .
format:
uv run ruff format .
uv run ruff check --fix .
test *args:
uv run pytest {{args}}
dev:
uv run uvicorn app:app --reload
build:
docker build -t {{PROJECT_NAME}} .
clean:
find . -type f -name "*.pyc" -delete
find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
rm -rf .pytest_cache .ruff_cache .coverage htmlcov dist build *.egg-info
Node.js(基于 Bun):
lint:
bun run lint
format:
bun run format
test *args:
bun test {{args}}
dev:
bun run dev
build:
bun run build
clean:
rm -rf node_modules dist .next .turbo .cache
Rust:
lint:
cargo clippy -- -D warnings
format:
cargo fmt
test *args:
cargo nextest run {{args}}
dev:
cargo watch -x run
build:
cargo build --release
clean:
cargo clean
Go:
lint:
golangci-lint run
format:
gofmt -s -w .
goimports -w .
test *args:
go test ./... {{args}}
dev:
air
build:
go build -o bin/{{PROJECT_NAME}} ./cmd/{{PROJECT_NAME}}
clean:
rm -rf bin dist
go clean -cache
检测逻辑
服务检测(需要启动/停止):
- 存在
docker-compose.yml→ Docker Compose 服务 - 存在
Dockerfile+ HTTP 服务端代码 → 容器服务 - 存在
src/server.*或src/main.*→ 应用服务
开发模式检测:
- Python:存在 FastAPI/Flask/Django → 使用带热重载的 uvicorn/flask/manage.py
- Node:package.json 中存在
dev脚本 - Rust:依赖项中存在
cargo-watch - Go:存在
air.toml或main.go
从 Makefile 迁移
如果存在 Makefile,但没有 Justfile:
- 根据 Makefile 命令检测项目类型
- 建议创建包含等效配方的 Justfile
- 可选择保留 Makefile,以实现向后兼容
Agentic 优化
| 上下文 | 命令 |
|---|---|
| 快速合规性检查 | /configure:justfile --check-only |
| 自动修复所有问题 | /configure:justfile --fix |
| 列出现有配方 | just --list |
| 验证特定配方是否存在 | just --summary |
| 检查 Justfile 语法 | just --evaluate 2>&1 |
标志
| 标志 | 说明 |
|---|---|
--check-only | 报告状态,但不提供修复方案 |
--fix | 自动应用修复 |
示例
# Check current Justfile compliance
/configure:justfile --check-only
# Create/update Justfile for Python project
/configure:justfile --fix
# Check compliance and prompt for fixes
/configure:justfile
另请参阅
/configure:makefile- Makefile 配置(旧版)/configure:all- 运行所有合规性检查/configure:workflows- GitHub Actions 工作流/configure:dockerfile- Docker 配置justfile-expert技能 - 全面的 Just 专业知识
评论
支持 Markdown