-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
163 lines (135 loc) · 4.78 KB
/
Taskfile.yml
File metadata and controls
163 lines (135 loc) · 4.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
version: "1"
name: ai-cursor
description: "AI-assisted development with Cursor IDE — rules, composer, review workflows"
variables:
APP: myapp
SRC: src/
TESTS: tests/
MODEL: claude-sonnet-4-20250514
environments:
local:
env_file: .env
tasks:
# ─── Project Setup for Cursor ──────────────────────────
init-rules:
desc: "Generate .cursor/rules for this project"
cmds:
- mkdir -p .cursor
- |
cat > .cursor/rules <<'EOF'
You are working on a Python project managed by taskfile.
Project structure:
- src/ — source code
- tests/ — pytest tests
- Taskfile.yml — task runner configuration
- .env — environment variables
Conventions:
- Use Google-style docstrings
- Type hints on all public functions
- pytest for testing, ruff for linting
- Keep functions under 30 lines
- Use dataclasses or Pydantic models
When writing code:
- Always add tests for new functions
- Use pathlib instead of os.path
- Prefer composition over inheritance
- Handle errors with specific exceptions
Available taskfile commands:
- taskfile run test — run tests
- taskfile run lint — run linter
- taskfile run build — build Docker image
- taskfile doctor — diagnose issues
- taskfile doctor --fix --llm — auto-fix with AI
EOF
- echo "✓ Created .cursor/rules"
init-context:
desc: "Generate .cursorrules (legacy) for project context"
cmds:
- |
cat > .cursorrules <<'EOF'
# Project: ${APP}
## Stack
- Python 3.12, pytest, ruff
- Docker, docker compose
- taskfile for task automation
## Key Files
- Taskfile.yml — all build/test/deploy tasks
- src/ — application source
- tests/ — test files mirror src/ structure
## Testing
Run: taskfile run test
Tests use: pytest, pytest-cov, faker
## Deploy
Local: taskfile --env local run deploy
Staging: taskfile --env staging run deploy
Prod: taskfile --env prod run deploy
EOF
- echo "✓ Created .cursorrules"
# ─── Composer Workflows ────────────────────────────────
composer-feature:
desc: "Prepare context for Cursor Composer (pass --var FEATURE='...')"
cmds:
- echo "=== Taskfile Config ==="
- cat Taskfile.yml
- echo ""
- echo "=== Current Tests ==="
- find ${TESTS} -name '*.py' -exec echo "--- {} ---" \; -exec head -20 {} \;
- echo ""
- echo "=== Feature Request ==="
- echo "${FEATURE}"
- echo ""
- echo "Copy the above context into Cursor Composer with your prompt."
# ─── Quality Gates (run from Cursor terminal) ──────────
test:
desc: "Run tests (use in Cursor terminal)"
cmds:
- pytest ${TESTS} -v --tb=short --color=yes
test-watch:
desc: "Watch tests (run in Cursor terminal)"
cmds:
- ptw ${TESTS} -- -v --tb=short
lint:
desc: "Lint + auto-fix"
cmds:
- ruff check ${SRC} --fix
- ruff format ${SRC}
typecheck:
desc: "Type check"
cmds:
- mypy ${SRC} --pretty
check-all:
desc: "Run all quality checks"
deps: [lint, typecheck, test]
cmds:
- echo "✓ All checks passed"
# ─── Cursor + Taskfile Integration ─────────────────────
doctor:
desc: "Diagnose project — output useful for Cursor chat"
cmds:
- taskfile doctor --report 2>&1 | python3 -c "
import sys, json;
data = json.load(sys.stdin);
issues = data.get('issues', []);
print(f'Found {len(issues)} issues:');
[print(f' [{i[\"category\"]}] {i[\"message\"]}') for i in issues]
" || taskfile doctor
doctor-fix:
desc: "Auto-fix + AI suggestions"
cmds:
- taskfile doctor --fix --llm
# ─── Git Workflows ────────────────────────────────────
pre-commit:
desc: "Pre-commit hook (configure in .git/hooks/pre-commit)"
cmds:
- ruff check ${SRC} --fix --quiet
- ruff format ${SRC} --quiet
- pytest ${TESTS} -x -q --tb=line
commit-msg:
desc: "Show diff summary for commit message writing"
cmds:
- echo "=== Staged Changes ==="
- git diff --staged --stat
- echo ""
- git diff --staged --shortstat
- echo ""
- 'echo "Paste this into Cursor chat: Write a conventional commit message for these changes"'