codeforge-dev 1.8.0 → 1.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 (39) hide show
  1. package/.devcontainer/CHANGELOG.md +51 -0
  2. package/.devcontainer/CLAUDE.md +1 -1
  3. package/.devcontainer/config/defaults/rules/spec-workflow.md +67 -0
  4. package/.devcontainer/config/defaults/rules/workspace-scope.md +7 -0
  5. package/.devcontainer/config/defaults/settings.json +63 -66
  6. package/.devcontainer/config/file-manifest.json +30 -18
  7. package/.devcontainer/plugins/devs-marketplace/.claude-plugin/marketplace.json +104 -97
  8. package/.devcontainer/plugins/devs-marketplace/plugins/auto-code-quality/.claude-plugin/plugin.json +7 -0
  9. package/.devcontainer/plugins/devs-marketplace/plugins/auto-code-quality/README.md +158 -0
  10. package/.devcontainer/plugins/devs-marketplace/plugins/auto-code-quality/hooks/hooks.json +39 -0
  11. package/.devcontainer/plugins/devs-marketplace/plugins/auto-code-quality/scripts/collect-edited-files.py +47 -0
  12. package/.devcontainer/plugins/devs-marketplace/plugins/auto-code-quality/scripts/format-on-stop.py +297 -0
  13. package/.devcontainer/plugins/devs-marketplace/plugins/auto-code-quality/scripts/lint-file.py +536 -0
  14. package/.devcontainer/plugins/devs-marketplace/plugins/auto-code-quality/scripts/syntax-validator.py +146 -0
  15. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/architect.md +77 -1
  16. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/debug-logs.md +18 -0
  17. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/dependency-analyst.md +18 -0
  18. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/doc-writer.md +86 -1
  19. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/explorer.md +18 -0
  20. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/generalist.md +142 -8
  21. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/git-archaeologist.md +18 -0
  22. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/migrator.md +108 -1
  23. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/perf-profiler.md +24 -0
  24. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/refactorer.md +97 -1
  25. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/researcher.md +33 -1
  26. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/security-auditor.md +24 -0
  27. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/spec-writer.md +29 -1
  28. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/test-writer.md +96 -1
  29. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/hooks/hooks.json +100 -95
  30. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/spec-reminder.py +121 -0
  31. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/spec-check/SKILL.md +86 -0
  32. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/spec-init/SKILL.md +97 -0
  33. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/spec-init/references/backlog-template.md +7 -0
  34. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/spec-init/references/roadmap-template.md +13 -0
  35. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/spec-new/SKILL.md +101 -0
  36. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/spec-new/references/template.md +110 -0
  37. package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/spec-update/SKILL.md +124 -0
  38. package/.devcontainer/scripts/setup-config.sh +86 -83
  39. package/package.json +42 -42
@@ -0,0 +1,158 @@
1
+ # auto-code-quality
2
+
3
+ Self-contained Claude Code plugin that automatically formats and lints edited files. Drop it into any Claude Code plugin marketplace and enable it — no other plugins required.
4
+
5
+ ## What It Does
6
+
7
+ Three-phase pipeline that runs transparently during your Claude Code session:
8
+
9
+ 1. **Collect** (PostToolUse on Edit/Write) — Records which files Claude edits
10
+ 2. **Format** (Stop hook) — Batch-formats all edited files when Claude finishes responding
11
+ 3. **Lint** (Stop hook) — Batch-lints all edited files and surfaces warnings as context
12
+
13
+ Additionally validates JSON, JSONC, YAML, and TOML syntax immediately after each edit.
14
+
15
+ All phases are non-blocking. Missing tools are silently skipped. The plugin always exits cleanly — it will never interrupt Claude.
16
+
17
+ ## Required Tools
18
+
19
+ Install the tools for the languages you work with. Everything is optional — the plugin gracefully skips any tool that isn't found.
20
+
21
+ | Language | Formatter | Linter(s) | Install |
22
+ |----------|-----------|-----------|---------|
23
+ | Python | [ruff](https://docs.astral.sh/ruff/) | [pyright](https://github.com/microsoft/pyright), ruff check | `pip install ruff` / `npm i -g pyright` |
24
+ | Python (fallback) | [black](https://github.com/psf/black) | — | `pip install black` |
25
+ | Go | gofmt (bundled with Go) | go vet (bundled with Go) | [Install Go](https://go.dev/dl/) |
26
+ | JS/TS/CSS/GraphQL/HTML | [biome](https://biomejs.dev/) | biome lint | `npm i -D @biomejs/biome` or `npm i -g @biomejs/biome` |
27
+ | Shell | [shfmt](https://github.com/mvdan/sh) | [shellcheck](https://github.com/koalaman/shellcheck) | `brew install shfmt shellcheck` |
28
+ | Markdown/YAML/TOML | [dprint](https://dprint.dev/) | — | `brew install dprint` |
29
+ | Dockerfile | dprint | [hadolint](https://github.com/hadolint/hadolint) | `brew install hadolint` |
30
+ | Rust | rustfmt (bundled with Rust) | clippy (bundled with Rust) | [Install Rust](https://rustup.rs/) |
31
+ | JSON/JSONC/YAML/TOML | — | syntax-validator (Python stdlib) | No extra install needed |
32
+
33
+ ### dprint Configuration
34
+
35
+ The dprint formatter looks for a config file at `/usr/local/share/dprint/dprint.json`. If this file doesn't exist, dprint formatting is skipped. Create one with your preferred settings, or use a minimal config:
36
+
37
+ ```json
38
+ {
39
+ "markdown": {},
40
+ "toml": {},
41
+ "yaml": {}
42
+ }
43
+ ```
44
+
45
+ ### Biome Discovery
46
+
47
+ Biome is resolved in this order:
48
+ 1. Project-local: walks up from the edited file looking for `node_modules/.bin/biome`
49
+ 2. Global: checks PATH via `which biome`
50
+
51
+ ## Installation
52
+
53
+ ### 1. Place the plugin
54
+
55
+ Copy the `auto-code-quality/` directory into your Claude Code plugin marketplace:
56
+
57
+ ```
58
+ your-marketplace/
59
+ ├── .claude-plugin/
60
+ │ └── marketplace.json
61
+ └── plugins/
62
+ └── auto-code-quality/ ← this directory
63
+ ```
64
+
65
+ ### 2. Register in marketplace.json
66
+
67
+ Add this entry to your `marketplace.json` `plugins` array:
68
+
69
+ ```json
70
+ {
71
+ "name": "auto-code-quality",
72
+ "description": "Self-contained code quality: auto-format + auto-lint edited files",
73
+ "version": "1.0.0",
74
+ "source": "./plugins/auto-code-quality",
75
+ "category": "development"
76
+ }
77
+ ```
78
+
79
+ ### 3. Enable in settings.json
80
+
81
+ Add to your Claude Code `settings.json` under `enabledPlugins`:
82
+
83
+ ```json
84
+ {
85
+ "enabledPlugins": {
86
+ "auto-code-quality@your-marketplace": true
87
+ }
88
+ }
89
+ ```
90
+
91
+ Replace `your-marketplace` with the name of your marketplace.
92
+
93
+ ## How It Works
94
+
95
+ ### Hook Lifecycle
96
+
97
+ ```
98
+ You edit a file (Edit/Write tool)
99
+
100
+ ├─→ collect-edited-files.py Appends path to temp files
101
+ └─→ syntax-validator.py Validates JSON/YAML/TOML syntax immediately
102
+
103
+ │ ... Claude keeps working ...
104
+
105
+ Claude stops responding (Stop event)
106
+
107
+ ├─→ format-on-stop.py Reads temp file, formats each file by extension
108
+ └─→ lint-file.py Reads temp file, lints each file, injects warnings
109
+ ```
110
+
111
+ ### Temp File Convention
112
+
113
+ Edited file paths are stored in session-scoped temp files:
114
+ - `/tmp/claude-cq-edited-{session_id}` — consumed by the formatter
115
+ - `/tmp/claude-cq-lint-{session_id}` — consumed by the linter
116
+
117
+ Both are always cleaned up after processing (even on error).
118
+
119
+ ### Timeouts
120
+
121
+ | Hook | Timeout |
122
+ |------|---------|
123
+ | File collection | 3s |
124
+ | Syntax validation | 5s |
125
+ | Batch formatting | 15s total |
126
+ | Batch linting | 60s total |
127
+ | Individual tool | 10-12s each |
128
+
129
+ ## Conflict Warning
130
+
131
+ This plugin bundles functionality that may overlap with other plugins. If you're using any of the following, **disable them** before enabling this plugin to avoid duplicate processing:
132
+
133
+ - `auto-formatter` — formatting is included here
134
+ - `auto-linter` — linting is included here
135
+ - `code-directive` `collect-edited-files.py` hook — file collection is included here
136
+
137
+ The temp file prefixes are different (`claude-cq-*` vs `claude-edited-files-*` / `claude-lint-files-*`), so enabling both won't corrupt data — but files would be formatted and linted twice.
138
+
139
+ ## Plugin Structure
140
+
141
+ ```
142
+ auto-code-quality/
143
+ ├── .claude-plugin/
144
+ │ └── plugin.json # Plugin metadata
145
+ ├── hooks/
146
+ │ └── hooks.json # Hook registrations (PostToolUse + Stop)
147
+ ├── scripts/
148
+ │ ├── collect-edited-files.py # File path collector (PostToolUse)
149
+ │ ├── syntax-validator.py # JSON/YAML/TOML validator (PostToolUse)
150
+ │ ├── format-on-stop.py # Batch formatter (Stop)
151
+ │ └── lint-file.py # Batch linter (Stop)
152
+ └── README.md # This file
153
+ ```
154
+
155
+ ## Requirements
156
+
157
+ - Python 3.11+ (for `tomllib` support in syntax validation; older Python skips TOML)
158
+ - Claude Code with plugin hook support
@@ -0,0 +1,39 @@
1
+ {
2
+ "description": "Self-contained code quality: file collection on edit, syntax validation, batch formatting + linting at stop",
3
+ "hooks": {
4
+ "PostToolUse": [
5
+ {
6
+ "matcher": "Edit|Write",
7
+ "hooks": [
8
+ {
9
+ "type": "command",
10
+ "command": "python3 ${CLAUDE_PLUGIN_ROOT}/scripts/collect-edited-files.py",
11
+ "timeout": 3
12
+ },
13
+ {
14
+ "type": "command",
15
+ "command": "python3 ${CLAUDE_PLUGIN_ROOT}/scripts/syntax-validator.py",
16
+ "timeout": 5
17
+ }
18
+ ]
19
+ }
20
+ ],
21
+ "Stop": [
22
+ {
23
+ "matcher": "",
24
+ "hooks": [
25
+ {
26
+ "type": "command",
27
+ "command": "python3 ${CLAUDE_PLUGIN_ROOT}/scripts/format-on-stop.py",
28
+ "timeout": 15
29
+ },
30
+ {
31
+ "type": "command",
32
+ "command": "python3 ${CLAUDE_PLUGIN_ROOT}/scripts/lint-file.py",
33
+ "timeout": 60
34
+ }
35
+ ]
36
+ }
37
+ ]
38
+ }
39
+ }
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Collect edited file paths for batch formatting and linting at Stop.
4
+
5
+ Lightweight PostToolUse hook that appends the edited file path
6
+ to session-scoped temp files. The format and lint Stop hooks
7
+ read these files to know which files need processing.
8
+
9
+ Non-blocking: always exits 0. Runs in <10ms.
10
+ """
11
+
12
+ import json
13
+ import os
14
+ import sys
15
+
16
+
17
+ def main():
18
+ try:
19
+ input_data = json.load(sys.stdin)
20
+ except (json.JSONDecodeError, ValueError):
21
+ sys.exit(0)
22
+
23
+ session_id = input_data.get("session_id", "")
24
+ tool_input = input_data.get("tool_input", {})
25
+ file_path = tool_input.get("file_path", "")
26
+
27
+ if not file_path or not session_id:
28
+ sys.exit(0)
29
+
30
+ if not os.path.isfile(file_path):
31
+ sys.exit(0)
32
+
33
+ # Write to both formatter and linter temp files (independent pipelines)
34
+ # Uses "claude-cq-" prefix to avoid collision with other plugins
35
+ for prefix in ("claude-cq-edited", "claude-cq-lint"):
36
+ tmp_path = f"/tmp/{prefix}-{session_id}"
37
+ try:
38
+ with open(tmp_path, "a") as f:
39
+ f.write(file_path + "\n")
40
+ except OSError:
41
+ pass # non-critical, don't block Claude
42
+
43
+ sys.exit(0)
44
+
45
+
46
+ if __name__ == "__main__":
47
+ main()
@@ -0,0 +1,297 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Unified batch formatter — runs as a Stop hook.
4
+
5
+ Reads file paths collected by collect-edited-files.py during the
6
+ conversation turn, deduplicates them, and formats each based on
7
+ extension:
8
+ .py / .pyi → Ruff format (fallback: Black)
9
+ .go → gofmt
10
+ .js/.jsx/.ts/.tsx/.mjs/.cjs/.mts/.cts → Biome check --write
11
+ .css/.json/.jsonc/.graphql/.gql → Biome check --write
12
+ .html/.vue/.svelte/.astro → Biome check --write
13
+ .sh/.bash/.zsh/.mksh/.bats → shfmt -w
14
+ .md/.markdown → dprint fmt
15
+ .yaml/.yml → dprint fmt
16
+ .toml → dprint fmt
17
+ Dockerfile / .dockerfile → dprint fmt
18
+ .rs → rustfmt
19
+
20
+ Always cleans up the temp file. Always exits 0.
21
+ """
22
+
23
+ import json
24
+ import os
25
+ import subprocess
26
+ import sys
27
+ from pathlib import Path
28
+
29
+ # ── Extension sets ──────────────────────────────────────────────────
30
+
31
+ PYTHON_EXTS = {".py", ".pyi"}
32
+ GO_EXTS = {".go"}
33
+ BIOME_EXTS = {
34
+ ".js",
35
+ ".jsx",
36
+ ".ts",
37
+ ".tsx",
38
+ ".mjs",
39
+ ".cjs",
40
+ ".mts",
41
+ ".cts",
42
+ ".css",
43
+ ".json",
44
+ ".jsonc",
45
+ ".graphql",
46
+ ".gql",
47
+ ".html",
48
+ ".vue",
49
+ ".svelte",
50
+ ".astro",
51
+ }
52
+ SHELL_EXTS = {".sh", ".bash", ".zsh", ".mksh", ".bats"}
53
+ DPRINT_EXTS = {".md", ".markdown", ".yaml", ".yml", ".toml"}
54
+ RUST_EXTS = {".rs"}
55
+
56
+ # ── Fallback paths ──────────────────────────────────────────────────
57
+
58
+ BLACK_PATH_FALLBACK = "/usr/local/py-utils/bin/black"
59
+ GOFMT_PATH_FALLBACK = "/usr/local/go/bin/gofmt"
60
+ DPRINT_CONFIG = "/usr/local/share/dprint/dprint.json"
61
+
62
+ # ── Tool resolution ─────────────────────────────────────────────────
63
+
64
+
65
+ def _resolve_tool(name: str, fallback: str = "") -> str | None:
66
+ """Find tool via PATH first, fall back to hardcoded path."""
67
+ try:
68
+ result = subprocess.run(["which", name], capture_output=True, text=True)
69
+ if result.returncode == 0:
70
+ return result.stdout.strip()
71
+ except Exception:
72
+ pass
73
+ if fallback and os.path.exists(fallback):
74
+ return fallback
75
+ return None
76
+
77
+
78
+ def find_tool_upward(file_path: str, tool_name: str) -> str | None:
79
+ """Walk up from file directory looking for node_modules/.bin/<tool>."""
80
+ current = Path(file_path).parent
81
+ for _ in range(20):
82
+ candidate = current / "node_modules" / ".bin" / tool_name
83
+ if candidate.is_file():
84
+ return str(candidate)
85
+ parent = current.parent
86
+ if parent == current:
87
+ break
88
+ current = parent
89
+ return None
90
+
91
+
92
+ def find_global_tool(tool_name: str) -> str | None:
93
+ """Check if tool is available globally."""
94
+ try:
95
+ result = subprocess.run(
96
+ ["which", tool_name],
97
+ capture_output=True,
98
+ text=True,
99
+ )
100
+ if result.returncode == 0:
101
+ return result.stdout.strip()
102
+ except Exception:
103
+ pass
104
+ return None
105
+
106
+
107
+ def find_biome(file_path: str) -> str | None:
108
+ """Find biome binary: project-local first, then global."""
109
+ local = find_tool_upward(file_path, "biome")
110
+ if local:
111
+ return local
112
+ return find_global_tool("biome")
113
+
114
+
115
+ # ── Formatters ──────────────────────────────────────────────────────
116
+
117
+
118
+ def format_python(file_path: str) -> None:
119
+ """Format with Ruff (preferred) or Black (fallback)."""
120
+ ruff = _resolve_tool("ruff")
121
+ if ruff:
122
+ try:
123
+ subprocess.run(
124
+ [ruff, "format", "--quiet", file_path],
125
+ capture_output=True,
126
+ timeout=10,
127
+ )
128
+ return
129
+ except (subprocess.TimeoutExpired, OSError):
130
+ pass
131
+
132
+ # Fallback to Black
133
+ black = _resolve_tool("black", BLACK_PATH_FALLBACK)
134
+ if not black:
135
+ return
136
+ try:
137
+ subprocess.run(
138
+ [black, "--quiet", file_path],
139
+ capture_output=True,
140
+ timeout=10,
141
+ )
142
+ except (subprocess.TimeoutExpired, OSError):
143
+ pass
144
+
145
+
146
+ def format_go(file_path: str) -> None:
147
+ """Format with gofmt."""
148
+ gofmt = _resolve_tool("gofmt", GOFMT_PATH_FALLBACK)
149
+ if not gofmt:
150
+ return
151
+ try:
152
+ subprocess.run(
153
+ [gofmt, "-w", file_path],
154
+ capture_output=True,
155
+ timeout=10,
156
+ )
157
+ except (subprocess.TimeoutExpired, OSError):
158
+ pass
159
+
160
+
161
+ def format_biome(file_path: str) -> None:
162
+ """Format with Biome in safe mode (no --unsafe)."""
163
+ biome = find_biome(file_path)
164
+ if not biome:
165
+ return
166
+ try:
167
+ subprocess.run(
168
+ [biome, "check", "--write", file_path],
169
+ capture_output=True,
170
+ timeout=12,
171
+ )
172
+ except (subprocess.TimeoutExpired, OSError):
173
+ pass
174
+
175
+
176
+ def format_shell(file_path: str) -> None:
177
+ """Format with shfmt."""
178
+ shfmt = _resolve_tool("shfmt")
179
+ if not shfmt:
180
+ return
181
+ try:
182
+ subprocess.run(
183
+ [shfmt, "-w", file_path],
184
+ capture_output=True,
185
+ timeout=10,
186
+ )
187
+ except (subprocess.TimeoutExpired, OSError):
188
+ pass
189
+
190
+
191
+ def format_dprint(file_path: str) -> None:
192
+ """Format with dprint using the global config."""
193
+ dprint = _resolve_tool("dprint")
194
+ if not dprint:
195
+ return
196
+ if not os.path.isfile(DPRINT_CONFIG):
197
+ return
198
+ try:
199
+ subprocess.run(
200
+ [dprint, "fmt", "--config", DPRINT_CONFIG, file_path],
201
+ capture_output=True,
202
+ timeout=10,
203
+ )
204
+ except (subprocess.TimeoutExpired, OSError):
205
+ pass
206
+
207
+
208
+ def format_rust(file_path: str) -> None:
209
+ """Format with rustfmt (conditional — only if installed)."""
210
+ rustfmt = _resolve_tool("rustfmt")
211
+ if not rustfmt:
212
+ return
213
+ try:
214
+ subprocess.run(
215
+ [rustfmt, file_path],
216
+ capture_output=True,
217
+ timeout=10,
218
+ )
219
+ except (subprocess.TimeoutExpired, OSError):
220
+ pass
221
+
222
+
223
+ # ── Dispatch ────────────────────────────────────────────────────────
224
+
225
+
226
+ def format_file(file_path: str) -> None:
227
+ """Dispatch to the correct formatter based on extension / filename."""
228
+ path = Path(file_path)
229
+ ext = path.suffix.lower()
230
+ name = path.name
231
+
232
+ if ext in PYTHON_EXTS:
233
+ format_python(file_path)
234
+ elif ext in GO_EXTS:
235
+ format_go(file_path)
236
+ elif ext in BIOME_EXTS:
237
+ format_biome(file_path)
238
+ elif ext in SHELL_EXTS:
239
+ format_shell(file_path)
240
+ elif ext in DPRINT_EXTS:
241
+ format_dprint(file_path)
242
+ elif ext in RUST_EXTS:
243
+ format_rust(file_path)
244
+ elif name == "Dockerfile" or ext == ".dockerfile":
245
+ format_dprint(file_path)
246
+
247
+
248
+ # ── Main ────────────────────────────────────────────────────────────
249
+
250
+
251
+ def main():
252
+ try:
253
+ input_data = json.load(sys.stdin)
254
+ except (json.JSONDecodeError, ValueError):
255
+ sys.exit(0)
256
+
257
+ # Prevent infinite loops if Stop hook triggers another stop
258
+ if input_data.get("stop_hook_active"):
259
+ sys.exit(0)
260
+
261
+ session_id = input_data.get("session_id", "")
262
+ if not session_id:
263
+ sys.exit(0)
264
+
265
+ tmp_path = f"/tmp/claude-cq-edited-{session_id}"
266
+
267
+ try:
268
+ with open(tmp_path) as f:
269
+ raw_paths = f.read().splitlines()
270
+ except FileNotFoundError:
271
+ sys.exit(0)
272
+ except OSError:
273
+ sys.exit(0)
274
+ finally:
275
+ # Always clean up the temp file
276
+ try:
277
+ os.unlink(tmp_path)
278
+ except OSError:
279
+ pass
280
+
281
+ # Deduplicate while preserving order, filter to existing files
282
+ seen: set[str] = set()
283
+ paths: list[str] = []
284
+ for p in raw_paths:
285
+ p = p.strip()
286
+ if p and p not in seen and os.path.isfile(p):
287
+ seen.add(p)
288
+ paths.append(p)
289
+
290
+ for path in paths:
291
+ format_file(path)
292
+
293
+ sys.exit(0)
294
+
295
+
296
+ if __name__ == "__main__":
297
+ main()