@hybridlabor-api/aos 4.7.2 → 4.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/.agents/agents.md +1 -1
  2. package/.agents/nodes.json +1 -1
  3. package/.agents/vendor-manifest.json +23 -1
  4. package/.claude/agents/godmode-media-eventtech.md +1 -1
  5. package/.claude/hooks/conventional-commits.mjs +125 -0
  6. package/.claude/hooks/env-file-protection.mjs +105 -0
  7. package/.claude/hooks/go-gate.mjs +101 -81
  8. package/.claude/settings.json +13 -0
  9. package/.opencode/agents/godmode-media-eventtech.md +1 -1
  10. package/.opencode/plugins/bdb-aos.js +31 -4
  11. package/README.de.md +1 -1
  12. package/README.md +1 -1
  13. package/README.pt.md +1 -1
  14. package/THIRD_PARTY_NOTICES.md +88 -0
  15. package/docs/skills_table.md +1 -1
  16. package/installer.js +309 -101
  17. package/package.json +6 -2
  18. package/packages/aos-cli/README.md +80 -0
  19. package/packages/aos-cli/bin/aos-cli.mjs +134 -0
  20. package/packages/aos-cli/core-skills.json +12 -0
  21. package/packages/aos-cli/extensions/aos.ts +321 -0
  22. package/packages/aos-cli/package-lock.json +1923 -0
  23. package/packages/aos-cli/package.json +29 -0
  24. package/packages/aos-cli/scripts/check-theme.mjs +63 -0
  25. package/packages/aos-cli/themes/aos.json +97 -0
  26. package/scripts/build-plugin-manifest.mjs +131 -0
  27. package/scripts/validate-skills.mjs +81 -6
  28. package/skills/basic/ao-orchestrator/SKILL.md +116 -0
  29. package/skills/global_config/agenttrail/SKILL.md +6 -1
  30. package/skills/global_config/ask-tim/SKILL.md +4 -4
  31. package/skills/global_config/bash-script-generator/SKILL.md +201 -0
  32. package/skills/global_config/bash-script-generator/assets/templates/standard-template.sh +96 -0
  33. package/skills/global_config/bash-script-generator/docs/bash-scripting-guide.md +729 -0
  34. package/skills/global_config/bash-script-generator/docs/generation-best-practices.md +193 -0
  35. package/skills/global_config/bash-script-generator/docs/script-patterns.md +566 -0
  36. package/skills/global_config/bash-script-generator/docs/text-processing-guide.md +437 -0
  37. package/skills/global_config/bash-script-generator/examples/log-analyzer.sh +92 -0
  38. package/skills/global_config/bash-script-generator/scripts/generate_script_template.sh +123 -0
  39. package/skills/global_config/bash-script-generator/scripts/run_ci_checks.sh +172 -0
  40. package/skills/global_config/bash-script-generator/scripts/test_generator.sh +413 -0
  41. package/skills/global_config/bash-script-validator/SKILL.md +249 -0
  42. package/skills/global_config/bash-script-validator/docs/awk-reference.md +449 -0
  43. package/skills/global_config/bash-script-validator/docs/bash-reference.md +468 -0
  44. package/skills/global_config/bash-script-validator/docs/common-mistakes.md +623 -0
  45. package/skills/global_config/bash-script-validator/docs/grep-reference.md +395 -0
  46. package/skills/global_config/bash-script-validator/docs/regex-reference.md +391 -0
  47. package/skills/global_config/bash-script-validator/docs/sed-reference.md +454 -0
  48. package/skills/global_config/bash-script-validator/docs/shell-reference.md +463 -0
  49. package/skills/global_config/bash-script-validator/docs/shellcheck-reference.md +399 -0
  50. package/skills/global_config/bash-script-validator/examples/bad-bash.sh +55 -0
  51. package/skills/global_config/bash-script-validator/examples/bad-shell.sh +54 -0
  52. package/skills/global_config/bash-script-validator/examples/good-bash.sh +71 -0
  53. package/skills/global_config/bash-script-validator/examples/good-shell.sh +69 -0
  54. package/skills/global_config/bash-script-validator/scripts/run_ci_checks.sh +23 -0
  55. package/skills/global_config/bash-script-validator/scripts/shellcheck_wrapper.sh +174 -0
  56. package/skills/global_config/bash-script-validator/scripts/test_validate.sh +446 -0
  57. package/skills/global_config/bash-script-validator/scripts/validate.sh +512 -0
  58. package/skills/global_config/ci-pipeline/SKILL.md +135 -0
  59. package/skills/global_config/dispatching-parallel-agents/SKILL.md +170 -0
  60. package/skills/global_config/dockerfile-generator/SKILL.md +1038 -0
  61. package/skills/global_config/dockerfile-generator/examples/example.dockerignore +95 -0
  62. package/skills/global_config/dockerfile-generator/examples/golang-distroless.Dockerfile +34 -0
  63. package/skills/global_config/dockerfile-generator/examples/java-springboot.Dockerfile +45 -0
  64. package/skills/global_config/dockerfile-generator/examples/nextjs-production.Dockerfile +49 -0
  65. package/skills/global_config/dockerfile-generator/examples/nodejs-multistage.Dockerfile +55 -0
  66. package/skills/global_config/dockerfile-generator/examples/python-fastapi.Dockerfile +48 -0
  67. package/skills/global_config/dockerfile-generator/references/language_specific_guides.md +510 -0
  68. package/skills/global_config/dockerfile-generator/references/multistage_builds.md +570 -0
  69. package/skills/global_config/dockerfile-generator/references/optimization_patterns.md +492 -0
  70. package/skills/global_config/dockerfile-generator/references/security_best_practices.md +375 -0
  71. package/skills/global_config/dockerfile-generator/scripts/generate_dockerignore.sh +199 -0
  72. package/skills/global_config/dockerfile-generator/scripts/generate_golang.sh +172 -0
  73. package/skills/global_config/dockerfile-generator/scripts/generate_java.sh +185 -0
  74. package/skills/global_config/dockerfile-generator/scripts/generate_nodejs.sh +279 -0
  75. package/skills/global_config/dockerfile-generator/scripts/generate_python.sh +218 -0
  76. package/skills/global_config/dockerfile-generator/scripts/test_generator.sh +210 -0
  77. package/skills/global_config/dockerfile-validator/SKILL.md +300 -0
  78. package/skills/global_config/dockerfile-validator/examples/.dockerignore.example +34 -0
  79. package/skills/global_config/dockerfile-validator/examples/bad-example.Dockerfile +37 -0
  80. package/skills/global_config/dockerfile-validator/examples/golang-distroless.Dockerfile +50 -0
  81. package/skills/global_config/dockerfile-validator/examples/good-example.Dockerfile +52 -0
  82. package/skills/global_config/dockerfile-validator/examples/python-optimized.Dockerfile +53 -0
  83. package/skills/global_config/dockerfile-validator/examples/security-issues.Dockerfile +42 -0
  84. package/skills/global_config/dockerfile-validator/references/docker_best_practices.md +348 -0
  85. package/skills/global_config/dockerfile-validator/references/optimization_guide.md +473 -0
  86. package/skills/global_config/dockerfile-validator/references/security_checklist.md +208 -0
  87. package/skills/global_config/dockerfile-validator/scripts/dockerfile-validate.sh +699 -0
  88. package/skills/global_config/dockerfile-validator/scripts/test_validate.sh +35 -0
  89. package/skills/global_config/dockerfile-validator/tests/fixtures/copy-before-yarn-lock-read.Dockerfile +6 -0
  90. package/skills/global_config/dockerfile-validator/tests/fixtures/copy-before-yarn.Dockerfile +6 -0
  91. package/skills/global_config/dockerfile-validator/tests/fixtures/from-platform-nonroot.Dockerfile +7 -0
  92. package/skills/global_config/dockerfile-validator/tests/test_regression.sh +164 -0
  93. package/skills/global_config/finishing-a-development-branch/SKILL.md +228 -0
  94. package/skills/global_config/github-actions-generator/SKILL.md +353 -0
  95. package/skills/global_config/github-actions-generator/assets/templates/action/composite/action.yml +82 -0
  96. package/skills/global_config/github-actions-generator/assets/templates/action/docker/Dockerfile +25 -0
  97. package/skills/global_config/github-actions-generator/assets/templates/action/docker/action.yml +42 -0
  98. package/skills/global_config/github-actions-generator/assets/templates/action/docker/entrypoint.sh +27 -0
  99. package/skills/global_config/github-actions-generator/assets/templates/action/javascript/action.yml +33 -0
  100. package/skills/global_config/github-actions-generator/assets/templates/action/javascript/index.js +50 -0
  101. package/skills/global_config/github-actions-generator/assets/templates/action/javascript/package.json +27 -0
  102. package/skills/global_config/github-actions-generator/assets/templates/workflow/basic_workflow.yml +242 -0
  103. package/skills/global_config/github-actions-generator/assets/templates/workflow/reusable_workflow.yml +106 -0
  104. package/skills/global_config/github-actions-generator/examples/README.md +147 -0
  105. package/skills/global_config/github-actions-generator/examples/actions/setup-node-cached/action.yml +93 -0
  106. package/skills/global_config/github-actions-generator/examples/caching/docker-buildkit.yml +256 -0
  107. package/skills/global_config/github-actions-generator/examples/security/dependency-review.yml +62 -0
  108. package/skills/global_config/github-actions-generator/examples/security/sbom-attestation.yml +119 -0
  109. package/skills/global_config/github-actions-generator/examples/triggers/chatops-commands.yml +475 -0
  110. package/skills/global_config/github-actions-generator/examples/triggers/repository-dispatch.yml +418 -0
  111. package/skills/global_config/github-actions-generator/examples/triggers/workflow-orchestration.yml +404 -0
  112. package/skills/global_config/github-actions-generator/examples/workflows/docker-build-push.yml +68 -0
  113. package/skills/global_config/github-actions-generator/examples/workflows/go-ci.yml +161 -0
  114. package/skills/global_config/github-actions-generator/examples/workflows/monorepo-ci.yml +340 -0
  115. package/skills/global_config/github-actions-generator/examples/workflows/multi-environment-deploy.yml +406 -0
  116. package/skills/global_config/github-actions-generator/examples/workflows/nodejs-ci.yml +122 -0
  117. package/skills/global_config/github-actions-generator/examples/workflows/python-ci.yml +157 -0
  118. package/skills/global_config/github-actions-generator/examples/workflows/scheduled-tasks.yml +376 -0
  119. package/skills/global_config/github-actions-generator/references/advanced-triggers.md +917 -0
  120. package/skills/global_config/github-actions-generator/references/best-practices.md +755 -0
  121. package/skills/global_config/github-actions-generator/references/common-actions.md +715 -0
  122. package/skills/global_config/github-actions-generator/references/custom-actions.md +320 -0
  123. package/skills/global_config/github-actions-generator/references/expressions-and-contexts.md +688 -0
  124. package/skills/global_config/github-actions-generator/references/modern-features.md +421 -0
  125. package/skills/global_config/github-actions-generator/scripts/test_generator.sh +344 -0
  126. package/skills/global_config/github-actions-templates/SKILL.md +7 -0
  127. package/skills/global_config/github-actions-validator/SKILL.md +576 -0
  128. package/skills/global_config/github-actions-validator/examples/README.md +88 -0
  129. package/skills/global_config/github-actions-validator/examples/outdated-versions.yml +76 -0
  130. package/skills/global_config/github-actions-validator/examples/valid-ci.yml +79 -0
  131. package/skills/global_config/github-actions-validator/examples/with-errors.yml +47 -0
  132. package/skills/global_config/github-actions-validator/references/act_usage.md +233 -0
  133. package/skills/global_config/github-actions-validator/references/action_versions.md +122 -0
  134. package/skills/global_config/github-actions-validator/references/actionlint_usage.md +343 -0
  135. package/skills/global_config/github-actions-validator/references/common_errors.md +512 -0
  136. package/skills/global_config/github-actions-validator/references/modern_features.md +384 -0
  137. package/skills/global_config/github-actions-validator/references/runners.md +317 -0
  138. package/skills/global_config/github-actions-validator/scripts/install_tools.sh +113 -0
  139. package/skills/global_config/github-actions-validator/scripts/validate_workflow.sh +910 -0
  140. package/skills/global_config/github-actions-validator/tests/test_validate_workflow.sh +237 -0
  141. package/skills/global_config/makefile-generator/SKILL.md +614 -0
  142. package/skills/global_config/makefile-generator/assets/templates/.gitkeep +1 -0
  143. package/skills/global_config/makefile-generator/docs/makefile-structure.md +530 -0
  144. package/skills/global_config/makefile-generator/docs/optimization-guide.md +784 -0
  145. package/skills/global_config/makefile-generator/docs/patterns-guide.md +642 -0
  146. package/skills/global_config/makefile-generator/docs/security-guide.md +361 -0
  147. package/skills/global_config/makefile-generator/docs/targets-guide.md +642 -0
  148. package/skills/global_config/makefile-generator/docs/variables-guide.md +596 -0
  149. package/skills/global_config/makefile-generator/scripts/add_standard_targets.sh +539 -0
  150. package/skills/global_config/makefile-generator/scripts/generate_makefile_template.sh +690 -0
  151. package/skills/global_config/makefile-generator/test/test_helper_scripts.sh +190 -0
  152. package/skills/global_config/makefile-validator/SKILL.md +244 -0
  153. package/skills/global_config/makefile-validator/docs/bake-tool.md +1000 -0
  154. package/skills/global_config/makefile-validator/docs/best-practices.md +858 -0
  155. package/skills/global_config/makefile-validator/docs/common-mistakes.md +944 -0
  156. package/skills/global_config/makefile-validator/examples/bad-makefile.mk +77 -0
  157. package/skills/global_config/makefile-validator/examples/good-makefile.mk +103 -0
  158. package/skills/global_config/makefile-validator/scripts/test_validate.sh +382 -0
  159. package/skills/global_config/makefile-validator/scripts/validate_makefile.sh +712 -0
  160. package/skills/global_config/{MCP_Manage → mcp-manage}/SKILL.md +3 -3
  161. package/skills/global_config/requesting-code-review/SKILL.md +98 -0
  162. package/skills/global_config/requesting-code-review/code-reviewer.md +198 -0
  163. package/skills/global_config/using-git-worktrees/SKILL.md +170 -0
  164. package/skills/global_config/verification-before-completion/SKILL.md +123 -0
  165. package/skills/global_config/writing-plans/SKILL.md +126 -46
  166. package/skills/global_config/writing-plans-legacy/SKILL.md +139 -0
@@ -0,0 +1,614 @@
1
+ ---
2
+ name: makefile-generator
3
+ description: Create, generate, or scaffold Makefiles with .PHONY targets and build automation.
4
+ category: engineering-method
5
+ source: cc-devops-skills
6
+ date_added: "2026-09-25"
7
+ ---
8
+
9
+ # Makefile Generator
10
+
11
+ ## Overview
12
+
13
+ Generate production-ready Makefiles with best practices for C/C++, Python, Go, Java, and generic projects. Features GNU Coding Standards compliance, standard targets, security hardening, and automatic validation via makefile-validator skill.
14
+
15
+ ## When to Use
16
+
17
+ - Creating new Makefiles from scratch
18
+ - Setting up build systems for projects (C/C++, Python, Go, Java)
19
+ - Implementing build automation and CI/CD integration
20
+ - Converting manual build processes to Makefiles
21
+ - The user asks to "create", "generate", or "write" a Makefile
22
+
23
+ **Do NOT use for:** Validating existing Makefiles (use makefile-validator), debugging (use `make -d`), or running builds.
24
+
25
+ ## Trigger Phrases
26
+
27
+ Use this skill when prompts look like:
28
+ - "Generate a Makefile for a Go service"
29
+ - "Create a production Makefile with install/test/help targets"
30
+ - "Write a Makefile for a C project with dependency tracking"
31
+ - "Add standard GNU targets to this existing Makefile"
32
+
33
+ ## Generation Workflow
34
+
35
+ ### Stage 1: Gather Requirements
36
+
37
+ Collect information for the following categories. **Use AskUserQuestion when information is missing or ambiguous:**
38
+
39
+ | Category | Information Needed |
40
+ |----------|-------------------|
41
+ | **Project** | Language (C/C++/Python/Go/Java), structure (single/multi-directory) |
42
+ | **Build** | Source files, output artifacts, dependencies, build order |
43
+ | **Install** | PREFIX location, directories (bin/lib/share), files to install |
44
+ | **Targets** | all, install, clean, test, dist, help (which are needed?) |
45
+ | **Config** | Compiler, flags, pkg-config dependencies, cross-compilation |
46
+
47
+ **When to Use AskUserQuestion (MUST ask if any apply):**
48
+
49
+ | Condition | Example Question |
50
+ |-----------|------------------|
51
+ | Language not specified | "What programming language is this project? (C/C++/Go/Python/Java)" |
52
+ | Project structure unclear | "Is this a single-directory or multi-directory project?" |
53
+ | Docker requested but registry unknown | "Which container registry should be used? (docker.io/ghcr.io/custom)" |
54
+ | Multiple binaries possible | "Should this build a single binary or multiple executables?" |
55
+ | Install targets needed but paths unclear | "Where should binaries be installed? (default: /usr/local/bin)" |
56
+ | Cross-compilation mentioned | "What is the target platform/architecture?" |
57
+
58
+ **When to Skip AskUserQuestion (proceed with defaults):**
59
+ - User explicitly provides all required information
60
+ - Standard project type with obvious defaults (e.g., "Go project with Docker" → use standard Go+Docker patterns)
61
+ - User says "use defaults" or "standard setup"
62
+
63
+ **Default Assumptions (when not asking):**
64
+ - Single-directory project structure
65
+ - PREFIX=/usr/local
66
+ - Standard targets: all, build, test, clean, install, help
67
+ - No cross-compilation
68
+
69
+ ### Stage 2: Documentation Lookup
70
+
71
+ **When REQUIRED (MUST perform lookup):**
72
+ - User requests integration with unfamiliar tools, frameworks, or build systems
73
+ - Complex build patterns not covered in Stage 3 examples (e.g., Bazel, Meson, custom toolchains)
74
+ - **Docker/container integration** (Dockerfile builds, multi-stage, registry push)
75
+ - CI/CD platform-specific integration (GitHub Actions, GitLab CI, Jenkins)
76
+ - Cross-compilation for unusual targets or embedded systems
77
+ - Package manager integration (Conan, vcpkg, Homebrew formulas)
78
+ - **Multi-binary or multi-library projects**
79
+ - **Version embedding via ldflags or build-time variables**
80
+
81
+ **When OPTIONAL (may skip external lookup):**
82
+ - Standard language patterns already covered in Stage 3 (C/C++, Go, Python, Java)
83
+ - Simple single-binary projects with no external dependencies
84
+ - User provides complete requirements with no ambiguity
85
+ - Internal docs already cover the required pattern comprehensively
86
+
87
+ **Lookup Process (follow in order):**
88
+
89
+ 1. **ALWAYS consult internal docs first using explicit file-open commands** (primary source of truth):
90
+
91
+ **Full doc path map (prefer full paths for deterministic access):**
92
+
93
+ | Doc | Full Path |
94
+ |-----|-----------|
95
+ | Structure guide | `devops-skills-plugin/skills/makefile-generator/docs/makefile-structure.md` |
96
+ | Variables guide | `devops-skills-plugin/skills/makefile-generator/docs/variables-guide.md` |
97
+ | Targets guide | `devops-skills-plugin/skills/makefile-generator/docs/targets-guide.md` |
98
+ | Patterns guide | `devops-skills-plugin/skills/makefile-generator/docs/patterns-guide.md` |
99
+ | Optimization guide | `devops-skills-plugin/skills/makefile-generator/docs/optimization-guide.md` |
100
+ | Security guide | `devops-skills-plugin/skills/makefile-generator/docs/security-guide.md` |
101
+
102
+ | Requirement | Read This Doc |
103
+ |-------------|---------------|
104
+ | Docker/container targets | `.../docs/patterns-guide.md` (Pattern 8: Docker Integration) |
105
+ | Multi-binary projects | `.../docs/patterns-guide.md` (Pattern 7: Multi-Binary Project) |
106
+ | Go projects with version embedding | `.../docs/patterns-guide.md` (Pattern 5: Go Project) |
107
+ | Parallel builds, caching, ccache | `.../docs/optimization-guide.md` |
108
+ | Credentials, secrets, API keys | `.../docs/security-guide.md` |
109
+ | Complex dependencies, pattern rules | `.../docs/patterns-guide.md` |
110
+ | Order-only prerequisites | `.../docs/optimization-guide.md` or `.../docs/targets-guide.md` |
111
+ | Variables, assignment operators | `.../docs/variables-guide.md` |
112
+
113
+ **Deterministic open/read commands:**
114
+ ```bash
115
+ # From repository root:
116
+ sed -n '1,220p' devops-skills-plugin/skills/makefile-generator/docs/patterns-guide.md
117
+ rg -n "Pattern 5|Pattern 8" devops-skills-plugin/skills/makefile-generator/docs/patterns-guide.md
118
+
119
+ # From skill directory:
120
+ sed -n '1,220p' docs/security-guide.md
121
+ ```
122
+
123
+ If shell commands are unavailable, use the environment's file-open/read capability on the same paths.
124
+
125
+ **Required Workflow Example (Docker + Go with version embedding):**
126
+ ```bash
127
+ # Step 1: Read Go pattern
128
+ rg -n "Pattern 5" devops-skills-plugin/skills/makefile-generator/docs/patterns-guide.md
129
+
130
+ # Step 2: Read Docker pattern
131
+ rg -n "Pattern 8" devops-skills-plugin/skills/makefile-generator/docs/patterns-guide.md
132
+
133
+ # Step 3: Read security guidance
134
+ sed -n '1,220p' devops-skills-plugin/skills/makefile-generator/docs/security-guide.md
135
+ ```
136
+ Then generate Makefile and list consulted docs in a header comment.
137
+
138
+ 2. **Try context7 for external tool documentation** (when internal docs don't cover a specific tool):
139
+ ```
140
+ # Only needed for tools/frameworks NOT covered in internal docs
141
+ mcp__context7__resolve-library-id: "<tool-name>"
142
+ mcp__context7__query-docs: query="<integration-topic>"
143
+
144
+ # Example queries:
145
+ # - For Docker: query="dockerfile best practices"
146
+ # - For Go: query="go build ldflags"
147
+ # - For specific tools: query="<tool> makefile integration"
148
+ ```
149
+ **Fallback:** If context7 is unavailable or returns nothing useful, record that and continue to Step 3.
150
+
151
+ 3. **Fallback to WebSearch** (only if pattern not found in internal docs OR context7):
152
+ ```
153
+ "<specific-feature>" makefile best practices 2025
154
+ Example: "docker makefile best practices 2025"
155
+ Example: "go ldflags version makefile 2025"
156
+ ```
157
+ **Trigger WebSearch when:** Internal docs don't cover the specific integration AND context7 returns no relevant results.
158
+
159
+ **Note:** Document which internal docs you consulted in your response (add comment in generated Makefile header).
160
+
161
+ ### Stage 3: Generate Makefile
162
+
163
+ **Optional helper-script fast path (for standard layouts):**
164
+ ```bash
165
+ # Generate template: TYPE NAME OUTPUT
166
+ bash scripts/generate_makefile_template.sh go myservice Makefile
167
+
168
+ # Add only selected standard targets
169
+ bash scripts/add_standard_targets.sh Makefile install clean help
170
+ ```
171
+ Use manual authoring when requirements are complex (Docker release flow, multi-binary matrices, custom toolchains).
172
+
173
+ #### Header (choose one style)
174
+
175
+ **Traditional (POSIX-compatible):**
176
+ ```makefile
177
+ .DELETE_ON_ERROR:
178
+ .SUFFIXES:
179
+ ```
180
+
181
+ **Modern (GNU Make 4.0+, recommended):**
182
+ ```makefile
183
+ SHELL := bash
184
+ .ONESHELL:
185
+ .SHELLFLAGS := -eu -o pipefail -c
186
+ .DELETE_ON_ERROR:
187
+ .SUFFIXES:
188
+ MAKEFLAGS += --warn-undefined-variables
189
+ MAKEFLAGS += --no-builtin-rules
190
+ ```
191
+
192
+ #### Standard Variables
193
+
194
+ ```makefile
195
+ # User-overridable (use ?=)
196
+ CC ?= gcc
197
+ CFLAGS ?= -Wall -Wextra -O2
198
+ PREFIX ?= /usr/local
199
+ DESTDIR ?=
200
+
201
+ # GNU installation directories
202
+ BINDIR ?= $(PREFIX)/bin
203
+ LIBDIR ?= $(PREFIX)/lib
204
+ INCLUDEDIR ?= $(PREFIX)/include
205
+
206
+ # Project-specific (use :=)
207
+ PROJECT := myproject
208
+ VERSION := 1.0.0
209
+ SRCDIR := src
210
+ BUILDDIR := build
211
+ SOURCES := $(wildcard $(SRCDIR)/*.c)
212
+ OBJECTS := $(SOURCES:$(SRCDIR)/%.c=$(BUILDDIR)/%.o)
213
+ ```
214
+
215
+ #### Language-Specific Build Rules
216
+
217
+ **C/C++:**
218
+ ```makefile
219
+ $(TARGET): $(OBJECTS)
220
+ $(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
221
+
222
+ $(BUILDDIR)/%.o: $(SRCDIR)/%.c
223
+ @mkdir -p $(@D)
224
+ $(CC) $(CPPFLAGS) $(CFLAGS) -MMD -MP -c $< -o $@
225
+
226
+ -include $(OBJECTS:.o=.d)
227
+ ```
228
+
229
+ **Go:**
230
+ ```makefile
231
+ $(TARGET): $(shell find . -name '*.go') go.mod
232
+ go build -o $@ ./cmd/$(PROJECT)
233
+ ```
234
+
235
+ **Python:**
236
+ ```makefile
237
+ .PHONY: build
238
+ build:
239
+ python -m build
240
+
241
+ .PHONY: develop
242
+ develop:
243
+ pip install -e .[dev]
244
+ ```
245
+
246
+ **Java:**
247
+ ```makefile
248
+ $(BUILDDIR)/%.class: $(SRCDIR)/%.java
249
+ @mkdir -p $(@D)
250
+ javac -d $(BUILDDIR) -sourcepath $(SRCDIR) $<
251
+ ```
252
+
253
+ #### Standard Targets
254
+
255
+ ```makefile
256
+ .PHONY: all clean install uninstall test help
257
+
258
+ ## Build all targets
259
+ all: $(TARGET)
260
+
261
+ ## Install to PREFIX
262
+ install: all
263
+ install -d $(DESTDIR)$(BINDIR)
264
+ install -m 755 $(TARGET) $(DESTDIR)$(BINDIR)/
265
+
266
+ ## Remove built files
267
+ clean:
268
+ $(RM) -r $(BUILDDIR) $(TARGET)
269
+
270
+ ## Run tests
271
+ test:
272
+ # Add test commands
273
+
274
+ ## Show help
275
+ help:
276
+ @echo "$(PROJECT) v$(VERSION)"
277
+ @echo "Targets: all, install, clean, test, help"
278
+ @echo "Override: make CC=clang PREFIX=/opt"
279
+ ```
280
+
281
+ ### Stage 4: Validate and Format
282
+
283
+ Validation is required for every generated Makefile.
284
+
285
+ #### Validation Tool Preflight (default + fallback)
286
+
287
+ 1. **Preferred path:** run `makefile-validator`.
288
+ 2. **If validator skill is unavailable:** run local fallback checks:
289
+ ```bash
290
+ # Required fallback check (if make exists)
291
+ make -f <Makefile> -n --dry-run
292
+
293
+ # Structural fallback checks
294
+ rg -n '^ {1,}\S' <Makefile> # suspicious space-indented recipe lines
295
+ rg -n '^\.PHONY:' <Makefile>
296
+ ```
297
+ 3. **If `make` is unavailable:** run structural checks only, report "partial validation due to missing make binary", and request user confirmation before claiming production readiness.
298
+
299
+ #### Required Validation Loop
300
+
301
+ ```
302
+ 1. Generate Makefile following stages above
303
+ 2. Run validator skill (or fallback checks if unavailable)
304
+ 3. Fix all errors (MUST have 0 errors before completion)
305
+ 4. Apply formatting fixes (see "Formatting Step" below)
306
+ 5. Fix warnings when feasible (SHOULD fix; explain if skipped)
307
+ 6. Address info items for large/production projects
308
+ 7. Re-run validation until checks pass
309
+ 8. Output structured validation report (REQUIRED - see format below)
310
+ ```
311
+
312
+ #### Formatting Step (REQUIRED)
313
+
314
+ When mbake reports formatting issues, you MUST either:
315
+
316
+ 1. **Auto-apply formatting** (preferred for minor issues):
317
+ ```bash
318
+ mbake format <Makefile>
319
+ ```
320
+
321
+ 2. **Explain why not applied** (if formatting would break functionality):
322
+ ```
323
+ Formatting not applied because:
324
+ - [specific reason, e.g., "heredoc syntax would be corrupted"]
325
+ - Manual review recommended for: [specific lines]
326
+ ```
327
+
328
+ If `mbake` is not installed or not executable, skip formatter execution and record:
329
+ `Formatting skipped: mbake unavailable in current environment.`
330
+
331
+ **Formatting Decision Guide:**
332
+
333
+ | mbake Report | Action |
334
+ |--------------|--------|
335
+ | "Would reformat" with no specific issues | Auto-apply with `mbake format` |
336
+ | Specific whitespace/indentation issues | Auto-apply with `mbake format` |
337
+ | Issues in complex heredocs or multi-line strings | Skip formatting, explain in output |
338
+ | Issues in `# bake-format off` sections | Skip (intentionally disabled) |
339
+ | `mbake` command unavailable | Skip formatting, record tool-unavailable reason |
340
+
341
+ **Validation Pass Criteria:**
342
+
343
+ | Level | Requirement | Action |
344
+ |-------|-------------|--------|
345
+ | **Errors (0 required)** | Syntax errors, missing tabs, invalid targets | MUST fix before completion |
346
+ | **Warnings (fix if feasible)** | Formatting issues, missing optimizations | SHOULD fix; explain if skipped |
347
+ | **Info (address for production)** | Enhancement suggestions, style preferences | SHOULD address for production Makefiles |
348
+
349
+ **Known mbake False Positives (can be safely ignored):**
350
+
351
+ The mbake validator may report warnings for valid GNU Make special targets. These are false positives and can be ignored:
352
+
353
+ | mbake Warning | Actual Status | Explanation |
354
+ |---------------|---------------|-------------|
355
+ | "Unknown special target '.DELETE_ON_ERROR'" | ✅ Valid | Critical GNU Make target that deletes failed build artifacts |
356
+ | "Unknown special target '.SUFFIXES'" | ✅ Valid | Standard GNU Make target for disabling/setting suffix rules |
357
+ | "Unknown special target '.ONESHELL'" | ✅ Valid | GNU Make 3.82+ feature for single-shell recipe execution |
358
+ | "Unknown special target '.POSIX'" | ✅ Valid | POSIX compliance declaration |
359
+
360
+ #### Validation Report Output (REQUIRED)
361
+
362
+ After validation completes, you MUST output a structured report in the following format. This is not optional.
363
+
364
+ **Required Report Format:**
365
+
366
+ ```
367
+ ## Validation Report
368
+
369
+ **Result:** [PASSED / PASSED with warnings / FAILED]
370
+ **Errors:** [count]
371
+ **Warnings:** [count]
372
+ **Info:** [count]
373
+
374
+ ### Errors Fixed
375
+ - [List each error and how it was fixed, or "None" if 0 errors]
376
+
377
+ ### Warnings Addressed
378
+ - [List each warning that was fixed]
379
+
380
+ ### Warnings Skipped (with reasons)
381
+ - [List each warning that was NOT fixed and explain why]
382
+ - Example: "mbake reports '.DELETE_ON_ERROR' as unknown - this is a valid GNU Make
383
+ special target (false positive)"
384
+
385
+ ### Formatting Applied
386
+ - [Yes/No] - [If No, explain why formatting was skipped]
387
+
388
+ ### Info Items Addressed
389
+ - [List info items that were addressed for production Makefiles]
390
+ - [Or "N/A - simple project" if not applicable]
391
+
392
+ ### Remaining Issues (if any)
393
+ - [List any issues requiring user attention]
394
+ - [Or "None - Makefile is production-ready"]
395
+ ```
396
+
397
+ **Example Complete Report:**
398
+
399
+ ```
400
+ ## Validation Report
401
+
402
+ **Result:** PASSED with warnings
403
+ **Errors:** 0
404
+ **Warnings:** 2
405
+ **Info:** 1
406
+
407
+ ### Errors Fixed
408
+ - None
409
+
410
+ ### Warnings Addressed
411
+ - Fixed: Added error handling to install target (|| exit 1)
412
+
413
+ ### Warnings Skipped (with reasons)
414
+ - mbake reports ".DELETE_ON_ERROR" as unknown - this is a valid and critical
415
+ GNU Make special target that ensures failed builds don't leave corrupt files.
416
+ See: https://www.gnu.org/software/make/manual/html_node/Special-Targets.html
417
+
418
+ ### Formatting Applied
419
+ - Yes - Applied `mbake format` to fix whitespace issues
420
+
421
+ ### Info Items Addressed
422
+ - Added .NOTPARALLEL for Docker targets (parallel safety)
423
+ - Added error handling for docker-push target
424
+
425
+ ### Remaining Issues
426
+ - None - Makefile is production-ready
427
+ ```
428
+
429
+ **Common Info Items to Address:**
430
+
431
+ | Info Item | When to Fix | How to Fix |
432
+ |-----------|-------------|------------|
433
+ | "mkdir without order-only prerequisites" | Large projects (>10 targets) | Use `target: prereqs \| $(BUILDDIR)` pattern |
434
+ | "recipe commands lack error handling" | Critical operations (install, deploy) | Add `set -e` in .SHELLFLAGS or use `&&` chaining |
435
+ | "consider using ccache" | Long compile times | Add `CC := ccache $(CC)` pattern |
436
+ | "parallel-sensitive commands detected" | Docker/npm/pip targets | Add `.NOTPARALLEL:` for affected targets or proper dependencies |
437
+
438
+ **Production-Quality Requirements (MUST address for Docker/deploy targets):**
439
+
440
+ When generating Makefiles with Docker or deployment targets, you MUST apply these production patterns:
441
+
442
+ 1. **Error Handling for docker-push:**
443
+ ```makefile
444
+ ## Push Docker image to registry (with error handling)
445
+ docker-push: docker-build
446
+ @echo "Pushing $(IMAGE)..."
447
+ docker push $(IMAGE) || { echo "Failed to push $(IMAGE)"; exit 1; }
448
+ docker push $(IMAGE_LATEST) || { echo "Failed to push $(IMAGE_LATEST)"; exit 1; }
449
+ ```
450
+
451
+ 2. **Parallel Safety for Docker targets:**
452
+ ```makefile
453
+ # Prevent parallel execution of Docker targets (race conditions)
454
+ .NOTPARALLEL: docker-build docker-push docker-run
455
+ ```
456
+ Or use proper dependencies to serialize:
457
+ ```makefile
458
+ docker-push: docker-build # Ensures build completes before push
459
+ docker-run: docker-build # Ensures build completes before run
460
+ ```
461
+
462
+ 3. **Install target error handling:**
463
+ ```makefile
464
+ install: $(TARGET)
465
+ install -d $(DESTDIR)$(PREFIX)/bin || exit 1
466
+ install -m 755 $(TARGET) $(DESTDIR)$(PREFIX)/bin/ || exit 1
467
+ ```
468
+
469
+ **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.
470
+
471
+ **Validation Checklist:**
472
+ - [ ] Syntax correct (`make -n` passes)
473
+ - [ ] All non-file targets have .PHONY
474
+ - [ ] Tab indentation (not spaces)
475
+ - [ ] No hardcoded credentials
476
+ - [ ] User-overridable variables use `?=`
477
+ - [ ] .DELETE_ON_ERROR present
478
+ - [ ] MAKEFLAGS optimizations included (Modern header)
479
+ - [ ] Order-only prerequisites for build directories (large projects)
480
+ - [ ] Error handling in critical recipes (install, deploy, docker-push)
481
+
482
+ ## Best Practices
483
+
484
+ ### Variables
485
+ - `?=` for user-overridable (CC, CFLAGS, PREFIX)
486
+ - `:=` for project-specific (SOURCES, OBJECTS)
487
+ - Use pkg-config: `CFLAGS += $(shell pkg-config --cflags lib)`
488
+
489
+ ### Targets
490
+ - Always declare `.PHONY` for non-file targets
491
+ - Default target should be `all`
492
+ - Use `.DELETE_ON_ERROR` for safety
493
+ - Document with `##` comments for help target
494
+
495
+ ### Directory Creation
496
+ Two approaches for creating build directories:
497
+
498
+ **Simple (inline mkdir):**
499
+ ```makefile
500
+ $(BUILDDIR)/%.o: $(SRCDIR)/%.c
501
+ @mkdir -p $(@D)
502
+ $(CC) $(CFLAGS) -c $< -o $@
503
+ ```
504
+
505
+ **Optimized (order-only prerequisites):** Prevents unnecessary rebuilds when directory timestamps change.
506
+ ```makefile
507
+ $(BUILDDIR):
508
+ @mkdir -p $@
509
+
510
+ $(BUILDDIR)/%.o: $(SRCDIR)/%.c | $(BUILDDIR)
511
+ $(CC) $(CFLAGS) -c $< -o $@
512
+ ```
513
+ Use order-only prerequisites (`|`) for large projects with many targets.
514
+
515
+ ### Recipes
516
+ - Use tabs, never spaces
517
+ - Quote variables in shell: `$(RM) "$(TARGET)"`
518
+ - Use `@` prefix for quiet commands
519
+ - Test with `make -n` first
520
+
521
+ ## Helper Scripts (Optional)
522
+
523
+ These scripts are **optional convenience tools** for quick template generation.
524
+
525
+ ### When to Use Scripts vs Manual Generation
526
+
527
+ | Scenario | Recommendation |
528
+ |----------|----------------|
529
+ | Simple, standard project (single binary, no special features) | ✅ Use `generate_makefile_template.sh` for speed |
530
+ | Complex project (Docker, multi-binary, custom patterns) | ❌ Use manual generation for full control |
531
+ | Adding targets to existing Makefile | ✅ Use `add_standard_targets.sh` |
532
+ | User has specific formatting/style requirements | ❌ Use manual generation |
533
+ | Rapid prototyping / proof-of-concept | ✅ Use scripts, customize later |
534
+ | Production-ready Makefile | ⚠️ Start with script, then customize manually |
535
+
536
+ ### generate_makefile_template.sh
537
+
538
+ Generates a complete Makefile template for a specific project type.
539
+ Script path: `scripts/generate_makefile_template.sh`
540
+
541
+ ```bash
542
+ bash scripts/generate_makefile_template.sh [TYPE] [NAME] [OUTPUT_FILE]
543
+
544
+ Types: c, c-lib, cpp, go, python, java, generic
545
+ ```
546
+
547
+ **Example:**
548
+ ```bash
549
+ bash scripts/generate_makefile_template.sh go myservice
550
+ # Creates Makefile with Go patterns, version embedding, standard targets
551
+
552
+ bash scripts/generate_makefile_template.sh go myservice build/Makefile
553
+ # Writes template to build/Makefile (TYPE NAME OUTPUT)
554
+ ```
555
+
556
+ ### add_standard_targets.sh
557
+
558
+ Adds missing standard GNU targets to an existing Makefile.
559
+ Script path: `scripts/add_standard_targets.sh`
560
+
561
+ ```bash
562
+ bash scripts/add_standard_targets.sh [MAKEFILE] [TARGETS...]
563
+ bash scripts/add_standard_targets.sh [TARGETS...] # uses ./Makefile
564
+
565
+ Targets: all, install, uninstall, clean, distclean, test, check, help, dist
566
+ ```
567
+
568
+ **Example:**
569
+ ```bash
570
+ bash scripts/add_standard_targets.sh Makefile install uninstall help
571
+ # Adds install, uninstall, help targets if they don't exist
572
+
573
+ bash scripts/add_standard_targets.sh clean test
574
+ # Explicit-target mode: modifies ./Makefile
575
+
576
+ bash scripts/add_standard_targets.sh -n Makefile dist
577
+ # Dry-run mode: shows planned changes without editing files
578
+ ```
579
+
580
+ **Note:** Manual generation following the Stage 3 patterns produces equivalent results but allows for more customization.
581
+
582
+ ### Helper Script Regression Smoke Tests
583
+
584
+ Run after modifying helper scripts or templates:
585
+ ```bash
586
+ bash test/test_helper_scripts.sh
587
+ ```
588
+
589
+ ## Done Criteria
590
+
591
+ Consider the task complete only when all checks below are satisfied:
592
+ - Trigger matched and missing requirements were clarified (or documented defaults were applied).
593
+ - Relevant internal docs were opened via explicit file paths before generation.
594
+ - Generated Makefile has complete `.PHONY` coverage for non-file targets.
595
+ - Go templates include optional `go.sum` handling and configurable `GO_MAIN` entrypoint.
596
+ - Validation ran with `makefile-validator` (preferred) or documented fallback checks.
597
+ - Formatting was applied with `mbake`, or skipped with an explicit tool-unavailable/compatibility reason.
598
+ - Final response includes the required structured validation report.
599
+
600
+ ## Documentation
601
+
602
+ Detailed guides in `docs/`:
603
+ - **makefile-structure.md** - Organization, layout, includes
604
+ - **variables-guide.md** - Assignment operators, automatic variables
605
+ - **targets-guide.md** - Standard targets, .PHONY, prerequisites
606
+ - **patterns-guide.md** - Pattern rules, dependencies
607
+ - **optimization-guide.md** - Parallel builds, caching
608
+ - **security-guide.md** - Safe expansion, credential handling
609
+
610
+ ## Resources
611
+
612
+ - [GNU Make Manual](https://www.gnu.org/software/make/manual/)
613
+ - [GNU Coding Standards](https://www.gnu.org/prep/standards/standards.html)
614
+ - [Makefile Conventions](https://www.gnu.org/prep/standards/html_node/Makefile-Conventions.html)
@@ -0,0 +1 @@
1
+ # Placeholder to preserve directory in git