[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6DRYGHPFGYY7XBYSM4WFMKB":3,"skill-same:01M6DRYGHPFGYY7XBYSM4WFMKB":97},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":25,"linkOnly":26,"markdownContent":27,"markdownBody":28,"frontMatter":29,"refName":30,"commitSha":31,"skillDirectory":32,"forksCount":33,"repositoryHtmlUrl":34,"repositoryHomepageUrl":6,"ownerHtmlUrl":35,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":36,"install":37,"resources":50},"01M6DRYGHPFGYY7XBYSM4WFMKB","makefile-generator",null,"Create, generate, or scaffold Makefiles with .PHONY targets and build automation.","AntifragileTech\u002Fantifragile-claude-code","AntifragileTech","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F174357194?v=4","01M6DQCYMK4CDSQQAN0ZC72NTV","01M6DQCYS9YPW1WKMQ5TJMPQ43",9,"MIT","https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code\u002Fblob\u002Fmaster\u002Fassets\u002Fskills\u002Fdevops\u002Fmakefile-generator\u002FSKILL.md",[],[18,19,20,21,22,23,24],"makefile","makefile generator","automation","scaffold","create","generate","build","2026-11-10 10:12:30",false,"---\nname: makefile-generator\ndescription: Create, generate, or scaffold Makefiles with .PHONY targets and build automation.\n---\n\n# Makefile Generator\n\n## Overview\n\nGenerate production-ready Makefiles with best practices for C\u002FC++, Python, Go, Java, and generic projects. Features GNU Coding Standards compliance, standard targets, security hardening, and automatic validation via devops-skills:makefile-validator skill.\n\n## When to Use\n\n- Creating new Makefiles from scratch\n- Setting up build systems for projects (C\u002FC++, Python, Go, Java)\n- Implementing build automation and CI\u002FCD integration\n- Converting manual build processes to Makefiles\n- The user asks to \"create\", \"generate\", or \"write\" a Makefile\n\n**Do NOT use for:** Validating existing Makefiles (use devops-skills:makefile-validator), debugging (use `make -d`), or running builds.\n\n## Trigger Phrases\n\nUse this skill when prompts look like:\n- \"Generate a Makefile for a Go service\"\n- \"Create a production Makefile with install\u002Ftest\u002Fhelp targets\"\n- \"Write a Makefile for a C project with dependency tracking\"\n- \"Add standard GNU targets to this existing Makefile\"\n\n## Generation Workflow\n\n### Stage 1: Gather Requirements\n\nCollect information for the following categories. **Use AskUserQuestion when information is missing or ambiguous:**\n\n| Category | Information Needed |\n|----------|-------------------|\n| **Project** | Language (C\u002FC++\u002FPython\u002FGo\u002FJava), structure (single\u002Fmulti-directory) |\n| **Build** | Source files, output artifacts, dependencies, build order |\n| **Install** | PREFIX location, directories (bin\u002Flib\u002Fshare), files to install |\n| **Targets** | all, install, clean, test, dist, help (which are needed?) |\n| **Config** | Compiler, flags, pkg-config dependencies, cross-compilation |\n\n**When to Use AskUserQuestion (MUST ask if any apply):**\n\n| Condition | Example Question |\n|-----------|------------------|\n| Language not specified | \"What programming language is this project? (C\u002FC++\u002FGo\u002FPython\u002FJava)\" |\n| Project structure unclear | \"Is this a single-directory or multi-directory project?\" |\n| Docker requested but registry unknown | \"Which container registry should be used? (docker.io\u002Fghcr.io\u002Fcustom)\" |\n| Multiple binaries possible | \"Should this build a single binary or multiple executables?\" |\n| Install targets needed but paths unclear | \"Where should binaries be installed? (default: \u002Fusr\u002Flocal\u002Fbin)\" |\n| Cross-compilation mentioned | \"What is the target platform\u002Farchitecture?\" |\n\n**When to Skip AskUserQuestion (proceed with defaults):**\n- User explicitly provides all required information\n- Standard project type with obvious defaults (e.g., \"Go project with Docker\" → use standard Go+Docker patterns)\n- User says \"use defaults\" or \"standard setup\"\n\n**Default Assumptions (when not asking):**\n- Single-directory project structure\n- PREFIX=\u002Fusr\u002Flocal\n- Standard targets: all, build, test, clean, install, help\n- No cross-compilation\n\n### Stage 2: Documentation Lookup\n\n**When REQUIRED (MUST perform lookup):**\n- User requests integration with unfamiliar tools, frameworks, or build systems\n- Complex build patterns not covered in Stage 3 examples (e.g., Bazel, Meson, custom toolchains)\n- **Docker\u002Fcontainer integration** (Dockerfile builds, multi-stage, registry push)\n- CI\u002FCD platform-specific integration (GitHub Actions, GitLab CI, Jenkins)\n- Cross-compilation for unusual targets or embedded systems\n- Package manager integration (Conan, vcpkg, Homebrew formulas)\n- **Multi-binary or multi-library projects**\n- **Version embedding via ldflags or build-time variables**\n\n**When OPTIONAL (may skip external lookup):**\n- Standard language patterns already covered in Stage 3 (C\u002FC++, Go, Python, Java)\n- Simple single-binary projects with no external dependencies\n- User provides complete requirements with no ambiguity\n- Internal docs already cover the required pattern comprehensively\n\n**Lookup Process (follow in order):**\n\n1. **ALWAYS consult internal docs first using explicit file-open commands** (primary source of truth):\n\n   **Full doc path map (prefer full paths for deterministic access):**\n\n   | Doc | Full Path |\n   |-----|-----------|\n   | Structure guide | `devops-skills-plugin\u002Fskills\u002Fmakefile-generator\u002Fdocs\u002Fmakefile-structure.md` |\n   | Variables guide | `devops-skills-plugin\u002Fskills\u002Fmakefile-generator\u002Fdocs\u002Fvariables-guide.md` |\n   | Targets guide | `devops-skills-plugin\u002Fskills\u002Fmakefile-generator\u002Fdocs\u002Ftargets-guide.md` |\n   | Patterns guide | `devops-skills-plugin\u002Fskills\u002Fmakefile-generator\u002Fdocs\u002Fpatterns-guide.md` |\n   | Optimization guide | `devops-skills-plugin\u002Fskills\u002Fmakefile-generator\u002Fdocs\u002Foptimization-guide.md` |\n   | Security guide | `devops-skills-plugin\u002Fskills\u002Fmakefile-generator\u002Fdocs\u002Fsecurity-guide.md` |\n\n   | Requirement | Read This Doc |\n   |-------------|---------------|\n   | Docker\u002Fcontainer targets | `...\u002Fdocs\u002Fpatterns-guide.md` (Pattern 8: Docker Integration) |\n   | Multi-binary projects | `...\u002Fdocs\u002Fpatterns-guide.md` (Pattern 7: Multi-Binary Project) |\n   | Go projects with version embedding | `...\u002Fdocs\u002Fpatterns-guide.md` (Pattern 5: Go Project) |\n   | Parallel builds, caching, ccache | `...\u002Fdocs\u002Foptimization-guide.md` |\n   | Credentials, secrets, API keys | `...\u002Fdocs\u002Fsecurity-guide.md` |\n   | Complex dependencies, pattern rules | `...\u002Fdocs\u002Fpatterns-guide.md` |\n   | Order-only prerequisites | `...\u002Fdocs\u002Foptimization-guide.md` or `...\u002Fdocs\u002Ftargets-guide.md` |\n   | Variables, assignment operators | `...\u002Fdocs\u002Fvariables-guide.md` |\n\n   **Deterministic open\u002Fread commands:**\n   ```bash\n   # From repository root:\n   sed -n '1,220p' devops-skills-plugin\u002Fskills\u002Fmakefile-generator\u002Fdocs\u002Fpatterns-guide.md\n   rg -n \"Pattern 5|Pattern 8\" devops-skills-plugin\u002Fskills\u002Fmakefile-generator\u002Fdocs\u002Fpatterns-guide.md\n\n   # From skill directory:\n   sed -n '1,220p' docs\u002Fsecurity-guide.md\n   ```\n\n   If shell commands are unavailable, use the environment's file-open\u002Fread capability on the same paths.\n\n   **Required Workflow Example (Docker + Go with version embedding):**\n   ```bash\n   # Step 1: Read Go pattern\n   rg -n \"Pattern 5\" devops-skills-plugin\u002Fskills\u002Fmakefile-generator\u002Fdocs\u002Fpatterns-guide.md\n\n   # Step 2: Read Docker pattern\n   rg -n \"Pattern 8\" devops-skills-plugin\u002Fskills\u002Fmakefile-generator\u002Fdocs\u002Fpatterns-guide.md\n\n   # Step 3: Read security guidance\n   sed -n '1,220p' devops-skills-plugin\u002Fskills\u002Fmakefile-generator\u002Fdocs\u002Fsecurity-guide.md\n   ```\n   Then generate Makefile and list consulted docs in a header comment.\n\n2. **Try context7 for external tool documentation** (when internal docs don't cover a specific tool):\n   ```\n   # Only needed for tools\u002Fframeworks NOT covered in internal docs\n   mcp__context7__resolve-library-id: \"\u003Ctool-name>\"\n   mcp__context7__query-docs: query=\"\u003Cintegration-topic>\"\n\n   # Example queries:\n   # - For Docker: query=\"dockerfile best practices\"\n   # - For Go: query=\"go build ldflags\"\n   # - For specific tools: query=\"\u003Ctool> makefile integration\"\n   ```\n   **Fallback:** If context7 is unavailable or returns nothing useful, record that and continue to Step 3.\n\n3. **Fallback to WebSearch** (only if pattern not found in internal docs OR context7):\n   ```\n   \"\u003Cspecific-feature>\" makefile best practices 2025\n   Example: \"docker makefile best practices 2025\"\n   Example: \"go ldflags version makefile 2025\"\n   ```\n   **Trigger WebSearch when:** Internal docs don't cover the specific integration AND context7 returns no relevant results.\n\n**Note:** Document which internal docs you consulted in your response (add comment in generated Makefile header).\n\n### Stage 3: Generate Makefile\n\n**Optional helper-script fast path (for standard layouts):**\n```bash\n# Generate template: TYPE NAME OUTPUT\nbash scripts\u002Fgenerate_makefile_template.sh go myservice Makefile\n\n# Add only selected standard targets\nbash scripts\u002Fadd_standard_targets.sh Makefile install clean help\n```\nUse manual authoring when requirements are complex (Docker release flow, multi-binary matrices, custom toolchains).\n\n#### Header (choose one style)\n\n**Traditional (POSIX-compatible):**\n```makefile\n.DELETE_ON_ERROR:\n.SUFFIXES:\n```\n\n**Modern (GNU Make 4.0+, recommended):**\n```makefile\nSHELL := bash\n.ONESHELL:\n.SHELLFLAGS := -eu -o pipefail -c\n.DELETE_ON_ERROR:\n.SUFFIXES:\nMAKEFLAGS += --warn-undefined-variables\nMAKEFLAGS += --no-builtin-rules\n```\n\n#### Standard Variables\n\n```makefile\n# User-overridable (use ?=)\nCC ?= gcc\nCFLAGS ?= -Wall -Wextra -O2\nPREFIX ?= \u002Fusr\u002Flocal\nDESTDIR ?=\n\n# GNU installation directories\nBINDIR ?= $(PREFIX)\u002Fbin\nLIBDIR ?= $(PREFIX)\u002Flib\nINCLUDEDIR ?= $(PREFIX)\u002Finclude\n\n# Project-specific (use :=)\nPROJECT := myproject\nVERSION := 1.0.0\nSRCDIR := src\nBUILDDIR := build\nSOURCES := $(wildcard $(SRCDIR)\u002F*.c)\nOBJECTS := $(SOURCES:$(SRCDIR)\u002F%.c=$(BUILDDIR)\u002F%.o)\n```\n\n#### Language-Specific Build Rules\n\n**C\u002FC++:**\n```makefile\n$(TARGET): $(OBJECTS)\n\t$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@\n\n$(BUILDDIR)\u002F%.o: $(SRCDIR)\u002F%.c\n\t@mkdir -p $(@D)\n\t$(CC) $(CPPFLAGS) $(CFLAGS) -MMD -MP -c $\u003C -o $@\n\n-include $(OBJECTS:.o=.d)\n```\n\n**Go:**\n```makefile\n$(TARGET): $(shell find . -name '*.go') go.mod\n\tgo build -o $@ .\u002Fcmd\u002F$(PROJECT)\n```\n\n**Python:**\n```makefile\n.PHONY: build\nbuild:\n\tpython -m build\n\n.PHONY: develop\ndevelop:\n\tpip install -e .[dev]\n```\n\n**Java:**\n```makefile\n$(BUILDDIR)\u002F%.class: $(SRCDIR)\u002F%.java\n\t@mkdir -p $(@D)\n\tjavac -d $(BUILDDIR) -sourcepath $(SRCDIR) $\u003C\n```\n\n#### Standard Targets\n\n```makefile\n.PHONY: all clean install uninstall test help\n\n## Build all targets\nall: $(TARGET)\n\n## Install to PREFIX\ninstall: all\n\tinstall -d $(DESTDIR)$(BINDIR)\n\tinstall -m 755 $(TARGET) $(DESTDIR)$(BINDIR)\u002F\n\n## Remove built files\nclean:\n\t$(RM) -r $(BUILDDIR) $(TARGET)\n\n## Run tests\ntest:\n\t# Add test commands\n\n## Show help\nhelp:\n\t@echo \"$(PROJECT) v$(VERSION)\"\n\t@echo \"Targets: all, install, clean, test, help\"\n\t@echo \"Override: make CC=clang PREFIX=\u002Fopt\"\n```\n\n### Stage 4: Validate and Format\n\nValidation is required for every generated Makefile.\n\n#### Validation Tool Preflight (default + fallback)\n\n1. **Preferred path:** run `devops-skills:makefile-validator`.\n2. **If validator skill is unavailable:** run local fallback checks:\n   ```bash\n   # Required fallback check (if make exists)\n   make -f \u003CMakefile> -n --dry-run\n\n   # Structural fallback checks\n   rg -n '^ {1,}\\S' \u003CMakefile>         # suspicious space-indented recipe lines\n   rg -n '^\\.PHONY:' \u003CMakefile>\n   ```\n3. **If `make` is unavailable:** run structural checks only, report \"partial validation due to missing make binary\", and request user confirmation before claiming production readiness.\n\n#### Required Validation Loop\n\n```\n1. Generate Makefile following stages above\n2. Run validator skill (or fallback checks if unavailable)\n3. Fix all errors (MUST have 0 errors before completion)\n4. Apply formatting fixes (see \"Formatting Step\" below)\n5. Fix warnings when feasible (SHOULD fix; explain if skipped)\n6. Address info items for large\u002Fproduction projects\n7. Re-run validation until checks pass\n8. Output structured validation report (REQUIRED - see format below)\n```\n\n#### Formatting Step (REQUIRED)\n\nWhen mbake reports formatting issues, you MUST either:\n\n1. **Auto-apply formatting** (preferred for minor issues):\n   ```bash\n   mbake format \u003CMakefile>\n   ```\n\n2. **Explain why not applied** (if formatting would break functionality):\n   ```\n   Formatting not applied because:\n   - [specific reason, e.g., \"heredoc syntax would be corrupted\"]\n   - Manual review recommended for: [specific lines]\n   ```\n\nIf `mbake` is not installed or not executable, skip formatter execution and record:\n`Formatting skipped: mbake unavailable in current environment.`\n\n**Formatting Decision Guide:**\n\n| mbake Report | Action |\n|--------------|--------|\n| \"Would reformat\" with no specific issues | Auto-apply with `mbake format` |\n| Specific whitespace\u002Findentation issues | Auto-apply with `mbake format` |\n| Issues in complex heredocs or multi-line strings | Skip formatting, explain in output |\n| Issues in `# bake-format off` sections | Skip (intentionally disabled) |\n| `mbake` command unavailable | Skip formatting, record tool-unavailable reason |\n\n**Validation Pass Criteria:**\n\n| Level | Requirement | Action |\n|-------|-------------|--------|\n| **Errors (0 required)** | Syntax errors, missing tabs, invalid targets | MUST fix before completion |\n| **Warnings (fix if feasible)** | Formatting issues, missing optimizations | SHOULD fix; explain if skipped |\n| **Info (address for production)** | Enhancement suggestions, style preferences | SHOULD address for production Makefiles |\n\n**Known mbake False Positives (can be safely ignored):**\n\nThe mbake validator may report warnings for valid GNU Make special targets. These are false positives and can be ignored:\n\n| mbake Warning | Actual Status | Explanation |\n|---------------|---------------|-------------|\n| \"Unknown special target '.DELETE_ON_ERROR'\" | ✅ Valid | Critical GNU Make target that deletes failed build artifacts |\n| \"Unknown special target '.SUFFIXES'\" | ✅ Valid | Standard GNU Make target for disabling\u002Fsetting suffix rules |\n| \"Unknown special target '.ONESHELL'\" | ✅ Valid | GNU Make 3.82+ feature for single-shell recipe execution |\n| \"Unknown special target '.POSIX'\" | ✅ Valid | POSIX compliance declaration |\n\n#### Validation Report Output (REQUIRED)\n\nAfter validation completes, you MUST output a structured report in the following format. This is not optional.\n\n**Required Report Format:**\n\n```\n## Validation Report\n\n**Result:** [PASSED \u002F PASSED with warnings \u002F FAILED]\n**Errors:** [count]\n**Warnings:** [count]\n**Info:** [count]\n\n### Errors Fixed\n- [List each error and how it was fixed, or \"None\" if 0 errors]\n\n### Warnings Addressed\n- [List each warning that was fixed]\n\n### Warnings Skipped (with reasons)\n- [List each warning that was NOT fixed and explain why]\n- Example: \"mbake reports '.DELETE_ON_ERROR' as unknown - this is a valid GNU Make\n  special target (false positive)\"\n\n### Formatting Applied\n- [Yes\u002FNo] - [If No, explain why formatting was skipped]\n\n### Info Items Addressed\n- [List info items that were addressed for production Makefiles]\n- [Or \"N\u002FA - simple project\" if not applicable]\n\n### Remaining Issues (if any)\n- [List any issues requiring user attention]\n- [Or \"None - Makefile is production-ready\"]\n```\n\n**Example Complete Report:**\n\n```\n## Validation Report\n\n**Result:** PASSED with warnings\n**Errors:** 0\n**Warnings:** 2\n**Info:** 1\n\n### Errors Fixed\n- None\n\n### Warnings Addressed\n- Fixed: Added error handling to install target (|| exit 1)\n\n### Warnings Skipped (with reasons)\n- mbake reports \".DELETE_ON_ERROR\" as unknown - this is a valid and critical\n  GNU Make special target that ensures failed builds don't leave corrupt files.\n  See: https:\u002F\u002Fwww.gnu.org\u002Fsoftware\u002Fmake\u002Fmanual\u002Fhtml_node\u002FSpecial-Targets.html\n\n### Formatting Applied\n- Yes - Applied `mbake format` to fix whitespace issues\n\n### Info Items Addressed\n- Added .NOTPARALLEL for Docker targets (parallel safety)\n- Added error handling for docker-push target\n\n### Remaining Issues\n- None - Makefile is production-ready\n```\n\n**Common Info Items to Address:**\n\n| Info Item | When to Fix | How to Fix |\n|-----------|-------------|------------|\n| \"mkdir without order-only prerequisites\" | Large projects (>10 targets) | Use `target: prereqs \\| $(BUILDDIR)` pattern |\n| \"recipe commands lack error handling\" | Critical operations (install, deploy) | Add `set -e` in .SHELLFLAGS or use `&&` chaining |\n| \"consider using ccache\" | Long compile times | Add `CC := ccache $(CC)` pattern |\n| \"parallel-sensitive commands detected\" | Docker\u002Fnpm\u002Fpip targets | Add `.NOTPARALLEL:` for affected targets or proper dependencies |\n\n**Production-Quality Requirements (MUST address for Docker\u002Fdeploy targets):**\n\nWhen generating Makefiles with Docker or deployment targets, you MUST apply these production patterns:\n\n1. **Error Handling for docker-push:**\n   ```makefile\n   ## Push Docker image to registry (with error handling)\n   docker-push: docker-build\n   \t@echo \"Pushing $(IMAGE)...\"\n   \tdocker push $(IMAGE) || { echo \"Failed to push $(IMAGE)\"; exit 1; }\n   \tdocker push $(IMAGE_LATEST) || { echo \"Failed to push $(IMAGE_LATEST)\"; exit 1; }\n   ```\n\n2. **Parallel Safety for Docker targets:**\n   ```makefile\n   # Prevent parallel execution of Docker targets (race conditions)\n   .NOTPARALLEL: docker-build docker-push docker-run\n   ```\n   Or use proper dependencies to serialize:\n   ```makefile\n   docker-push: docker-build  # Ensures build completes before push\n   docker-run: docker-build   # Ensures build completes before run\n   ```\n\n3. **Install target error handling:**\n   ```makefile\n   install: $(TARGET)\n   \tinstall -d $(DESTDIR)$(PREFIX)\u002Fbin || exit 1\n   \tinstall -m 755 $(TARGET) $(DESTDIR)$(PREFIX)\u002Fbin\u002F || exit 1\n   ```\n\n**Note:** When validation shows info items about error handling or parallel safety, you MUST address them for any Makefile containing Docker, deploy, or install targets. Explain in your response which patterns were applied.\n\n**Validation Checklist:**\n- [ ] Syntax correct (`make -n` passes)\n- [ ] All non-file targets have .PHONY\n- [ ] Tab indentation (not spaces)\n- [ ] No hardcoded credentials\n- [ ] User-overridable variables use `?=`\n- [ ] .DELETE_ON_ERROR present\n- [ ] MAKEFLAGS optimizations included (Modern header)\n- [ ] Order-only prerequisites for build directories (large projects)\n- [ ] Error handling in critical recipes (install, deploy, docker-push)\n\n## Best Practices\n\n### Variables\n- `?=` for user-overridable (CC, CFLAGS, PREFIX)\n- `:=` for project-specific (SOURCES, OBJECTS)\n- Use pkg-config: `CFLAGS += $(shell pkg-config --cflags lib)`\n\n### Targets\n- Always declare `.PHONY` for non-file targets\n- Default target should be `all`\n- Use `.DELETE_ON_ERROR` for safety\n- Document with `##` comments for help target\n\n### Directory Creation\nTwo approaches for creating build directories:\n\n**Simple (inline mkdir):**\n```makefile\n$(BUILDDIR)\u002F%.o: $(SRCDIR)\u002F%.c\n\t@mkdir -p $(@D)\n\t$(CC) $(CFLAGS) -c $\u003C -o $@\n```\n\n**Optimized (order-only prerequisites):** Prevents unnecessary rebuilds when directory timestamps change.\n```makefile\n$(BUILDDIR):\n\t@mkdir -p $@\n\n$(BUILDDIR)\u002F%.o: $(SRCDIR)\u002F%.c | $(BUILDDIR)\n\t$(CC) $(CFLAGS) -c $\u003C -o $@\n```\nUse order-only prerequisites (`|`) for large projects with many targets.\n\n### Recipes\n- Use tabs, never spaces\n- Quote variables in shell: `$(RM) \"$(TARGET)\"`\n- Use `@` prefix for quiet commands\n- Test with `make -n` first\n\n## Helper Scripts (Optional)\n\nThese scripts are **optional convenience tools** for quick template generation.\n\n### When to Use Scripts vs Manual Generation\n\n| Scenario | Recommendation |\n|----------|----------------|\n| Simple, standard project (single binary, no special features) | ✅ Use `generate_makefile_template.sh` for speed |\n| Complex project (Docker, multi-binary, custom patterns) | ❌ Use manual generation for full control |\n| Adding targets to existing Makefile | ✅ Use `add_standard_targets.sh` |\n| User has specific formatting\u002Fstyle requirements | ❌ Use manual generation |\n| Rapid prototyping \u002F proof-of-concept | ✅ Use scripts, customize later |\n| Production-ready Makefile | ⚠️ Start with script, then customize manually |\n\n### generate_makefile_template.sh\n\nGenerates a complete Makefile template for a specific project type.\nScript path: `scripts\u002Fgenerate_makefile_template.sh`\n\n```bash\nbash scripts\u002Fgenerate_makefile_template.sh [TYPE] [NAME] [OUTPUT_FILE]\n\nTypes: c, c-lib, cpp, go, python, java, generic\n```\n\n**Example:**\n```bash\nbash scripts\u002Fgenerate_makefile_template.sh go myservice\n# Creates Makefile with Go patterns, version embedding, standard targets\n\nbash scripts\u002Fgenerate_makefile_template.sh go myservice build\u002FMakefile\n# Writes template to build\u002FMakefile (TYPE NAME OUTPUT)\n```\n\n### add_standard_targets.sh\n\nAdds missing standard GNU targets to an existing Makefile.\nScript path: `scripts\u002Fadd_standard_targets.sh`\n\n```bash\nbash scripts\u002Fadd_standard_targets.sh [MAKEFILE] [TARGETS...]\nbash scripts\u002Fadd_standard_targets.sh [TARGETS...]  # uses .\u002FMakefile\n\nTargets: all, install, uninstall, clean, distclean, test, check, help, dist\n```\n\n**Example:**\n```bash\nbash scripts\u002Fadd_standard_targets.sh Makefile install uninstall help\n# Adds install, uninstall, help targets if they don't exist\n\nbash scripts\u002Fadd_standard_targets.sh clean test\n# Explicit-target mode: modifies .\u002FMakefile\n\nbash scripts\u002Fadd_standard_targets.sh -n Makefile dist\n# Dry-run mode: shows planned changes without editing files\n```\n\n**Note:** Manual generation following the Stage 3 patterns produces equivalent results but allows for more customization.\n\n### Helper Script Regression Smoke Tests\n\nRun after modifying helper scripts or templates:\n```bash\nbash test\u002Ftest_helper_scripts.sh\n```\n\n## Done Criteria\n\nConsider the task complete only when all checks below are satisfied:\n- Trigger matched and missing requirements were clarified (or documented defaults were applied).\n- Relevant internal docs were opened via explicit file paths before generation.\n- Generated Makefile has complete `.PHONY` coverage for non-file targets.\n- Go templates include optional `go.sum` handling and configurable `GO_MAIN` entrypoint.\n- Validation ran with `makefile-validator` (preferred) or documented fallback checks.\n- Formatting was applied with `mbake`, or skipped with an explicit tool-unavailable\u002Fcompatibility reason.\n- Final response includes the required structured validation report.\n\n## Documentation\n\nDetailed guides in `docs\u002F`:\n- **makefile-structure.md** - Organization, layout, includes\n- **variables-guide.md** - Assignment operators, automatic variables\n- **targets-guide.md** - Standard targets, .PHONY, prerequisites\n- **patterns-guide.md** - Pattern rules, dependencies\n- **optimization-guide.md** - Parallel builds, caching\n- **security-guide.md** - Safe expansion, credential handling\n\n## Resources\n\n- [GNU Make Manual](https:\u002F\u002Fwww.gnu.org\u002Fsoftware\u002Fmake\u002Fmanual\u002F)\n- [GNU Coding Standards](https:\u002F\u002Fwww.gnu.org\u002Fprep\u002Fstandards\u002Fstandards.html)\n- [Makefile Conventions](https:\u002F\u002Fwww.gnu.org\u002Fprep\u002Fstandards\u002Fhtml_node\u002FMakefile-Conventions.html)\n","# Makefile Generator\n\n## Overview\n\nGenerate production-ready Makefiles with best practices for C\u002FC++, Python, Go, Java, and generic projects. Features GNU Coding Standards compliance, standard targets, security hardening, and automatic validation via devops-skills:makefile-validator skill.\n\n## When to Use\n\n- Creating new Makefiles from scratch\n- Setting up build systems for projects (C\u002FC++, Python, Go, Java)\n- Implementing build automation and CI\u002FCD integration\n- Converting manual build processes to Makefiles\n- The user asks to \"create\", \"generate\", or \"write\" a Makefile\n\n**Do NOT use for:** Validating existing Makefiles (use devops-skills:makefile-validator), debugging (use `make -d`), or running builds.\n\n## Trigger Phrases\n\nUse this skill when prompts look like:\n- \"Generate a Makefile for a Go service\"\n- \"Create a production Makefile with install\u002Ftest\u002Fhelp targets\"\n- \"Write a Makefile for a C project with dependency tracking\"\n- \"Add standard GNU targets to this existing Makefile\"\n\n## Generation Workflow\n\n### Stage 1: Gather Requirements\n\nCollect information for the following categories. **Use AskUserQuestion when information is missing or ambiguous:**\n\n| Category | Information Needed |\n|----------|-------------------|\n| **Project** | Language (C\u002FC++\u002FPython\u002FGo\u002FJava), structure (single\u002Fmulti-directory) |\n| **Build** | Source files, output artifacts, dependencies, build order |\n| **Install** | PREFIX location, directories (bin\u002Flib\u002Fshare), files to install |\n| **Targets** | all, install, clean, test, dist, help (which are needed?) |\n| **Config** | Compiler, flags, pkg-config dependencies, cross-compilation |\n\n**When to Use AskUserQuestion (MUST ask if any apply):**\n\n| Condition | Example Question |\n|-----------|------------------|\n| Language not specified | \"What programming language is this project? (C\u002FC++\u002FGo\u002FPython\u002FJava)\" |\n| Project structure unclear | \"Is this a single-directory or multi-directory project?\" |\n| Docker requested but registry unknown | \"Which container registry should be used? (docker.io\u002Fghcr.io\u002Fcustom)\" |\n| Multiple binaries possible | \"Should this build a single binary or multiple executables?\" |\n| Install targets needed but paths unclear | \"Where should binaries be installed? (default: \u002Fusr\u002Flocal\u002Fbin)\" |\n| Cross-compilation mentioned | \"What is the target platform\u002Farchitecture?\" |\n\n**When to Skip AskUserQuestion (proceed with defaults):**\n- User explicitly provides all required information\n- Standard project type with obvious defaults (e.g., \"Go project with Docker\" → use standard Go+Docker patterns)\n- User says \"use defaults\" or \"standard setup\"\n\n**Default Assumptions (when not asking):**\n- Single-directory project structure\n- PREFIX=\u002Fusr\u002Flocal\n- Standard targets: all, build, test, clean, install, help\n- No cross-compilation\n\n### Stage 2: Documentation Lookup\n\n**When REQUIRED (MUST perform lookup):**\n- User requests integration with unfamiliar tools, frameworks, or build systems\n- Complex build patterns not covered in Stage 3 examples (e.g., Bazel, Meson, custom toolchains)\n- **Docker\u002Fcontainer integration** (Dockerfile builds, multi-stage, registry push)\n- CI\u002FCD platform-specific integration (GitHub Actions, GitLab CI, Jenkins)\n- Cross-compilation for unusual targets or embedded systems\n- Package manager integration (Conan, vcpkg, Homebrew formulas)\n- **Multi-binary or multi-library projects**\n- **Version embedding via ldflags or build-time variables**\n\n**When OPTIONAL (may skip external lookup):**\n- Standard language patterns already covered in Stage 3 (C\u002FC++, Go, Python, Java)\n- Simple single-binary projects with no external dependencies\n- User provides complete requirements with no ambiguity\n- Internal docs already cover the required pattern comprehensively\n\n**Lookup Process (follow in order):**\n\n1. **ALWAYS consult internal docs first using explicit file-open commands** (primary source of truth):\n\n   **Full doc path map (prefer full paths for deterministic access):**\n\n   | Doc | Full Path |\n   |-----|-----------|\n   | Structure guide | `devops-skills-plugin\u002Fskills\u002Fmakefile-generator\u002Fdocs\u002Fmakefile-structure.md` |\n   | Variables guide | `devops-skills-plugin\u002Fskills\u002Fmakefile-generator\u002Fdocs\u002Fvariables-guide.md` |\n   | Targets guide | `devops-skills-plugin\u002Fskills\u002Fmakefile-generator\u002Fdocs\u002Ftargets-guide.md` |\n   | Patterns guide | `devops-skills-plugin\u002Fskills\u002Fmakefile-generator\u002Fdocs\u002Fpatterns-guide.md` |\n   | Optimization guide | `devops-skills-plugin\u002Fskills\u002Fmakefile-generator\u002Fdocs\u002Foptimization-guide.md` |\n   | Security guide | `devops-skills-plugin\u002Fskills\u002Fmakefile-generator\u002Fdocs\u002Fsecurity-guide.md` |\n\n   | Requirement | Read This Doc |\n   |-------------|---------------|\n   | Docker\u002Fcontainer targets | `...\u002Fdocs\u002Fpatterns-guide.md` (Pattern 8: Docker Integration) |\n   | Multi-binary projects | `...\u002Fdocs\u002Fpatterns-guide.md` (Pattern 7: Multi-Binary Project) |\n   | Go projects with version embedding | `...\u002Fdocs\u002Fpatterns-guide.md` (Pattern 5: Go Project) |\n   | Parallel builds, caching, ccache | `...\u002Fdocs\u002Foptimization-guide.md` |\n   | Credentials, secrets, API keys | `...\u002Fdocs\u002Fsecurity-guide.md` |\n   | Complex dependencies, pattern rules | `...\u002Fdocs\u002Fpatterns-guide.md` |\n   | Order-only prerequisites | `...\u002Fdocs\u002Foptimization-guide.md` or `...\u002Fdocs\u002Ftargets-guide.md` |\n   | Variables, assignment operators | `...\u002Fdocs\u002Fvariables-guide.md` |\n\n   **Deterministic open\u002Fread commands:**\n   ```bash\n   # From repository root:\n   sed -n '1,220p' devops-skills-plugin\u002Fskills\u002Fmakefile-generator\u002Fdocs\u002Fpatterns-guide.md\n   rg -n \"Pattern 5|Pattern 8\" devops-skills-plugin\u002Fskills\u002Fmakefile-generator\u002Fdocs\u002Fpatterns-guide.md\n\n   # From skill directory:\n   sed -n '1,220p' docs\u002Fsecurity-guide.md\n   ```\n\n   If shell commands are unavailable, use the environment's file-open\u002Fread capability on the same paths.\n\n   **Required Workflow Example (Docker + Go with version embedding):**\n   ```bash\n   # Step 1: Read Go pattern\n   rg -n \"Pattern 5\" devops-skills-plugin\u002Fskills\u002Fmakefile-generator\u002Fdocs\u002Fpatterns-guide.md\n\n   # Step 2: Read Docker pattern\n   rg -n \"Pattern 8\" devops-skills-plugin\u002Fskills\u002Fmakefile-generator\u002Fdocs\u002Fpatterns-guide.md\n\n   # Step 3: Read security guidance\n   sed -n '1,220p' devops-skills-plugin\u002Fskills\u002Fmakefile-generator\u002Fdocs\u002Fsecurity-guide.md\n   ```\n   Then generate Makefile and list consulted docs in a header comment.\n\n2. **Try context7 for external tool documentation** (when internal docs don't cover a specific tool):\n   ```\n   # Only needed for tools\u002Fframeworks NOT covered in internal docs\n   mcp__context7__resolve-library-id: \"\u003Ctool-name>\"\n   mcp__context7__query-docs: query=\"\u003Cintegration-topic>\"\n\n   # Example queries:\n   # - For Docker: query=\"dockerfile best practices\"\n   # - For Go: query=\"go build ldflags\"\n   # - For specific tools: query=\"\u003Ctool> makefile integration\"\n   ```\n   **Fallback:** If context7 is unavailable or returns nothing useful, record that and continue to Step 3.\n\n3. **Fallback to WebSearch** (only if pattern not found in internal docs OR context7):\n   ```\n   \"\u003Cspecific-feature>\" makefile best practices 2025\n   Example: \"docker makefile best practices 2025\"\n   Example: \"go ldflags version makefile 2025\"\n   ```\n   **Trigger WebSearch when:** Internal docs don't cover the specific integration AND context7 returns no relevant results.\n\n**Note:** Document which internal docs you consulted in your response (add comment in generated Makefile header).\n\n### Stage 3: Generate Makefile\n\n**Optional helper-script fast path (for standard layouts):**\n```bash\n# Generate template: TYPE NAME OUTPUT\nbash scripts\u002Fgenerate_makefile_template.sh go myservice Makefile\n\n# Add only selected standard targets\nbash scripts\u002Fadd_standard_targets.sh Makefile install clean help\n```\nUse manual authoring when requirements are complex (Docker release flow, multi-binary matrices, custom toolchains).\n\n#### Header (choose one style)\n\n**Traditional (POSIX-compatible):**\n```makefile\n.DELETE_ON_ERROR:\n.SUFFIXES:\n```\n\n**Modern (GNU Make 4.0+, recommended):**\n```makefile\nSHELL := bash\n.ONESHELL:\n.SHELLFLAGS := -eu -o pipefail -c\n.DELETE_ON_ERROR:\n.SUFFIXES:\nMAKEFLAGS += --warn-undefined-variables\nMAKEFLAGS += --no-builtin-rules\n```\n\n#### Standard Variables\n\n```makefile\n# User-overridable (use ?=)\nCC ?= gcc\nCFLAGS ?= -Wall -Wextra -O2\nPREFIX ?= \u002Fusr\u002Flocal\nDESTDIR ?=\n\n# GNU installation directories\nBINDIR ?= $(PREFIX)\u002Fbin\nLIBDIR ?= $(PREFIX)\u002Flib\nINCLUDEDIR ?= $(PREFIX)\u002Finclude\n\n# Project-specific (use :=)\nPROJECT := myproject\nVERSION := 1.0.0\nSRCDIR := src\nBUILDDIR := build\nSOURCES := $(wildcard $(SRCDIR)\u002F*.c)\nOBJECTS := $(SOURCES:$(SRCDIR)\u002F%.c=$(BUILDDIR)\u002F%.o)\n```\n\n#### Language-Specific Build Rules\n\n**C\u002FC++:**\n```makefile\n$(TARGET): $(OBJECTS)\n\t$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@\n\n$(BUILDDIR)\u002F%.o: $(SRCDIR)\u002F%.c\n\t@mkdir -p $(@D)\n\t$(CC) $(CPPFLAGS) $(CFLAGS) -MMD -MP -c $\u003C -o $@\n\n-include $(OBJECTS:.o=.d)\n```\n\n**Go:**\n```makefile\n$(TARGET): $(shell find . -name '*.go') go.mod\n\tgo build -o $@ .\u002Fcmd\u002F$(PROJECT)\n```\n\n**Python:**\n```makefile\n.PHONY: build\nbuild:\n\tpython -m build\n\n.PHONY: develop\ndevelop:\n\tpip install -e .[dev]\n```\n\n**Java:**\n```makefile\n$(BUILDDIR)\u002F%.class: $(SRCDIR)\u002F%.java\n\t@mkdir -p $(@D)\n\tjavac -d $(BUILDDIR) -sourcepath $(SRCDIR) $\u003C\n```\n\n#### Standard Targets\n\n```makefile\n.PHONY: all clean install uninstall test help\n\n## Build all targets\nall: $(TARGET)\n\n## Install to PREFIX\ninstall: all\n\tinstall -d $(DESTDIR)$(BINDIR)\n\tinstall -m 755 $(TARGET) $(DESTDIR)$(BINDIR)\u002F\n\n## Remove built files\nclean:\n\t$(RM) -r $(BUILDDIR) $(TARGET)\n\n## Run tests\ntest:\n\t# Add test commands\n\n## Show help\nhelp:\n\t@echo \"$(PROJECT) v$(VERSION)\"\n\t@echo \"Targets: all, install, clean, test, help\"\n\t@echo \"Override: make CC=clang PREFIX=\u002Fopt\"\n```\n\n### Stage 4: Validate and Format\n\nValidation is required for every generated Makefile.\n\n#### Validation Tool Preflight (default + fallback)\n\n1. **Preferred path:** run `devops-skills:makefile-validator`.\n2. **If validator skill is unavailable:** run local fallback checks:\n   ```bash\n   # Required fallback check (if make exists)\n   make -f \u003CMakefile> -n --dry-run\n\n   # Structural fallback checks\n   rg -n '^ {1,}\\S' \u003CMakefile>         # suspicious space-indented recipe lines\n   rg -n '^\\.PHONY:' \u003CMakefile>\n   ```\n3. **If `make` is unavailable:** run structural checks only, report \"partial validation due to missing make binary\", and request user confirmation before claiming production readiness.\n\n#### Required Validation Loop\n\n```\n1. Generate Makefile following stages above\n2. Run validator skill (or fallback checks if unavailable)\n3. Fix all errors (MUST have 0 errors before completion)\n4. Apply formatting fixes (see \"Formatting Step\" below)\n5. Fix warnings when feasible (SHOULD fix; explain if skipped)\n6. Address info items for large\u002Fproduction projects\n7. Re-run validation until checks pass\n8. Output structured validation report (REQUIRED - see format below)\n```\n\n#### Formatting Step (REQUIRED)\n\nWhen mbake reports formatting issues, you MUST either:\n\n1. **Auto-apply formatting** (preferred for minor issues):\n   ```bash\n   mbake format \u003CMakefile>\n   ```\n\n2. **Explain why not applied** (if formatting would break functionality):\n   ```\n   Formatting not applied because:\n   - [specific reason, e.g., \"heredoc syntax would be corrupted\"]\n   - Manual review recommended for: [specific lines]\n   ```\n\nIf `mbake` is not installed or not executable, skip formatter execution and record:\n`Formatting skipped: mbake unavailable in current environment.`\n\n**Formatting Decision Guide:**\n\n| mbake Report | Action |\n|--------------|--------|\n| \"Would reformat\" with no specific issues | Auto-apply with `mbake format` |\n| Specific whitespace\u002Findentation issues | Auto-apply with `mbake format` |\n| Issues in complex heredocs or multi-line strings | Skip formatting, explain in output |\n| Issues in `# bake-format off` sections | Skip (intentionally disabled) |\n| `mbake` command unavailable | Skip formatting, record tool-unavailable reason |\n\n**Validation Pass Criteria:**\n\n| Level | Requirement | Action |\n|-------|-------------|--------|\n| **Errors (0 required)** | Syntax errors, missing tabs, invalid targets | MUST fix before completion |\n| **Warnings (fix if feasible)** | Formatting issues, missing optimizations | SHOULD fix; explain if skipped |\n| **Info (address for production)** | Enhancement suggestions, style preferences | SHOULD address for production Makefiles |\n\n**Known mbake False Positives (can be safely ignored):**\n\nThe mbake validator may report warnings for valid GNU Make special targets. These are false positives and can be ignored:\n\n| mbake Warning | Actual Status | Explanation |\n|---------------|---------------|-------------|\n| \"Unknown special target '.DELETE_ON_ERROR'\" | ✅ Valid | Critical GNU Make target that deletes failed build artifacts |\n| \"Unknown special target '.SUFFIXES'\" | ✅ Valid | Standard GNU Make target for disabling\u002Fsetting suffix rules |\n| \"Unknown special target '.ONESHELL'\" | ✅ Valid | GNU Make 3.82+ feature for single-shell recipe execution |\n| \"Unknown special target '.POSIX'\" | ✅ Valid | POSIX compliance declaration |\n\n#### Validation Report Output (REQUIRED)\n\nAfter validation completes, you MUST output a structured report in the following format. This is not optional.\n\n**Required Report Format:**\n\n```\n## Validation Report\n\n**Result:** [PASSED \u002F PASSED with warnings \u002F FAILED]\n**Errors:** [count]\n**Warnings:** [count]\n**Info:** [count]\n\n### Errors Fixed\n- [List each error and how it was fixed, or \"None\" if 0 errors]\n\n### Warnings Addressed\n- [List each warning that was fixed]\n\n### Warnings Skipped (with reasons)\n- [List each warning that was NOT fixed and explain why]\n- Example: \"mbake reports '.DELETE_ON_ERROR' as unknown - this is a valid GNU Make\n  special target (false positive)\"\n\n### Formatting Applied\n- [Yes\u002FNo] - [If No, explain why formatting was skipped]\n\n### Info Items Addressed\n- [List info items that were addressed for production Makefiles]\n- [Or \"N\u002FA - simple project\" if not applicable]\n\n### Remaining Issues (if any)\n- [List any issues requiring user attention]\n- [Or \"None - Makefile is production-ready\"]\n```\n\n**Example Complete Report:**\n\n```\n## Validation Report\n\n**Result:** PASSED with warnings\n**Errors:** 0\n**Warnings:** 2\n**Info:** 1\n\n### Errors Fixed\n- None\n\n### Warnings Addressed\n- Fixed: Added error handling to install target (|| exit 1)\n\n### Warnings Skipped (with reasons)\n- mbake reports \".DELETE_ON_ERROR\" as unknown - this is a valid and critical\n  GNU Make special target that ensures failed builds don't leave corrupt files.\n  See: https:\u002F\u002Fwww.gnu.org\u002Fsoftware\u002Fmake\u002Fmanual\u002Fhtml_node\u002FSpecial-Targets.html\n\n### Formatting Applied\n- Yes - Applied `mbake format` to fix whitespace issues\n\n### Info Items Addressed\n- Added .NOTPARALLEL for Docker targets (parallel safety)\n- Added error handling for docker-push target\n\n### Remaining Issues\n- None - Makefile is production-ready\n```\n\n**Common Info Items to Address:**\n\n| Info Item | When to Fix | How to Fix |\n|-----------|-------------|------------|\n| \"mkdir without order-only prerequisites\" | Large projects (>10 targets) | Use `target: prereqs \\| $(BUILDDIR)` pattern |\n| \"recipe commands lack error handling\" | Critical operations (install, deploy) | Add `set -e` in .SHELLFLAGS or use `&&` chaining |\n| \"consider using ccache\" | Long compile times | Add `CC := ccache $(CC)` pattern |\n| \"parallel-sensitive commands detected\" | Docker\u002Fnpm\u002Fpip targets | Add `.NOTPARALLEL:` for affected targets or proper dependencies |\n\n**Production-Quality Requirements (MUST address for Docker\u002Fdeploy targets):**\n\nWhen generating Makefiles with Docker or deployment targets, you MUST apply these production patterns:\n\n1. **Error Handling for docker-push:**\n   ```makefile\n   ## Push Docker image to registry (with error handling)\n   docker-push: docker-build\n   \t@echo \"Pushing $(IMAGE)...\"\n   \tdocker push $(IMAGE) || { echo \"Failed to push $(IMAGE)\"; exit 1; }\n   \tdocker push $(IMAGE_LATEST) || { echo \"Failed to push $(IMAGE_LATEST)\"; exit 1; }\n   ```\n\n2. **Parallel Safety for Docker targets:**\n   ```makefile\n   # Prevent parallel execution of Docker targets (race conditions)\n   .NOTPARALLEL: docker-build docker-push docker-run\n   ```\n   Or use proper dependencies to serialize:\n   ```makefile\n   docker-push: docker-build  # Ensures build completes before push\n   docker-run: docker-build   # Ensures build completes before run\n   ```\n\n3. **Install target error handling:**\n   ```makefile\n   install: $(TARGET)\n   \tinstall -d $(DESTDIR)$(PREFIX)\u002Fbin || exit 1\n   \tinstall -m 755 $(TARGET) $(DESTDIR)$(PREFIX)\u002Fbin\u002F || exit 1\n   ```\n\n**Note:** When validation shows info items about error handling or parallel safety, you MUST address them for any Makefile containing Docker, deploy, or install targets. Explain in your response which patterns were applied.\n\n**Validation Checklist:**\n- [ ] Syntax correct (`make -n` passes)\n- [ ] All non-file targets have .PHONY\n- [ ] Tab indentation (not spaces)\n- [ ] No hardcoded credentials\n- [ ] User-overridable variables use `?=`\n- [ ] .DELETE_ON_ERROR present\n- [ ] MAKEFLAGS optimizations included (Modern header)\n- [ ] Order-only prerequisites for build directories (large projects)\n- [ ] Error handling in critical recipes (install, deploy, docker-push)\n\n## Best Practices\n\n### Variables\n- `?=` for user-overridable (CC, CFLAGS, PREFIX)\n- `:=` for project-specific (SOURCES, OBJECTS)\n- Use pkg-config: `CFLAGS += $(shell pkg-config --cflags lib)`\n\n### Targets\n- Always declare `.PHONY` for non-file targets\n- Default target should be `all`\n- Use `.DELETE_ON_ERROR` for safety\n- Document with `##` comments for help target\n\n### Directory Creation\nTwo approaches for creating build directories:\n\n**Simple (inline mkdir):**\n```makefile\n$(BUILDDIR)\u002F%.o: $(SRCDIR)\u002F%.c\n\t@mkdir -p $(@D)\n\t$(CC) $(CFLAGS) -c $\u003C -o $@\n```\n\n**Optimized (order-only prerequisites):** Prevents unnecessary rebuilds when directory timestamps change.\n```makefile\n$(BUILDDIR):\n\t@mkdir -p $@\n\n$(BUILDDIR)\u002F%.o: $(SRCDIR)\u002F%.c | $(BUILDDIR)\n\t$(CC) $(CFLAGS) -c $\u003C -o $@\n```\nUse order-only prerequisites (`|`) for large projects with many targets.\n\n### Recipes\n- Use tabs, never spaces\n- Quote variables in shell: `$(RM) \"$(TARGET)\"`\n- Use `@` prefix for quiet commands\n- Test with `make -n` first\n\n## Helper Scripts (Optional)\n\nThese scripts are **optional convenience tools** for quick template generation.\n\n### When to Use Scripts vs Manual Generation\n\n| Scenario | Recommendation |\n|----------|----------------|\n| Simple, standard project (single binary, no special features) | ✅ Use `generate_makefile_template.sh` for speed |\n| Complex project (Docker, multi-binary, custom patterns) | ❌ Use manual generation for full control |\n| Adding targets to existing Makefile | ✅ Use `add_standard_targets.sh` |\n| User has specific formatting\u002Fstyle requirements | ❌ Use manual generation |\n| Rapid prototyping \u002F proof-of-concept | ✅ Use scripts, customize later |\n| Production-ready Makefile | ⚠️ Start with script, then customize manually |\n\n### generate_makefile_template.sh\n\nGenerates a complete Makefile template for a specific project type.\nScript path: `scripts\u002Fgenerate_makefile_template.sh`\n\n```bash\nbash scripts\u002Fgenerate_makefile_template.sh [TYPE] [NAME] [OUTPUT_FILE]\n\nTypes: c, c-lib, cpp, go, python, java, generic\n```\n\n**Example:**\n```bash\nbash scripts\u002Fgenerate_makefile_template.sh go myservice\n# Creates Makefile with Go patterns, version embedding, standard targets\n\nbash scripts\u002Fgenerate_makefile_template.sh go myservice build\u002FMakefile\n# Writes template to build\u002FMakefile (TYPE NAME OUTPUT)\n```\n\n### add_standard_targets.sh\n\nAdds missing standard GNU targets to an existing Makefile.\nScript path: `scripts\u002Fadd_standard_targets.sh`\n\n```bash\nbash scripts\u002Fadd_standard_targets.sh [MAKEFILE] [TARGETS...]\nbash scripts\u002Fadd_standard_targets.sh [TARGETS...]  # uses .\u002FMakefile\n\nTargets: all, install, uninstall, clean, distclean, test, check, help, dist\n```\n\n**Example:**\n```bash\nbash scripts\u002Fadd_standard_targets.sh Makefile install uninstall help\n# Adds install, uninstall, help targets if they don't exist\n\nbash scripts\u002Fadd_standard_targets.sh clean test\n# Explicit-target mode: modifies .\u002FMakefile\n\nbash scripts\u002Fadd_standard_targets.sh -n Makefile dist\n# Dry-run mode: shows planned changes without editing files\n```\n\n**Note:** Manual generation following the Stage 3 patterns produces equivalent results but allows for more customization.\n\n### Helper Script Regression Smoke Tests\n\nRun after modifying helper scripts or templates:\n```bash\nbash test\u002Ftest_helper_scripts.sh\n```\n\n## Done Criteria\n\nConsider the task complete only when all checks below are satisfied:\n- Trigger matched and missing requirements were clarified (or documented defaults were applied).\n- Relevant internal docs were opened via explicit file paths before generation.\n- Generated Makefile has complete `.PHONY` coverage for non-file targets.\n- Go templates include optional `go.sum` handling and configurable `GO_MAIN` entrypoint.\n- Validation ran with `makefile-validator` (preferred) or documented fallback checks.\n- Formatting was applied with `mbake`, or skipped with an explicit tool-unavailable\u002Fcompatibility reason.\n- Final response includes the required structured validation report.\n\n## Documentation\n\nDetailed guides in `docs\u002F`:\n- **makefile-structure.md** - Organization, layout, includes\n- **variables-guide.md** - Assignment operators, automatic variables\n- **targets-guide.md** - Standard targets, .PHONY, prerequisites\n- **patterns-guide.md** - Pattern rules, dependencies\n- **optimization-guide.md** - Parallel builds, caching\n- **security-guide.md** - Safe expansion, credential handling\n\n## Resources\n\n- [GNU Make Manual](https:\u002F\u002Fwww.gnu.org\u002Fsoftware\u002Fmake\u002Fmanual\u002F)\n- [GNU Coding Standards](https:\u002F\u002Fwww.gnu.org\u002Fprep\u002Fstandards\u002Fstandards.html)\n- [Makefile Conventions](https:\u002F\u002Fwww.gnu.org\u002Fprep\u002Fstandards\u002Fhtml_node\u002FMakefile-Conventions.html)\n",{"name":5,"description":7},"master","c73386b305dec167db7654e0e6feacb462d4f9dc","assets\u002Fskills\u002Fdevops\u002Fmakefile-generator",1,"https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code","https:\u002F\u002Fgithub.com\u002FAntifragileTech","2026-10-02 14:22:14",{"source":8,"skillName":5,"commands":38,"prompt":48,"zipAvailable":49},[39,42,45],{"tool":40,"command":41},"npx","npx skills add AntifragileTech\u002Fantifragile-claude-code --skill makefile-generator",{"tool":43,"command":44},"bunx","bunx skills add AntifragileTech\u002Fantifragile-claude-code --skill makefile-generator",{"tool":46,"command":47},"pnpm","pnpm dlx skills add AntifragileTech\u002Fantifragile-claude-code --skill makefile-generator","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code\u002Fblob\u002Fmaster\u002Fassets\u002Fskills\u002Fdevops\u002Fmakefile-generator\u002FSKILL.md",true,[51,57,63,67,71,75,79,83,89,93],{"path":52,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":55,"sourceHtmlUrl":56},"assets\u002Ftemplates\u002F.gitkeep","ASSET","资产文件",43,"https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code\u002Fblob\u002Fmaster\u002Fassets\u002Fskills\u002Fdevops\u002Fmakefile-generator\u002Fassets\u002Ftemplates\u002F.gitkeep",{"path":58,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":61,"sourceHtmlUrl":62},"docs\u002Fmakefile-structure.md","REFERENCE","参考文档",11182,"https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code\u002Fblob\u002Fmaster\u002Fassets\u002Fskills\u002Fdevops\u002Fmakefile-generator\u002Fdocs\u002Fmakefile-structure.md",{"path":64,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":65,"sourceHtmlUrl":66},"docs\u002Foptimization-guide.md",16254,"https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code\u002Fblob\u002Fmaster\u002Fassets\u002Fskills\u002Fdevops\u002Fmakefile-generator\u002Fdocs\u002Foptimization-guide.md",{"path":68,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":69,"sourceHtmlUrl":70},"docs\u002Fpatterns-guide.md",12593,"https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code\u002Fblob\u002Fmaster\u002Fassets\u002Fskills\u002Fdevops\u002Fmakefile-generator\u002Fdocs\u002Fpatterns-guide.md",{"path":72,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":73,"sourceHtmlUrl":74},"docs\u002Fsecurity-guide.md",8176,"https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code\u002Fblob\u002Fmaster\u002Fassets\u002Fskills\u002Fdevops\u002Fmakefile-generator\u002Fdocs\u002Fsecurity-guide.md",{"path":76,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":77,"sourceHtmlUrl":78},"docs\u002Ftargets-guide.md",13243,"https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code\u002Fblob\u002Fmaster\u002Fassets\u002Fskills\u002Fdevops\u002Fmakefile-generator\u002Fdocs\u002Ftargets-guide.md",{"path":80,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":81,"sourceHtmlUrl":82},"docs\u002Fvariables-guide.md",12816,"https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code\u002Fblob\u002Fmaster\u002Fassets\u002Fskills\u002Fdevops\u002Fmakefile-generator\u002Fdocs\u002Fvariables-guide.md",{"path":84,"resourceType":85,"resourceTypeDesc":86,"sizeBytes":87,"sourceHtmlUrl":88},"scripts\u002Fadd_standard_targets.sh","SCRIPT","脚本",14273,"https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code\u002Fblob\u002Fmaster\u002Fassets\u002Fskills\u002Fdevops\u002Fmakefile-generator\u002Fscripts\u002Fadd_standard_targets.sh",{"path":90,"resourceType":85,"resourceTypeDesc":86,"sizeBytes":91,"sourceHtmlUrl":92},"scripts\u002Fgenerate_makefile_template.sh",15334,"https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code\u002Fblob\u002Fmaster\u002Fassets\u002Fskills\u002Fdevops\u002Fmakefile-generator\u002Fscripts\u002Fgenerate_makefile_template.sh",{"path":94,"resourceType":85,"resourceTypeDesc":86,"sizeBytes":95,"sourceHtmlUrl":96},"test\u002Ftest_helper_scripts.sh",9102,"https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code\u002Fblob\u002Fmaster\u002Fassets\u002Fskills\u002Fdevops\u002Fmakefile-generator\u002Ftest\u002Ftest_helper_scripts.sh",[98,124,139,154,167,180],{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":117,"publishedAt":25},"01M6DT9Q6VYA615SCXR757TZZ7","writing-skills","Use when creating new skills, editing existing skills, or verifying skills work before deployment","https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code\u002Fblob\u002Fmaster\u002Fassets\u002Fskills\u002Fthinking\u002Fwriting-skills\u002FSKILL.md",[104,109,112],{"categoryNo":105,"categoryName":106,"taxonomyType":107,"taxonomyTypeDesc":108},"01JBSEEDCAT000000000000008","测试与质量","SCENARIO","使用场景",{"categoryNo":110,"categoryName":111,"taxonomyType":107,"taxonomyTypeDesc":108},"01JBSEEDCAT000000000000018","写作与文案",{"categoryNo":113,"categoryName":114,"taxonomyType":115,"taxonomyTypeDesc":116},"01JBSEEDCAT000000000000036","内容创作者","PROFESSION","适用职业",[118,119,120,121,122,123],"writing skills","writing","use","editing","work","deployment",{"skillNo":125,"name":126,"nameZh":6,"description":127,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":128,"categories":129,"keywords":132,"publishedAt":25},"01M6DT9GFHDNY90P41WGAE1TV0","writing-plans","Use when you have a spec or requirements for a multi-step task, before touching code","https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code\u002Fblob\u002Fmaster\u002Fassets\u002Fskills\u002Fthinking\u002Fwriting-plans\u002FSKILL.md",[130,131],{"categoryNo":110,"categoryName":111,"taxonomyType":107,"taxonomyTypeDesc":108},{"categoryNo":113,"categoryName":114,"taxonomyType":115,"taxonomyTypeDesc":116},[133,134,119,135,136,120,137,138],"plans","writing plans","requirements","task","code","spec",{"skillNo":140,"name":141,"nameZh":6,"description":142,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":143,"categories":144,"keywords":147,"publishedAt":25},"01M6DT9C6PFGD86WS3HY7YE3XG","docs:write-concisely","Apply writing rules to any documentation that humans will read. Makes your writing clearer, stronger, and more professional.","https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code\u002Fblob\u002Fmaster\u002Fassets\u002Fskills\u002Fthinking\u002Fwrite-concisely\u002FSKILL.md",[145,146],{"categoryNo":110,"categoryName":111,"taxonomyType":107,"taxonomyTypeDesc":108},{"categoryNo":113,"categoryName":114,"taxonomyType":115,"taxonomyTypeDesc":116},[148,149,150,151,152,153,119],"docs:write concisely","write","docs","read","Rules","documentation",{"skillNo":155,"name":156,"nameZh":6,"description":157,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":158,"categories":159,"keywords":160,"publishedAt":25},"01M6DT98AWQ27P0N1CG97WAG66","kaizen:why","Iterative Five Whys root cause analysis drilling from symptoms to fundamentals","https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code\u002Fblob\u002Fmaster\u002Fassets\u002Fskills\u002Fthinking\u002Fwhy\u002FSKILL.md",[],[156,161,162,163,164,165,166],"why","kaizen","issue","five whys","analysis","root cause analysis",{"skillNo":168,"name":169,"nameZh":6,"description":170,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":171,"categories":172,"keywords":173,"publishedAt":25},"01M6DT93EH25NAX19R3WGE1P53","verification-loop","A comprehensive verification system for Claude Code sessions.","https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code\u002Fblob\u002Fmaster\u002Fassets\u002Fskills\u002Fthinking\u002Fverification-loop\u002FSKILL.md",[],[174,175,176,177,137,178,179],"verification loop","verification","loop","sessions","claude code sessions","system",{"skillNo":181,"name":182,"nameZh":6,"description":183,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":184,"categories":185,"keywords":186,"publishedAt":25},"01M6DT90GW7Z7VCN98P9DVYSNC","verification-before-completion","Use when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always","https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code\u002Fblob\u002Fmaster\u002Fassets\u002Fskills\u002Fthinking\u002Fverification-before-completion\u002FSKILL.md",[],[187,175,188,122,120,189,190,191],"verification before completion","commands","evidence","claim","complete"]