mcpField
C
configure-justfile

configure-justfile

github.com/laurigates开发5953 次安装1 天前更新
代码仓库

关于 configure-justfile

configure-justfile 是面向开发者和编码 Agent 的技能,用于按项目约定检查和配置 Justfile。它能根据检测到的项目类型创建或更新配方与设置。

主要功能

  1. 01检测项目类型和任务文件
  2. 02审查必需及可选配方
  3. 03检查 Justfile 设置与注释
  4. 04创建或更新配方
  5. 05支持从 Makefile 迁移
  6. 06支持仅检查或自动修复

适用场景

  1. 01为新项目创建 Justfile
  2. 02按团队约定审查配方
  3. 03将任务定义从 Makefile 迁移
  4. 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 和项目类型
  1. 检查项目根目录中是否存在 justfile 或 Justfile
  2. 如果存在,读取并分析当前配方和设置
  3. 根据文件标识检测项目类型:
标识项目类型
pyproject.toml 或 requirements.txtPython
package.jsonNode.js
Cargo.tomlRust
go.modGo
以上均无通用
第 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 标志或用户确认:

  1. 缺少 Justfile:根据项目类型从标准模板创建
  2. 缺少配方:添加带有适当命令的配方
  3. 缺少设置:如果存在 .env,则添加 set dotenv-load
  4. 缺少帮助配方:添加使用 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:

  1. 根据 Makefile 命令检测项目类型
  2. 建议创建包含等效配方的 Justfile
  3. 可选择保留 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