Loading...
Loading...
This skill should be used when users want to create, convert, or manage Justfiles for command automation. It handles converting Makefile, npm scripts, or shell commands to Justfile format, generating project-specific templates, and providing Justfile syntax guidance. Triggers on requests mentioning justfile, just command, command runner, Makefile conversion, or task automation.
npx skill4agent add oldwinter/skills justfile# macOS
brew install just
# Linux
curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash
# 验证安装
just --versionjust # 运行默认 recipe
just --list # 列出所有 recipes
just <recipe> # 运行指定 recipe
just -n <recipe> # 干运行(只显示命令)用户需求
├── 已有 Makefile → 转换工作流
├── 已有 package.json → npm 转换工作流
├── 有常用 shell 命令 → 命令整理工作流
├── 新项目需要自动化 → 模板生成工作流
└── 需要了解语法 → 查阅 references/syntax.mdpython scripts/makefile_to_just.py Makefile justfile.PHONY$(VAR){{var}}$(shell cmd)`cmd`@# Makefile
.PHONY: build test
VERSION := $(shell git describe --tags)
build:
go build -ldflags "-X main.version=$(VERSION)"
test: build
go test ./...# justfile
version := `git describe --tags`
build:
go build -ldflags "-X main.version={{version}}"
test: build
go test ./...python scripts/npm_to_just.py package.json justfile{
"scripts": {
"dev": "vite",
"build": "vite build",
"test": "vitest",
"lint": "eslint ."
}
}set dotenv-load
default: dev
dev:
npm run dev
build:
npm run build
test:
npm run test
lint:
npm run lint
# 或者直接使用原始命令
dev:
vite
build:
vite buildpython scripts/shell_to_just.py --history justfile# 创建命令列表
cat > commands.txt << 'EOF'
docker-compose up -d
docker-compose logs -f
kubectl get pods -n production
kubectl logs -f deployment/api
EOF
python scripts/shell_to_just.py commands.txt justfile# === Docker ===
up:
docker-compose up -d
down:
docker-compose down
logs service="":
docker-compose logs -f {{service}}
# === Kubernetes ===
pods:
kubectl get pods -n production
logs-k8s pod:
kubectl logs -f {{pod}} -n production| 文件 | 项目类型 |
|---|---|
| Python |
| Node.js |
| Go |
| Rust |
| Docker |
| Kubernetes |
| Terraform |
references/templates.md# 必需参数
deploy env:
kubectl apply -k overlays/{{env}}
# 默认值参数
build mode="debug":
cargo build --{{mode}}
# 可变参数
test *args:
pytest {{args}}# 简单依赖
release: build test
./deploy.sh
# 带参数的依赖
push: (build "release")
docker push myapp:latest# 跨平台
[linux]
install:
apt install mypackage
[macos]
install:
brew install mypackage
# 确认提示
[confirm("确定要部署到生产环境吗?")]
deploy-prod:
kubectl apply -k overlays/prod[group('development')]
dev:
npm run dev
[group('development')]
watch:
npm run watch
[group('testing')]
test:
npm run test[script]
setup:
#!/usr/bin/env bash
set -euo pipefail
echo "Setting up environment..."
for pkg in curl git make; do
command -v $pkg || echo "Missing: $pkg"
done# 头部:设置和变量
set dotenv-load
set shell := ["bash", "-cu"]
project := "myapp"
version := `git describe --tags --always`
# 默认 recipe
default: dev
# 按功能分组,用注释分隔
# === 开发 ===
dev: ...
# === 构建 ===
build: ...
# === 测试 ===
test: ...build-prodrunbuildtestdeploy_helper# 启动开发服务器 (端口 3000)
dev:
npm run dev# 从环境变量读取,带默认值
env := env("ENV", "development")
# 从命令获取
commit := `git rev-parse --short HEAD`
# 条件变量
mode := if env == "prod" { "release" } else { "debug" }references/syntax.mdreferences/templates.mdscripts/makefile_to_just.pyscripts/npm_to_just.pyscripts/shell_to_just.py