Generate Taskfile.yml, Taskfile_dev.yml, and .pre-commit-config.yaml for Go projects with comprehensive task automation
From go-specialistnpx claudepluginhub sgaunet/claude-plugins --plugin go-specialist[--force] [--dry-run]Instantly create complete Task automation setup for Go projects including main Taskfile, development tasks, and pre-commit hooks configuration. This command provides a comprehensive task runner setup with linting, testing, building, and release automation.
Problem: Setting up task automation for Go projects requires manually creating Taskfile configuration, understanding Task syntax, and configuring pre-commit hooks - a 20-30 minute process.
Solution: One-command generation that:
CRITICAL: When generating any content (taskfiles, commit messages, or any other output):
Critical checks before proceeding:
Validate Git repository:
git rev-parse --git-dir
Validate Go project:
test -f go.mod
Check existing taskfiles:
test -f Taskfile.yml
test -f Taskfile_dev.yml
test -f .pre-commit-config.yaml
existingFiles = []hasExistingFiles = trueVerify command assets directory:
${CLAUDE_PLUGIN_ROOT}/commands/assets/taskfiles/Taskfile.yml existsCheck for supporting configs (non-blocking):
test -f .golangci.yml
test -f .goreleaser.yml
linterMissing = true (warn in Phase 6)goreleaserMissing = true (warn in Phase 6)Parse command arguments from $argument string:
Supported flags:
--force: Skip confirmation for existing files--dry-run: Show preview without writing filesParsing logic:
arguments = split($argument by space)
for each arg in arguments:
if arg == "--force": set forceMode = true
if arg == "--dry-run": set dryRunMode = true
Read all template files from command assets directory:
Files to read:
Taskfile.yml (66 lines)
${CLAUDE_PLUGIN_ROOT}/commands/assets/taskfiles/Taskfile.ymlTaskfile.yml (project root)Taskfile_dev.yml (14 lines)
${CLAUDE_PLUGIN_ROOT}/commands/assets/taskfiles/Taskfile_dev.ymlTaskfile_dev.yml (project root).pre-commit-config.yaml (25 lines)
${CLAUDE_PLUGIN_ROOT}/commands/assets/taskfiles/.pre-commit-config.yaml.pre-commit-config.yaml (project root)Template handling:
Error handling:
Detection Function Library: Use the shared detection functions from ${CLAUDE_PLUGIN_ROOT}/commands/assets/detection-functions.md. Read that file to get all bash detection functions (detect_project_name, detect_git_owner, detect_main_dir, detect_registry, substitute_placeholders).
Detection Workflow:
Detect all values:
PROJECT_NAME=$(detect_project_name)
OWNER=$(detect_git_owner)
REGISTRY=$(detect_registry)
MAIN_DIR=$(detect_main_dir)
Handle missing critical values:
PROJECT_NAME is empty: Use "app" as defaultOWNER is empty: Preserve [OWNER] placeholderSubstitute placeholders in Taskfile.yml template:
taskfile_template=$(substitute_placeholders "$taskfile_template" \
"$PROJECT_NAME" "$OWNER" "$REGISTRY" "$MAIN_DIR")
Detect pre-commit-hooks version:
PRE_COMMIT_HOOKS_VERSION=$(detect_pre_commit_hooks_version)
v4.3.0Substitute version placeholders in .pre-commit-config.yaml template:
precommit_template=$(substitute_version_placeholders "$precommit_template" \
"PRE_COMMIT_HOOKS_VERSION=${PRE_COMMIT_HOOKS_VERSION:-v4.3.0}")
Note: Taskfile_dev.yml has no placeholders
Build preview summary:
Files to be created:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅ Taskfile.yml (66 lines) - Main task definitions
✅ Taskfile_dev.yml (14 lines) - Development tasks
✅ .pre-commit-config.yaml (25 lines) - Git pre-commit hooks
Total: 3 files (105 lines)
✅ Auto-detected Configuration
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Project Settings:
• Project name: <PROJECT_NAME> (from go.mod)
• Binary name: <PROJECT_NAME>
• Main directory: <MAIN_DIR>
Repository Settings:
• Owner: <OWNER> (from git remote)
• Registry: <REGISTRY>
Task Categories:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔧 Development:
- default: List all available tasks
- check-before-commit: Run all quality checks
- lint: Run golangci-lint
- test: Run unit tests with race detection
- build: Build project binaries
📦 Release:
- snapshot: Create snapshot release (goreleaser)
- release: Create production release (goreleaser)
- image: Build and push Docker image
📚 Documentation:
- doc: Start godoc server
🛠️ Dev Tools (Taskfile_dev.yml):
- dev:install-pre-commit: Install pre-commit hooks
- dev:pre-commit: Run all pre-commit hooks manually
🎯 Pre-commit Hooks:
- check-yaml: Validate YAML syntax
- check-added-large-files: Prevent large files
- unit-tests: Run tests before commit
- lint: Run linter before commit
- build: Test build before commit
[If hasExistingFiles == true:]
⚠️ WARNING: Some files already exist and will be overwritten:
[List existing files]
Dry run mode:
If dryRunMode == true:
Confirmation logic:
If --force flag provided: Skip confirmation, proceed to Phase 5
If existing files without --force:
Use AskUserQuestion:
Question: "Task configuration files already exist. Overwrite?"
Options:
1. "Yes, overwrite files" [Recommended if upgrading]
2. "Show full preview first"
3. "Cancel"
If option 2: Display full content preview, then re-ask confirmation
If option 3: Exit gracefully
If no existing files:
Use AskUserQuestion:
Question: "Create task configuration files (3 files)?"
Options:
1. "Yes, create files"
2. "Show preview first"
3. "Cancel"
File writing sequence:
Write files in order:
Taskfile.yml
BINFILE: gitlab-backup with detected binary nameTaskfile_dev.yml
.pre-commit-config.yaml
For each file:
Error handling:
Track results:
successfulFiles = []
failedFiles = []
for each file:
try write:
if success: add to successfulFiles
if failure: add to failedFiles
Post-creation validation:
For each file in successfulFiles:
failedFilesGenerate success report:
[If all files succeeded:]
✅ Task Configuration Created Successfully
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Created Files:
✅ Taskfile.yml (66 lines, ready to use)
✅ Taskfile_dev.yml (14 lines)
✅ .pre-commit-config.yaml (25 lines)
Total: 3 files (105 lines)
Auto-configured with detected values:
✓ Project name: <PROJECT_NAME> (from go.mod)
✓ Binary name: <PROJECT_NAME>
✓ Main directory: <MAIN_DIR> (auto-detected)
✓ Owner: <OWNER> (from git remote)
✓ Registry: <REGISTRY>
✓ Pre-commit hooks version: <PRE_COMMIT_HOOKS_VERSION>
Available Tasks:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Run `task` or `task -a` to see all available tasks.
Key Tasks:
- task check-before-commit # Run all quality checks
- task lint # Run golangci-lint
- task test # Run unit tests with race detection
- task build # Build binaries
- task snapshot # Create test release
- task release # Create production release
- task doc # Start godoc server
- task dev:install-pre-commit # Install pre-commit hooks
- task dev:pre-commit # Run pre-commit hooks manually
Required Dependencies:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠️ Install these tools for full functionality:
1. Task (if not installed):
- macOS: brew install go-task
- Linux: sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b /usr/local/bin
- Or: go install github.com/go-task/task/v3/cmd/task@latest
2. pre-commit (for git hooks):
- macOS: brew install pre-commit
- Linux: pip install pre-commit
- After install: task dev:install-pre-commit
3. golangci-lint (for linting):
[If linterMissing == true:]
⚠️ .golangci.yml not found
- Generate with: /linter
- Or install: https://golangci-lint.run/usage/install/
4. goreleaser (for releases):
[If goreleaserMissing == true:]
⚠️ .goreleaser.yml not found
- Generate with: /goreleaser
- Or install: https://goreleaser.com/install/
Optional Customizations:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📝 Configuration is ready to use! Optional adjustments:
1. Multi-binary projects:
- If your project has multiple binaries, update the build task
- Example: Add separate build commands for each binary
2. Pre-commit hooks (.pre-commit-config.yaml):
- Uncomment trailing-whitespace and end-of-file-fixer if desired
- Customize which checks run before commits
3. Docker image settings (already auto-configured):
- Verify registry and image name match your preferences
- Auto-detected: <REGISTRY>/<OWNER>/<PROJECT_NAME>:latest
Pre-commit Hook Setup:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
To enable automatic quality checks on every commit:
1. Install pre-commit tool (see above)
2. Install hooks:
task dev:install-pre-commit
3. Test hooks:
task dev:pre-commit
4. Hooks will now run automatically on `git commit`
- Checks YAML syntax
- Prevents large files
- Runs unit tests
- Runs linter
- Runs snapshot build
To bypass hooks (emergency only):
git commit --no-verify -m "message"
Task Integration:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Tasks integrate with your development workflow:
- CI/CD pipelines can call: task lint, task test, task snapshot
- Pre-commit hooks run: task test, task lint, task snapshot
- Local development: task build, task doc
- Releases: task release (with git tags)
Next Steps:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1. Install Task runner (if not installed)
2. Review and customize Taskfile.yml
3. Install pre-commit: task dev:install-pre-commit
4. Generate missing configs:
- .golangci.yml: /linter
- .goreleaser.yml: /goreleaser
5. Test tasks:
task lint
task test
task build
6. Commit changes:
git add Taskfile*.yml .pre-commit-config.yaml
git commit -m "build: add task automation and pre-commit hooks"
7. Verify pre-commit hooks:
- Make a test change
- Run: git commit
- Hooks should run automatically
Documentation:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
- Task documentation: https://taskfile.dev
- Pre-commit documentation: https://pre-commit.com
- Task reference: Run `task -a` to list all tasks
[If partial success:]
⚠️ Task Configuration Partially Created
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Successfully Created:
[List successful files]
Failed to Create:
[List failed files with error messages]
Recommendation: Review errors and retry with --force flag
[If all files failed:]
❌ Task Configuration Creation Failed
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Errors:
[List all failures with details]
Possible causes:
- Insufficient permissions
- Disk space issues
- File system restrictions
Action: Check errors above and ensure write permissions in current directory
Arguments are parsed from the argument string parameter:
--force: Skip confirmation prompt and overwrite existing files
--dry-run: Preview files without writing to disk
Parsing example:
argument = "--force"
Split by space, check for each flag:
- forceMode = true
- dryRunMode = false
Not a Git repository:
❌ Error: Not a git repository
This command requires a Git repository. Initialize one:
git init
git add .
git commit -m "Initial commit"
Not a Go project:
❌ Error: go.mod not found
This command is for Go projects only. Initialize a Go module:
go mod init github.com/username/project
Command assets missing:
❌ Error: Command assets directory not found
The go-specialist plugin may be corrupted. Try:
1. Reinstalling the plugin
2. Updating Claude Code to latest version
3. Reporting issue at: https://github.com/sgaunet/claude-plugins/issues
Existing task files:
--force: Request user confirmation--force: Overwrite silentlyMissing .golangci.yml or .goreleaser.yml:
If file write fails:
❌ Error: Failed to write [filename]
Check:
1. Current directory is writable
2. Sufficient disk space
3. No file system restrictions
Current permissions: [show with ls -ld .]
| Source Path | Target (Relative to CWD) | Lines | Purpose |
|---|---|---|---|
${CLAUDE_PLUGIN_ROOT}/commands/assets/taskfiles/Taskfile.yml | Taskfile.yml | 66 | Main task definitions |
${CLAUDE_PLUGIN_ROOT}/commands/assets/taskfiles/Taskfile_dev.yml | Taskfile_dev.yml | 14 | Development tasks |
${CLAUDE_PLUGIN_ROOT}/commands/assets/taskfiles/.pre-commit-config.yaml | .pre-commit-config.yaml | 25 | Git pre-commit hooks |
Works with:
/commit: Commit generated taskfiles/linter: Generate .golangci.yml (required for lint task)/goreleaser: Generate .goreleaser.yml (required for snapshot/release tasks)/gen-github-dir: GitHub workflows can call task commands/gen-gitlab-ci: GitLab CI can call task commandsTypical Workflow:
# 1. Generate task configuration
/gen-taskfiles
# 2. Generate supporting configs
/linter # Creates .golangci.yml
/goreleaser # Creates .goreleaser.yml
# 3. Install tools and hooks
brew install go-task pre-commit golangci-lint goreleaser
task dev:install-pre-commit
# 4. Test tasks
task lint
task test
task build
# 5. Commit everything
git add Taskfile*.yml .pre-commit-config.yaml .golangci.yml .goreleaser.yml
git commit -m "build: add task automation and pre-commit hooks"
# 6. Verify hooks work
# Make a test change, try to commit - hooks should run
default: List all available tasks
task -acheck-before-commit: Run complete quality check suite
lint: Run golangci-lint
golangci-lint runtest: Run unit tests with race detection
go test -count=2 -race ./...build: Build project binaries
image: Build and push Docker image
doc: Start godoc documentation server
godoc -http=:6060snapshot: Create snapshot release
goreleaser --clean --snapshotrelease: Create production release
goreleaser --cleandev:install-pre-commit: Install pre-commit hooks
pre-commit installdev:pre-commit: Run all pre-commit hooks manually
pre-commit run --all-files.pre-commit-config.yaml configures automatic quality checks:
Standard hooks (from pre-commit/pre-commit-hooks):
check-yaml: Validate YAML syntax (enabled)check-added-large-files: Prevent commits of large files (enabled)trailing-whitespace: Remove trailing whitespace (commented, can enable)end-of-file-fixer: Ensure files end with newline (commented, can enable)Local hooks (run task commands):
unit-tests: Run task test before commitlint: Run task lint before commitbuild: Run task snapshot before commitAll local hooks use pass_filenames: false to run full checks, not per-file.
Before running command:
After generation:
task dev:install-pre-committask lint, task test, task buildOngoing usage:
task check-before-commit before pushing codetask snapshot to test releases locallyThis command does NOT:
/linter command)/goreleaser command)--force to overwrite)task dev:install-pre-commit)Scope boundaries:
✅ Prerequisites validated (git repo, Go project)
✅ Template files read from skill assets (3 files)
✅ Binary name detected from go.mod
✅ User confirmation obtained (unless --force)
✅ All files written successfully (or partial success reported)
✅ Files validated (exist and non-zero size)
✅ Comprehensive success report displayed
✅ Customization instructions provided
✅ Next steps guide shown
✅ No Claude Code attribution in generated content
✅ Total runtime < 5 seconds
# Standard generation (3 files)
/gen-taskfiles
# Preview before creating
/gen-taskfiles --dry-run
# Overwrite existing configuration
/gen-taskfiles --force
# Force with dry run
/gen-taskfiles --force --dry-run
Standard mode (default):
Dry run mode (--dry-run):
Why Task instead of Make?
Migration from Make: If you have a Makefile, you can: