AgentSkillsCN

justfile-dev

为 just 命令行工具编写、审查并规划 Justfile。当您需要创建新的 Justfile、添加配方、审查现有 Justfile 的质量、为新项目规划配方集,或随着项目成熟逐步升级 Justfile 时,可选用此技能。它涵盖语法模式、模块系统、配方组、特定语言的模板,以及成熟度评估。

SKILL.md
--- frontmatter
name: justfile-dev
description: >-
  Justfile authoring, reviewing, and planning for the just command runner.
  Use when creating new justfiles, adding recipes, reviewing existing justfiles
  for quality, planning recipe sets for new projects, or upgrading justfiles
  as projects mature. Covers syntax patterns, module system, recipe groups,
  language-specific templates, and maturity assessment.

Justfile Development

Workflows for authoring, reviewing, planning, and updating justfiles with the just command runner.

When to Use

  • Creating a new justfile for a project
  • Adding or modifying recipes
  • Reviewing a justfile for quality issues
  • Planning which recipes a project needs
  • Upgrading a justfile as a project matures
  • Converting a Makefile to a justfile
  • Setting up monorepo module structure

Workflows

Author

When creating a new justfile or adding recipes.

New Justfile Scaffold:

just
set shell := ["bash", "-cu"]

default:
    @just --list

# =============================================================================
# Development
# =============================================================================

# Build the project
[group('dev')]
build:
    <build-command>

# =============================================================================
# Testing
# =============================================================================

# Run test suite
[group('test')]
test:
    <test-command>

# =============================================================================
# Code Quality
# =============================================================================

# Format code
[group('lint')]
fmt:
    <fmt-command>

# Run linter
[group('lint')]
lint:
    <lint-command>

# =============================================================================
# Utilities
# =============================================================================

# Remove build artifacts
[group('util')]
[confirm('Remove all build artifacts?')]
clean:
    <clean-command>

Recipe Writing Rules:

RuleExample
Always add [group('name')][group('dev')]
Doc comment above every recipe# Build the project
Private helpers start with __ensure-tool name:
[confirm] on destructive ops[confirm('Delete all?')]
Prefer parameters over env varsrecipe name='default':
Single responsibilityCompose with dependencies
No && chainingUse separate lines or deps
No cdUse [working-directory]

Adding Recipes to Existing Justfiles:

  1. Identify the correct group (see Standard Groups below)
  2. Place recipe near related recipes in the same section
  3. Add doc comment
  4. Add [group] attribute
  5. If destructive, add [confirm]

Review

Use this checklist when reviewing justfiles.

markdown
## Justfile Review

- [ ] `set shell` declared at top
- [ ] All recipes grouped with `[group('name')]`
- [ ] Every recipe has a doc comment
- [ ] No ungrouped recipes (except `default`)
- [ ] Private helpers prefixed with `_`
- [ ] Destructive recipes use `[confirm]`
- [ ] No `cd` usage (use `[working-directory]`)
- [ ] No `&&` chaining (use dependencies or separate lines)
- [ ] No secrets in justfile (env vars or `op://`)
- [ ] `default` recipe shows `just --list`
- [ ] Section separators between groups
- [ ] Recipe names are kebab-case
- [ ] No monolithic recipes (compose from focused ones)
- [ ] Parameters preferred over env vars for inputs

Common Issues:

IssueFix
Missing set shellAdd set shell := ["bash", "-cu"] at top
Ungrouped recipesAdd [group('name')] attribute
Missing doc commentsAdd # Description above recipe
cd in recipe bodyUse [working-directory('path')]
&& chainingSplit into separate lines or deps
Hardcoded secretsReplace with env('VAR') or op://
God recipe doing everythingSplit into focused recipes, compose with deps

Plan

Use when deciding what recipes a project needs.

3-Question Assessment:

QuestionYesNo
Has CI?Add quality gates (coverage, check-all)Skip quality recipes
Deploys to prod?Add security + deploy recipesSkip deploy/security
Multiple languages?Add module structureKeep single justfile

Recipe Sets by Project Type:

Project TypeBaselineQualityDeployModules
Rust CLIbuild, test, lint, fmt, cleancoverage, bench, releasedocker
Rust libbuild, test, lint, fmt, docscoverage, benchrelease
Web appbuild, test, lint, fmt, devcoveragedocker, deployif polyglot
Monorepoorchestrate, defaultper-packageper-serviceyes
MCP serverbuild, test, lint, fmtcoveragedocker, release

Decision: Single File vs Modules:

CriteriaSingle justfileModules
Recipe count< 20> 20
Languages12+
Repo structureflatmonorepo/workspace
Shared recipesnoneCDN imports needed

Convert

When migrating from a Makefile to a justfile.

Steps:

  1. Map targets to recipes (all recipes are phony — no .PHONY needed)
  2. Add set shell := ["bash", "-cu"] at top
  3. Add default recipe with @just --list
  4. Group recipes with [group('name')] and add section separators
  5. Add doc comments above each recipe
  6. Fix anti-patterns (see translations below)
  7. Add [confirm] to destructive recipes
  8. Validate: just --list shows grouped, documented recipes

Makefile → just Translations:

Makefilejust
.PHONY: targetNot needed (all recipes are phony)
target: dep1 dep2recipe: dep1 dep2 (same syntax)
cd dir && cmd[working-directory('dir')] attribute
cmd1 && cmd2Separate lines in recipe body
$(VAR){{VAR}}
@echo "msg"@echo "msg" (same)
export VAR=valexport VAR := "val" at top
include file.mkimport "file.just"

Update

When upgrading an existing justfile.

Maturity Progression:

LevelWhenAdd
0: BaselineEvery projectdefault, build, test, lint, fmt, clean
1: QualityCI/CD addedcoverage, test-watch, check-all, bench
2: SecurityDeployingaudit, sbom, doctor
3: ProductionProd systemsdeploy, migrate, logs, status
4: PolyglotMulti-languagemodules, orchestration

YAGNI: Only add levels you currently need. Reassess when project scope changes.

Module Migration:

When a justfile exceeds ~20 recipes, consider splitting:

  1. Create just/ directory
  2. Move related recipes to just/<group>.just
  3. Add import? "just/<group>.just" to root justfile
  4. Or use CDN: mod name "https://just.arusty.dev/modules/<name>.just"

Quick Reference

Standard Groups

GroupPurposeTypical Recipes
devDevelopmentbuild, setup, install, watch, dev
testTestingtest, coverage, bench, test-watch
lintCode qualityfmt, lint, clippy, check
docsDocumentationdocs-build, docs-serve
dockerContainersdocker-build, docker-run, docker-push
releasePublishingrelease, version-bump, changelog
utilMaintenanceclean, update, doctor

Essential Syntax

FeatureSyntax
Settingsset shell := ["bash", "-cu"]
Groups[group('dev')]
Confirm[confirm('message')]
Working dir[working-directory('path')]
Private_recipe-name:
Parametersrecipe name:
Default paramsrecipe name='value':
Variadicrecipe *args:
Dependenciesrecipe: dep1 dep2
Param depsrecipe: (dep1 "arg")
Conditionalif os() == "macos" { ... }
Shebang#!/usr/bin/env python3
Script attr[script('python3')]
Optional importimport? "just/mod.just"
CDN modulemod name "https://url"

Common Functions

FunctionReturns
os()"linux", "macos", "windows"
arch()"x86_64", "aarch64"
env('VAR')Environment variable value
env('VAR', 'default')With fallback
justfile_directory()Dir containing justfile
invocation_directory()Dir where just was called

aRustyDev Conventions

  • Shell: always set shell := ["bash", "-cu"]
  • CDN modules from just.arusty.dev
  • Local modules in just/ with import?
  • Gist templates via just apply-gist (see gist-templates rule)
  • KuzuDB recipes follow graph-data-pattern rule

Language Patterns

Quick lookup — see references/recipe-patterns.md for full details.

RecipeRustGoTypeScriptPython
fmtcargo fmtgofmt -w .prettier --write .ruff format .
lintcargo clippygolangci-lint runeslint .ruff check .
testcargo testgo test ./...vitestpytest
buildcargo buildgo build ./...tscpython -m build
coveragecargo tarpaulingo test -covervitest --coveragepytest --cov

See Also

  • references/syntax-quick-ref.md — full syntax reference
  • references/recipe-patterns.md — recipe patterns by category and language
  • references/module-system.md — module system deep dive
  • references/maturity-model.md — maturity assessment details
  • examples/rust-project.just — complete Rust CLI/lib justfile
  • examples/monorepo-root.just — monorepo router pattern
  • examples/arustydev.just — aRustyDev conventions with gist templates
  • tables/standard-groups.md — group definitions and ordering
  • tables/language-recipes.md — Rust/Go/TS/Python recipe matrix