justfile-expert
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseJustfile Expert
Justfile 专家
Expert knowledge for Just command runner, recipe development, and task automation with focus on cross-platform compatibility and project standardization.
精通Just命令运行器、Recipe开发和任务自动化,重点关注跨平台兼容性与项目标准化。
When to Use This Skill
何时使用该技能
| Use this skill when... | Use alternative when... |
|---|---|
| Creating/editing justfiles for task automation | Need build system with incremental compilation → Make |
| Writing cross-platform project commands | Need tool version management bundled → mise tasks |
| Adding shebang recipes (Python, Node, Ruby, etc.) | Already using mise for all project tooling |
| Configuring dotenv loading and settings | Simple one-off shell scripts → Bash directly |
| Setting up CI/CD with just recipes | Project already has extensive Makefile |
| Standardizing recipes across projects | Need Docker-specific workflows → docker-compose |
| 适用场景 | 替代方案场景 |
|---|---|
| 为任务自动化创建/编辑justfiles | 需要支持增量编译的构建系统 → 使用Make |
| 编写跨平台项目命令 | 需要捆绑工具版本管理 → 使用mise tasks |
| 添加shebang Recipe(Python、Node、Ruby等) | 已使用mise管理所有项目工具 |
| 配置dotenv加载与设置 | 简单一次性Shell脚本 → 直接使用Bash |
| 使用just Recipe搭建CI/CD | 项目已有完善的Makefile |
| 跨项目标准化Recipe | 需要Docker专属工作流 → 使用docker-compose |
Core Expertise
核心能力
Command Runner Mastery
- Justfile syntax and recipe structure
- Cross-platform task automation (Linux, macOS, Windows)
- Parameter handling and argument forwarding
- Module organization for large projects
Recipe Development Excellence
- Recipe patterns for common operations
- Dependency management between recipes
- Shebang recipes for complex logic
- Environment variable integration
Project Standardization
- Golden template with standard naming and section structure
- Self-documenting project operations
- Portable patterns across projects
- Integration with CI/CD pipelines
命令运行器精通
- Justfile语法与Recipe结构
- 跨平台任务自动化(Linux、macOS、Windows)
- 参数处理与参数转发
- 大型项目的模块组织
Recipe开发进阶
- 通用操作的Recipe模式
- Recipe间的依赖管理
- 复杂逻辑的shebang Recipe
- 环境变量集成
项目标准化
- 含标准命名与章节结构的黄金模板
- 自文档化的项目操作
- 跨项目可移植的模式
- 与CI/CD流水线的集成
Recipe Naming Conventions
Recipe命名规范
| Rule | Pattern | Examples |
|---|---|---|
| Hyphen-separated | | |
| Verb-first (actions) | | |
| Noun-first (categories) | | |
| Private prefix | | |
| Read-only verification | |
| Auto-correction | |
| Watch mode | |
| Modifiers after base | | |
| 规则 | 格式 | 示例 |
|---|---|---|
| 连字符分隔 | | |
| 动词开头(动作类) | | |
| 名词开头(分类类) | | |
| 私有前缀 | | |
| 只读校验 | |
| 自动修正 | |
| 监听模式 | |
| 修饰符后置 | | |
Semantic Workflow Recipes
语义化工作流Recipe
Standard composite recipes with defined meanings:
| Recipe | Composition | Purpose |
|---|---|---|
| | Code quality only, no tests |
| | Fast, non-mutating validation |
| | Full CI simulation |
| Remove build artifacts | Partial cleanup |
| | Full cleanup |
just
undefined具有明确含义的标准组合Recipe:
| Recipe | 组合 | 用途 |
|---|---|---|
| | 仅代码质量检查,不包含测试 |
| | 快速、非破坏性的校验 |
| | 完整CI模拟 |
| 删除构建产物 | 部分清理 |
| | 完全清理 |
just
undefinedComposite: code quality only (no tests)
Composite: code quality only (no tests)
check: format-check lint typecheck
check: format-check lint typecheck
Pre-commit checks (fast, non-mutating)
Pre-commit checks (fast, non-mutating)
pre-commit: format-check lint typecheck test-unit
@echo "Pre-commit checks passed"
pre-commit: format-check lint typecheck test-unit
@echo "Pre-commit checks passed"
Full CI simulation
Full CI simulation
ci: check test-coverage build
@echo "CI simulation passed"
ci: check test-coverage build
@echo "CI simulation passed"
Clean build artifacts
Clean build artifacts
clean:
rm -rf dist build .next
clean:
rm -rf dist build .next
Clean everything including deps
Clean everything including deps
clean-all: clean
rm -rf node_modules .venv pycache
undefinedclean-all: clean
rm -rf node_modules .venv pycache
undefinedKey Capabilities
关键功能
Recipe Parameters
- Required parameters: - must be provided
recipe param: - Default values: - optional with fallback
recipe param="default": - Variadic :
+- one or more argumentsrecipe +FILES: - Variadic :
*- zero or more argumentsrecipe *FLAGS: - Environment export: - parameter as env var
recipe $VAR:
Settings Configuration
- : Load
set dotenv-loadfile automatically.env - : Enable
set positional-arguments,$1syntax$2 - : Export all variables as env vars
set export - : Custom shell interpreter
set shell - : Suppress command echoing
set quiet
Recipe Attributes
- : Hide from
[private]output--list - : Don't change directory
[no-cd] - : Suppress exit messages
[no-exit-message] - /
[unix]/[windows]/[linux]: Platform-specific recipes[macos] - : Per-recipe positional args
[positional-arguments] - /
[confirm]: Require confirmation before running[confirm("message")] - : Group recipes in
[group: "name"]output--list - : Run in specific directory
[working-directory: "path"]
Module System
- : Declare submodule
mod name - : Custom module path
mod name 'path' - Invocation: or
just module::recipejust module recipe
Recipe参数
- 必填参数:- 必须传入
recipe param: - 默认值:- 可选,含回退值
recipe param="default": - 可变参数:
+- 一个或多个参数recipe +FILES: - 可变参数:
*- 零个或多个参数recipe *FLAGS: - 环境变量导出:- 参数作为环境变量
recipe $VAR:
设置配置
- :自动加载
set dotenv-load文件.env - :启用
set positional-arguments,$1语法$2 - :导出所有变量为环境变量
set export - :自定义Shell解释器
set shell - :抑制命令回显
set quiet
Recipe属性
- :在
[private]输出中隐藏--list - :不切换目录
[no-cd] - :抑制退出提示
[no-exit-message] - /
[unix]/[windows]/[linux]:特定平台的Recipe[macos] - :针对单个Recipe的位置参数
[positional-arguments] - /
[confirm]:运行前需确认[confirm("message")] - :在
[group: "name"]输出中分组显示Recipe--list - :在指定目录运行
[working-directory: "path"]
模块系统
- :声明子模块
mod name - :自定义模块路径
mod name 'path' - 调用方式:或
just module::recipejust module recipe
Essential Syntax
基础语法
Basic Recipe Structure
just
undefined基础Recipe结构
just
undefinedComment describes the recipe
Comment describes the recipe
recipe-name:
command1
command2
**Recipe with Parameters**
```just
build target:
@echo "Building {{target}}..."
cd {{target}} && make
test *args:
uv run pytest {{args}}Recipe Dependencies
just
default: build test
build: _setup
cargo build --release
_setup:
@echo "Setting up..."Variables and Interpolation
just
version := "1.0.0"
project := env('PROJECT_NAME', 'default')
info:
@echo "Project: {{project}} v{{version}}"Conditional Recipes
just
[unix]
open:
xdg-open http://localhost:8080
[windows]
open:
start http://localhost:8080recipe-name:
command1
command2
**带参数的Recipe**
```just
build target:
@echo "Building {{target}}..."
cd {{target}} && make
test *args:
uv run pytest {{args}}Recipe依赖
just
default: build test
build: _setup
cargo build --release
_setup:
@echo "Setting up..."变量与插值
just
version := "1.0.0"
project := env('PROJECT_NAME', 'default')
info:
@echo "Project: {{project}} v{{version}}"条件Recipe
just
[unix]
open:
xdg-open http://localhost:8080
[windows]
open:
start http://localhost:8080Standard Recipes
标准Recipe
Every project should provide these standard recipes, organized by section:
just
undefined每个项目都应提供以下标准Recipe,按章节组织:
just
undefinedJustfile - Project task runner
Justfile - Project task runner
Run just
or just help
to see available recipes
justjust helpRun just
or just help
to see available recipes
justjust helpset dotenv-load
set positional-arguments
set dotenv-load
set positional-arguments
Default recipe - show help
Default recipe - show help
default:
@just --list
default:
@just --list
Show available recipes with descriptions
Show available recipes with descriptions
help:
@just --list --unsorted
####################
help:
@just --list --unsorted
####################
Development
Development
####################
####################
Start development environment
Start development environment
dev:
# bun run dev / uv run uvicorn app:app --reload / skaffold dev
dev:
# bun run dev / uv run uvicorn app:app --reload / skaffold dev
Build for production
Build for production
build:
# bun run build / cargo build --release / docker build
build:
# bun run build / cargo build --release / docker build
Clean build artifacts
Clean build artifacts
clean:
# rm -rf dist build .next
####################
clean:
# rm -rf dist build .next
####################
Code Quality
Code Quality
####################
####################
Run linter (read-only)
Run linter (read-only)
lint *args:
# bun run lint / uv run ruff check {{args}}
lint *args:
# bun run lint / uv run ruff check {{args}}
Auto-fix lint issues
Auto-fix lint issues
lint-fix:
# bun run lint:fix / uv run ruff check --fix .
lint-fix:
# bun run lint:fix / uv run ruff check --fix .
Format code (mutating)
Format code (mutating)
format *args:
# bun run format / uv run ruff format {{args}}
format *args:
# bun run format / uv run ruff format {{args}}
Check formatting without modifying (non-mutating)
Check formatting without modifying (non-mutating)
format-check *args:
# bun run format:check / uv run ruff format --check {{args}}
format-check *args:
# bun run format:check / uv run ruff format --check {{args}}
Type checking
Type checking
typecheck:
# bunx tsc --noEmit / uv run basedpyright
####################
typecheck:
# bunx tsc --noEmit / uv run basedpyright
####################
Testing
Testing
####################
####################
Run all tests
Run all tests
test *args:
# bun test {{args}} / uv run pytest {{args}}
test *args:
# bun test {{args}} / uv run pytest {{args}}
Run unit tests only
Run unit tests only
test-unit *args:
# bun test --grep unit {{args}} / uv run pytest -m unit {{args}}
####################
test-unit *args:
# bun test --grep unit {{args}} / uv run pytest -m unit {{args}}
####################
Workflows
Workflows
####################
####################
Composite: code quality (no tests)
Composite: code quality (no tests)
check: format-check lint typecheck
check: format-check lint typecheck
Pre-commit checks (fast, non-mutating)
Pre-commit checks (fast, non-mutating)
pre-commit: format-check lint typecheck test-unit
@echo "Pre-commit checks passed"
pre-commit: format-check lint typecheck test-unit
@echo "Pre-commit checks passed"
Full CI simulation
Full CI simulation
ci: check test-coverage build
@echo "CI simulation passed"
undefinedci: check test-coverage build
@echo "CI simulation passed"
undefinedSection Structure
章节结构
Organize recipes into these standard sections:
| Section | Recipes | Purpose |
|---|---|---|
| Metadata | | Discovery and navigation |
| Development | | Core dev cycle |
| Code Quality | | Code standards |
| Testing | | Test tiers |
| Workflows | | Composite operations |
| Dependencies | | Package management |
| Database | | Data operations |
| Kubernetes | | Container orchestration |
| Documentation | | Project docs |
Use comment blocks as section dividers for readability.
####################按以下标准章节组织Recipe:
| 章节 | Recipe | 用途 |
|---|---|---|
| 元数据 | | 发现与导航 |
| 开发 | | 核心开发周期 |
| 代码质量 | | 代码标准 |
| 测试 | | 测试层级 |
| 工作流 | | 组合操作 |
| 依赖 | | 包管理 |
| 数据库 | | 数据操作 |
| Kubernetes | | 容器编排 |
| 文档 | | 项目文档 |
使用注释块作为章节分隔符以提升可读性。
####################Common Patterns
常见模式
Setup/Bootstrap Recipe
just
undefined初始化/引导Recipe
just
undefinedInitial project setup
Initial project setup
setup:
#!/usr/bin/env bash
set -euo pipefail
echo "Installing dependencies..."
uv sync
echo "Setting up pre-commit..."
pre-commit install
echo "Done!"
**Docker Integration**
```justsetup:
#!/usr/bin/env bash
set -euo pipefail
echo "Installing dependencies..."
uv sync
echo "Setting up pre-commit..."
pre-commit install
echo "Done!"
**Docker集成**
```justBuild container image
Build container image
docker-build tag="latest":
docker build -t {{project}}:{{tag}} .
docker-build tag="latest":
docker build -t {{project}}:{{tag}} .
Run container
Run container
docker-run tag="latest" *args:
docker run --rm -it {{project}}:{{tag}} {{args}}
docker-run tag="latest" *args:
docker run --rm -it {{project}}:{{tag}} {{args}}
Push to registry
Push to registry
docker-push tag="latest":
docker push {{registry}}/{{project}}:{{tag}}
**Database Operations**
```justdocker-push tag="latest":
docker push {{registry}}/{{project}}:{{tag}}
**数据库操作**
```justRun database migrations
Run database migrations
db-migrate:
uv run alembic upgrade head
db-migrate:
uv run alembic upgrade head
Create new migration
Create new migration
db-revision message:
uv run alembic revision --autogenerate -m "{{message}}"
db-revision message:
uv run alembic revision --autogenerate -m "{{message}}"
Reset database
Reset database
db-reset:
uv run alembic downgrade base
uv run alembic upgrade head
**CI/CD Recipes**
```justdb-reset:
uv run alembic downgrade base
uv run alembic upgrade head
**CI/CD Recipe**
```justFull CI check (lint + test + build)
Full CI check (lint + test + build)
ci: lint test build
@echo "CI passed!"
ci: lint test build
@echo "CI passed!"
Release workflow
Release workflow
release version:
git tag -a "v{{version}}" -m "Release {{version}}"
git push origin "v{{version}}"
undefinedrelease version:
git tag -a "v{{version}}" -m "Release {{version}}"
git push origin "v{{version}}"
undefinedMCP Integration (just-mcp)
MCP集成(just-mcp)
The MCP server enables AI assistants to discover and execute justfile recipes through the Model Context Protocol, reducing context waste since the AI doesn't need to read the full justfile.
just-mcpInstallation:
bash
undefinedjust-mcp安装方式:
bash
undefinedVia npm
Via npm
npx just-mcp --stdio
npx just-mcp --stdio
Via pip/uvx
Via pip/uvx
uvx just-mcp --stdio
uvx just-mcp --stdio
Via cargo
Via cargo
cargo install just-mcp
**Claude Desktop configuration (`.claude/mcp.json`):**
```json
{
"mcpServers": {
"just-mcp": {
"command": "npx",
"args": ["-y", "just-mcp", "--stdio"]
}
}
}Available MCP Tools:
- - Discover all recipes and parameters
list_recipes - - Execute a recipe with arguments
run_recipe - - Get detailed recipe documentation
get_recipe_info - - Check for syntax errors
validate_justfile
cargo install just-mcp
**Claude桌面端配置(`.claude/mcp.json`):**
```json
{
"mcpServers": {
"just-mcp": {
"command": "npx",
"args": ["-y", "just-mcp", "--stdio"]
}
}
}可用MCP工具:
- - 发现所有Recipe与参数
list_recipes - - 传入参数执行Recipe
run_recipe - - 获取Recipe的详细文档
get_recipe_info - - 检查语法错误
validate_justfile
Agentic Optimizations
智能优化命令
| Context | Command |
|---|---|
| List all recipes | |
| Dry run (preview) | |
| Show variables | |
| JSON recipe list | |
| Verbose execution | |
| Specific justfile | |
| Working directory | |
| Choose interactively | |
| 场景 | 命令 |
|---|---|
| 列出所有Recipe | |
| 空运行(预览) | |
| 显示变量 | |
| JSON格式Recipe列表 | |
| 详细执行日志 | |
| 指定justfile | |
| 指定工作目录 | |
| 交互式选择 | |
Best Practices
最佳实践
Recipe Development Workflow
- Name clearly: Use descriptive, verb-based names (,
build,test)deploy - Document always: Add comment before each recipe
- Use defaults: Provide sensible default parameter values
- Group logically: Organize with section comments
- Hide internals: Mark helper recipes as
[private] - Test portability: Verify on all target platforms
Critical Guidelines
- Always provide recipe pointing to help
default - Use prefix to suppress command echo when appropriate
@ - Use shebang recipes for multi-line logic
- Prefer for configuration
set dotenv-load - Use modules for large projects (>20 recipes)
- Include variadic for passthrough flexibility
*args - Quote all variables in shell commands
Recipe开发流程
- 命名清晰:使用描述性的动词式名称(,
build,test)deploy - 始终文档化:每个Recipe前添加注释
- 使用默认值:为参数提供合理的默认值
- 逻辑分组:使用章节注释组织Recipe
- 隐藏内部实现:将辅助Recipe标记为
[private] - 测试可移植性:在所有目标平台上验证
关键准则
- 始终提供指向帮助的Recipe
default - 适当使用前缀抑制命令回显
@ - 对于多行逻辑使用shebang Recipe
- 优先使用进行配置
set dotenv-load - 大型项目(超过20个Recipe)使用模块
- 包含可变参数以支持灵活的参数传递
*args - 在Shell命令中为所有变量添加引号
Comparison with Alternatives
与替代方案的对比
| Feature | Just | Make | mise tasks |
|---|---|---|---|
| Syntax | Simple, clear | Complex, tabs required | YAML |
| Dependencies | Built-in | Built-in | Manual |
| Parameters | Full support | Limited | Full support |
| Cross-platform | Excellent | Good | Excellent |
| Tool versions | No | No | Yes |
| Error messages | Clear | Cryptic | Clear |
| Installation | Single binary | Pre-installed | Requires mise |
When to use Just:
- Cross-project standard recipes
- Simple, readable task automation
- No tool version management needed
When to use mise tasks:
- Project-specific with tool version pinning
- Already using mise for tool management
When to use Make:
- Legacy projects with existing Makefiles
- Build systems requiring incremental compilation
For the golden justfile template, detailed syntax reference, advanced patterns, and troubleshooting, see REFERENCE.md.
| 特性 | Just | Make | mise tasks |
|---|---|---|---|
| 语法 | 简洁清晰 | 复杂,要求使用制表符 | YAML |
| 依赖 | 内置 | 内置 | 手动管理 |
| 参数支持 | 完整 | 有限 | 完整 |
| 跨平台性 | 优秀 | 良好 | 优秀 |
| 工具版本管理 | 无 | 无 | 有 |
| 错误提示 | 清晰 | 晦涩 | 清晰 |
| 安装方式 | 单二进制文件 | 预安装 | 需要安装mise |
何时使用Just:
- 跨项目的标准Recipe
- 简洁、易读的任务自动化
- 无需工具版本管理
何时使用mise tasks:
- 带工具版本固定的项目专属场景
- 已使用mise进行工具管理
何时使用Make:
- 已有Makefile的遗留项目
- 需要增量编译的构建系统
如需获取golden justfile模板、详细语法参考、进阶模式与故障排除内容,请查看REFERENCE.md。