worclaude 1.0.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 (89) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +278 -0
  3. package/package.json +62 -0
  4. package/src/commands/backup.js +55 -0
  5. package/src/commands/diff.js +76 -0
  6. package/src/commands/init.js +628 -0
  7. package/src/commands/restore.js +95 -0
  8. package/src/commands/status.js +141 -0
  9. package/src/commands/upgrade.js +208 -0
  10. package/src/core/backup.js +94 -0
  11. package/src/core/config.js +54 -0
  12. package/src/core/detector.js +43 -0
  13. package/src/core/file-categorizer.js +177 -0
  14. package/src/core/merger.js +413 -0
  15. package/src/core/scaffolder.js +60 -0
  16. package/src/data/agents.js +164 -0
  17. package/src/index.js +51 -0
  18. package/src/prompts/agent-selection.js +99 -0
  19. package/src/prompts/claude-md-merge.js +153 -0
  20. package/src/prompts/conflict-resolution.js +24 -0
  21. package/src/prompts/project-type.js +75 -0
  22. package/src/prompts/tech-stack.js +35 -0
  23. package/src/utils/display.js +41 -0
  24. package/src/utils/file.js +70 -0
  25. package/src/utils/hash.js +13 -0
  26. package/src/utils/time.js +22 -0
  27. package/templates/agents/optional/backend/api-designer.md +61 -0
  28. package/templates/agents/optional/backend/auth-auditor.md +63 -0
  29. package/templates/agents/optional/backend/database-analyst.md +61 -0
  30. package/templates/agents/optional/data/data-pipeline-reviewer.md +68 -0
  31. package/templates/agents/optional/data/ml-experiment-tracker.md +67 -0
  32. package/templates/agents/optional/data/prompt-engineer.md +75 -0
  33. package/templates/agents/optional/devops/ci-fixer.md +64 -0
  34. package/templates/agents/optional/devops/dependency-manager.md +55 -0
  35. package/templates/agents/optional/devops/deploy-validator.md +68 -0
  36. package/templates/agents/optional/devops/docker-helper.md +63 -0
  37. package/templates/agents/optional/docs/changelog-generator.md +69 -0
  38. package/templates/agents/optional/docs/doc-writer.md +60 -0
  39. package/templates/agents/optional/frontend/style-enforcer.md +47 -0
  40. package/templates/agents/optional/frontend/ui-reviewer.md +51 -0
  41. package/templates/agents/optional/quality/bug-fixer.md +54 -0
  42. package/templates/agents/optional/quality/performance-auditor.md +65 -0
  43. package/templates/agents/optional/quality/refactorer.md +61 -0
  44. package/templates/agents/optional/quality/security-reviewer.md +74 -0
  45. package/templates/agents/universal/build-validator.md +15 -0
  46. package/templates/agents/universal/code-simplifier.md +17 -0
  47. package/templates/agents/universal/plan-reviewer.md +20 -0
  48. package/templates/agents/universal/test-writer.md +17 -0
  49. package/templates/agents/universal/verify-app.md +16 -0
  50. package/templates/claude-md.md +40 -0
  51. package/templates/commands/commit-push-pr.md +9 -0
  52. package/templates/commands/compact-safe.md +8 -0
  53. package/templates/commands/end.md +9 -0
  54. package/templates/commands/review-plan.md +10 -0
  55. package/templates/commands/setup.md +112 -0
  56. package/templates/commands/start.md +3 -0
  57. package/templates/commands/status.md +6 -0
  58. package/templates/commands/techdebt.md +9 -0
  59. package/templates/commands/update-claude-md.md +9 -0
  60. package/templates/commands/verify.md +8 -0
  61. package/templates/mcp-json.json +3 -0
  62. package/templates/progress-md.md +21 -0
  63. package/templates/settings/base.json +64 -0
  64. package/templates/settings/docker.json +9 -0
  65. package/templates/settings/go.json +10 -0
  66. package/templates/settings/node.json +17 -0
  67. package/templates/settings/python.json +16 -0
  68. package/templates/settings/rust.json +11 -0
  69. package/templates/skills/templates/backend-conventions.md +57 -0
  70. package/templates/skills/templates/frontend-design-system.md +48 -0
  71. package/templates/skills/templates/project-patterns.md +48 -0
  72. package/templates/skills/universal/claude-md-maintenance.md +110 -0
  73. package/templates/skills/universal/context-management.md +71 -0
  74. package/templates/skills/universal/git-conventions.md +95 -0
  75. package/templates/skills/universal/planning-with-files.md +114 -0
  76. package/templates/skills/universal/prompt-engineering.md +97 -0
  77. package/templates/skills/universal/review-and-handoff.md +106 -0
  78. package/templates/skills/universal/subagent-usage.md +108 -0
  79. package/templates/skills/universal/testing.md +116 -0
  80. package/templates/skills/universal/verification.md +120 -0
  81. package/templates/spec-md-backend.md +85 -0
  82. package/templates/spec-md-cli.md +79 -0
  83. package/templates/spec-md-data.md +74 -0
  84. package/templates/spec-md-devops.md +87 -0
  85. package/templates/spec-md-frontend.md +81 -0
  86. package/templates/spec-md-fullstack.md +81 -0
  87. package/templates/spec-md-library.md +87 -0
  88. package/templates/spec-md.md +22 -0
  89. package/templates/workflow-meta.json +10 -0
@@ -0,0 +1,108 @@
1
+ ---
2
+ description: "When to use subagents, how many, context hygiene, worktree isolation patterns"
3
+ ---
4
+
5
+ # Subagent Usage
6
+
7
+ ## What Subagents Are
8
+
9
+ Subagents are separate Claude instances spawned from your main session. They have
10
+ their own context window, execute independently, and return results to the main
11
+ session. Your main context stays clean.
12
+
13
+ ## When Subagents Help
14
+
15
+ Tasks that benefit from subagents:
16
+ - **Testing**: writing tests for code you just implemented (test-writer agent)
17
+ - **Code review**: reviewing your own changes for quality (code-simplifier agent)
18
+ - **Research**: reading many files to answer a specific question
19
+ - **Parallel work**: running verification while you continue designing
20
+ - **Build validation**: checking that everything compiles and passes (build-validator)
21
+ - **File generation**: creating boilerplate, configs, or template files
22
+
23
+ The common thread: these tasks require context (reading files, understanding code)
24
+ but that context doesn't need to persist in your main session.
25
+
26
+ ## When NOT to Use Subagents
27
+
28
+ - Tasks requiring back-and-forth with the user (subagents can't interact with users)
29
+ - Tasks where the result needs deep integration with your current reasoning
30
+ - Very small tasks (the overhead of spawning isn't worth it)
31
+ - Tasks that depend on conversation history the subagent doesn't have
32
+
33
+ ## Context Hygiene
34
+
35
+ Your main session has limited context. Every file you read, every long output you
36
+ generate, consumes context. Subagents let you offload this:
37
+
38
+ Instead of:
39
+ 1. Read 10 test files to understand patterns (consumes context)
40
+ 2. Write new tests (uses that context)
41
+ 3. Continue main work (context is now polluted with test details)
42
+
43
+ Do:
44
+ 1. Spawn test-writer subagent with: "write tests for src/merger.js following
45
+ patterns in tests/core/"
46
+ 2. Continue main work while subagent works
47
+ 3. Subagent returns: "wrote 3 test files, all passing"
48
+ 4. Main context stays clean
49
+
50
+ ## Parallel vs Sequential Subagents
51
+
52
+ **Parallel**: when tasks are independent.
53
+ - Run test-writer and code-simplifier on different parts of the code simultaneously
54
+ - Run build-validator while continuing implementation
55
+
56
+ **Sequential**: when tasks depend on each other.
57
+ - Run code-simplifier first, then test-writer on the simplified code
58
+ - Run security-reviewer first, then fix the issues it found
59
+
60
+ Don't spawn more than 2-3 parallel subagents. Each consumes resources and
61
+ coordination overhead grows.
62
+
63
+ ## Worktree Isolation
64
+
65
+ Some agents use `git worktree` to make changes without affecting your working tree:
66
+
67
+ How it works:
68
+ 1. Agent creates a worktree from your current branch
69
+ 2. Makes changes in the worktree (isolated from your files)
70
+ 3. Commits changes
71
+ 4. You merge or cherry-pick the results
72
+
73
+ Agents with worktree isolation: code-simplifier, test-writer, verify-app, ci-fixer,
74
+ bug-fixer, refactorer, doc-writer.
75
+
76
+ Benefits:
77
+ - Agent's changes don't conflict with your uncommitted work
78
+ - You can review agent changes before merging
79
+ - If the agent breaks something, it's isolated
80
+
81
+ ## Giving Subagents Good Instructions
82
+
83
+ Subagents start with zero context. They don't know what you've been doing. Give them:
84
+
85
+ 1. **The specific task**: "Write unit tests for the merge function in src/core/merger.js"
86
+ 2. **Where to look**: "Follow patterns from tests/core/detector.test.js"
87
+ 3. **Constraints**: "Use Vitest, not Jest. Mock fs-extra, not the actual filesystem."
88
+ 4. **Success criteria**: "All tests should pass. Cover happy path, error cases,
89
+ and the three-way merge edge case."
90
+
91
+ Bad instruction: "Write some tests"
92
+ Good instruction: "Write unit tests for detectScenario() in src/core/detector.js.
93
+ Test all three scenarios: fresh (no .claude/), existing (.claude/ but no meta),
94
+ upgrade (meta exists). Mock the filesystem. Use Vitest."
95
+
96
+ ## Gotchas
97
+
98
+ - Subagents don't see your uncommitted changes unless they share the same working
99
+ directory. If you need them to see your changes, commit first or use the same
100
+ worktree.
101
+ - Subagent output is returned to your context. If a subagent generates a huge report,
102
+ that report consumes your context. Ask for concise results.
103
+ - Don't use subagents for tasks that require judgment about the overall session
104
+ direction. They lack the conversational context to make those calls.
105
+ - Worktree-based agents need a clean git state to create the worktree. Commit or
106
+ stash before spawning them.
107
+ - If a subagent fails, don't automatically retry. Understand why it failed first.
108
+ The same instructions will produce the same failure.
@@ -0,0 +1,116 @@
1
+ ---
2
+ description: "Test philosophy, coverage strategy, test-first patterns, what to test and what not to"
3
+ ---
4
+
5
+ # Testing
6
+
7
+ ## What to Test
8
+
9
+ Test behavior, not implementation. A test should verify what a function does, not
10
+ how it does it. If you refactor the internals and the test breaks, the test was
11
+ testing the wrong thing.
12
+
13
+ Good test: "given a valid email, returns true"
14
+ Bad test: "calls regex.match with pattern /^[a-z].../"
15
+
16
+ ## Meaningful Coverage vs Line Coverage
17
+
18
+ 100% line coverage is a vanity metric. You can have 100% coverage and still ship bugs
19
+ if your tests don't exercise meaningful paths.
20
+
21
+ Focus coverage on:
22
+ - Business logic (the rules that make your app unique)
23
+ - Error handling paths (what happens when things go wrong)
24
+ - Boundary conditions (empty, null, max values, off-by-one)
25
+ - Integration points (where your code meets external systems)
26
+
27
+ Skip coverage on:
28
+ - Simple getters/setters
29
+ - Framework boilerplate
30
+ - Generated code
31
+ - Pure delegation (functions that just call another function)
32
+
33
+ ## Edge Cases Worth Testing
34
+
35
+ Every function has these potential edge cases. Consider which apply:
36
+
37
+ - Null / undefined / empty string
38
+ - Empty array / empty object
39
+ - Single element
40
+ - Very large input
41
+ - Negative numbers / zero
42
+ - Unicode and special characters
43
+ - Concurrent access
44
+ - Network timeout / failure
45
+
46
+ You don't need to test ALL of these for every function. Think about which ones
47
+ are realistic for your specific case.
48
+
49
+ ## Test-First Workflow
50
+
51
+ Writing tests first helps when:
52
+ - The behavior is well-defined but the implementation isn't clear
53
+ - You're fixing a bug (write the failing test first, then fix)
54
+ - You're implementing a spec (tests become the spec's executable form)
55
+
56
+ Test-first hurts when:
57
+ - You're exploring and don't know what the API should look like
58
+ - You're prototyping and will throw the code away
59
+ - The test would be trivial (testing that a constant equals itself)
60
+
61
+ When doing test-first: write the test, watch it fail, implement the minimum to pass,
62
+ then refactor. Don't write all the tests up front — go one at a time.
63
+
64
+ ## Test Structure
65
+
66
+ Follow Arrange-Act-Assert (AAA):
67
+
68
+ ```
69
+ // Arrange: set up the test conditions
70
+ const input = createValidInput();
71
+
72
+ // Act: call the thing being tested
73
+ const result = processInput(input);
74
+
75
+ // Assert: verify the outcome
76
+ expect(result.status).toBe('success');
77
+ ```
78
+
79
+ Keep tests independent. No test should depend on another test running first.
80
+ No shared mutable state between tests.
81
+
82
+ ## Naming Tests
83
+
84
+ Test names should read like specifications:
85
+ - "should return 401 when token is expired"
86
+ - "should merge arrays without duplicates"
87
+ - "should create backup directory if it doesn't exist"
88
+
89
+ Not:
90
+ - "test1"
91
+ - "it works"
92
+ - "handles edge case"
93
+
94
+ ## Testing Anti-Patterns
95
+
96
+ - **Snapshot abuse**: snapshots test that output didn't change, not that it's correct.
97
+ Use sparingly and review snapshot diffs carefully.
98
+ - **Mock everything**: if your test mocks 5 dependencies, you're testing the mocking
99
+ framework, not your code. Prefer integration tests for heavily-connected code.
100
+ - **Test the framework**: don't test that Express routes requests or that React renders
101
+ components. Trust the framework; test YOUR logic.
102
+ - **Brittle assertions**: asserting on exact error messages or full object shapes when
103
+ only one field matters. Assert on what matters.
104
+ - **Slow tests without reason**: if a test takes seconds, it's probably doing I/O
105
+ that should be mocked or it's an integration test that should be tagged separately.
106
+
107
+ ## Gotchas
108
+
109
+ - Flaky tests are worse than no tests. They erode trust in the entire suite.
110
+ Fix immediately or quarantine with a clear TODO.
111
+ - Test data should be self-contained. Don't rely on database state, external
112
+ services, or file system artifacts from other tests.
113
+ - When a test fails, the test might be wrong. Don't assume the code is broken —
114
+ read the test carefully first.
115
+ - Delete tests that test deleted features. Orphan tests confuse and mislead.
116
+ - Async tests need proper awaiting. An unawaited assertion silently passes.
@@ -0,0 +1,120 @@
1
+ ---
2
+ description: "Domain-specific verification beyond tests, closing the feedback loop for web, API, CLI, data"
3
+ ---
4
+
5
+ # Verification
6
+
7
+ ## Beyond Unit Tests
8
+
9
+ Unit tests verify code logic. Verification confirms the feature actually works in
10
+ its real environment. Both are necessary. Neither alone is sufficient.
11
+
12
+ The /verify command runs automated checks, but domain-specific verification often
13
+ requires manual steps or specialized tooling.
14
+
15
+ ## Closing the Feedback Loop
16
+
17
+ Every change needs a feedback loop: make a change, verify it worked, then move on.
18
+ The loop must be closed BEFORE committing.
19
+
20
+ Bad workflow: change code -> commit -> move to next task -> discover it's broken
21
+ Good workflow: change code -> verify -> commit -> move to next task
22
+
23
+ ## Web Application Verification
24
+
25
+ After changing UI or API behavior:
26
+
27
+ 1. Start the dev server
28
+ 2. Navigate to the affected page/endpoint
29
+ 3. Test the happy path manually
30
+ 4. Test at least one error path
31
+ 5. Check browser console for errors/warnings
32
+ 6. Verify responsive behavior if UI changed
33
+
34
+ For API changes:
35
+ ```bash
36
+ # Test the endpoint directly
37
+ curl -X POST http://localhost:3000/api/resource \
38
+ -H "Content-Type: application/json" \
39
+ -d '{"field": "value"}'
40
+
41
+ # Check response status and body
42
+ ```
43
+
44
+ ## API Verification
45
+
46
+ Test beyond the happy path:
47
+ - Valid request with all fields
48
+ - Valid request with minimum fields
49
+ - Invalid request (missing required field)
50
+ - Invalid request (wrong types)
51
+ - Authentication failures
52
+ - Rate limiting behavior
53
+ - Concurrent request handling (if relevant)
54
+
55
+ Use curl, httpie, or the project's API test suite. Automate what you can, but
56
+ do at least one manual check of the actual running server.
57
+
58
+ ## CLI Verification
59
+
60
+ After changing CLI behavior:
61
+
62
+ 1. Run the command with typical arguments
63
+ 2. Run with edge case arguments (empty, very long, special characters)
64
+ 3. Run with invalid arguments (verify error messages are helpful)
65
+ 4. Test piping and redirection if applicable
66
+ 5. Verify exit codes
67
+
68
+ ```bash
69
+ # Test normal usage
70
+ my-cli init --name "test project"
71
+
72
+ # Test error handling
73
+ my-cli init # missing required flag
74
+
75
+ # Test edge cases
76
+ my-cli init --name "" # empty string
77
+ ```
78
+
79
+ ## Data Pipeline Verification
80
+
81
+ After changing data transformations:
82
+
83
+ 1. Run with sample input data
84
+ 2. Verify output schema matches expectations
85
+ 3. Check row counts (input vs output)
86
+ 4. Spot-check specific records for correctness
87
+ 5. Test with empty input
88
+ 6. Test with malformed input
89
+
90
+ ## Build Verification
91
+
92
+ The full verification suite (triggered by /verify):
93
+
94
+ 1. `npm test` / `pytest` / `cargo test` — unit and integration tests
95
+ 2. `npm run build` / equivalent — compilation and bundling
96
+ 3. `npm run lint` / equivalent — style and static analysis
97
+ 4. Type checking if applicable (`tsc --noEmit`, `mypy`, etc.)
98
+ 5. Domain-specific checks from above
99
+
100
+ All five must pass. If any fails, stop and fix before continuing.
101
+
102
+ ## When Verification Reveals Problems
103
+
104
+ If verification fails:
105
+ 1. Don't panic. Read the error carefully.
106
+ 2. Check if it's a pre-existing issue or something you introduced.
107
+ 3. If you introduced it, fix it before committing.
108
+ 4. If it's pre-existing, document it and decide whether to fix now or file it.
109
+
110
+ ## Gotchas
111
+
112
+ - "Tests pass" is not the same as "it works." A test suite can have 100% coverage
113
+ and still miss real-world failures. Always do at least one real verification.
114
+ - Don't skip verification because "it's a small change." Small changes cause
115
+ production outages too.
116
+ - Browser console errors are free bug reports. Check them.
117
+ - If verification is painful, invest in making it easier. A script that starts
118
+ the server, runs checks, and reports results saves cumulative hours.
119
+ - Flaky tests must be fixed or quarantined. A test suite that sometimes fails
120
+ trains people to ignore failures.
@@ -0,0 +1,85 @@
1
+ # SPEC.md — {project_name}
2
+
3
+ ## Product Overview
4
+ {description}
5
+
6
+ ## Tech Stack
7
+ | Layer | Technology |
8
+ |-------------|-----------------------------------|
9
+ | Language | {tech_stack_table} |{docker_row}
10
+ | Framework | [e.g. Express, FastAPI, Gin] |
11
+ | Database | [e.g. PostgreSQL, MongoDB, Redis] |
12
+ | Auth | [e.g. JWT, API keys, OAuth2] |
13
+ | Hosting | [e.g. AWS, Railway, Fly.io] |
14
+ | CI/CD | [e.g. GitHub Actions] |
15
+
16
+ ## API Endpoints
17
+ | Method | Path | Purpose | Auth Required |
18
+ |--------|-----------------------|----------------------------------|---------------|
19
+ | POST | `/api/auth/login` | [Authenticate and return token] | No |
20
+ | POST | `/api/auth/register` | [Create new user account] | No |
21
+ | GET | `/api/[resource]` | [List with pagination/filtering] | [Yes/No] |
22
+ | GET | `/api/[resource]/:id` | [Get single resource by ID] | [Yes/No] |
23
+ | POST | `/api/[resource]` | [Create new resource] | [Yes/No] |
24
+ | PUT | `/api/[resource]/:id` | [Full update of resource] | [Yes/No] |
25
+ | PATCH | `/api/[resource]/:id` | [Partial update of resource] | [Yes/No] |
26
+ | DELETE | `/api/[resource]/:id` | [Soft/hard delete resource] | [Yes/No] |
27
+
28
+ ## Data Model
29
+ ### [PrimaryEntity]
30
+ | Field | Type | Constraints |
31
+ |-------------|-----------|----------------------------------|
32
+ | id | UUID | Primary key, auto-generated |
33
+ | [field] | [type] | [required, unique, indexed, etc] |
34
+ | created_at | Timestamp | Auto-set on creation |
35
+ | updated_at | Timestamp | Auto-set on update |
36
+
37
+ ### [SecondaryEntity]
38
+ | Field | Type | Constraints |
39
+ |-------------|-----------|----------------------------------|
40
+ | id | UUID | Primary key, auto-generated |
41
+ | [field] | [type] | [constraints] |
42
+ | [foreign] | UUID | FK -> [PrimaryEntity].id |
43
+
44
+ ## Authentication & Authorization
45
+ - **Strategy:** [JWT bearer tokens / API key header / OAuth2]
46
+ - **Roles:** [e.g. admin, user, service — describe permissions per role]
47
+ - **Token lifetime:** [e.g. 15m access, 7d refresh]
48
+ - **Rate limiting:** [e.g. 100 req/min per API key]
49
+
50
+ ## Error Handling
51
+ Response format: `{ "error": { "code": "MACHINE_CODE", "message": "...", "details": "..." } }`
52
+
53
+ | HTTP Status | When Used |
54
+ |-------------|------------------------------------------|
55
+ | 400 | Validation failure, malformed request |
56
+ | 401 | Missing or invalid authentication |
57
+ | 403 | Authenticated but not authorized |
58
+ | 404 | Resource not found |
59
+ | 409 | Conflict (duplicate, stale update) |
60
+ | 422 | Business logic violation |
61
+ | 429 | Rate limit exceeded |
62
+ | 500 | Unhandled server error |
63
+
64
+ ## Implementation Phases
65
+
66
+ ### Phase 1 — Foundation
67
+ - [ ] Project scaffolding and dependency setup
68
+ - [ ] Database connection and schema migrations
69
+ - [ ] Basic CRUD for [primary resource]
70
+ - [ ] Authentication (signup, login, token refresh)
71
+ - [ ] Request validation middleware
72
+
73
+ ### Phase 2 — Core Features
74
+ - [ ] Remaining resource endpoints
75
+ - [ ] Business logic and domain rules
76
+ - [ ] Pagination, filtering, and sorting
77
+ - [ ] Authorization and role checks
78
+ - [ ] Background jobs [if applicable]
79
+
80
+ ### Phase 3 — Polish
81
+ - [ ] Rate limiting, input sanitization, security hardening
82
+ - [ ] OpenAPI / Swagger documentation
83
+ - [ ] Logging, health-check endpoint, comprehensive error handling
84
+ - [ ] Integration and load tests
85
+ - [ ] Deployment pipeline and monitoring
@@ -0,0 +1,79 @@
1
+ # SPEC.md — {project_name}
2
+
3
+ ## Product Overview
4
+ {description}
5
+
6
+ ## Tech Stack
7
+ | Layer | Technology |
8
+ |--------------|-----------------------------------|
9
+ | Language | {tech_stack_table} |{docker_row}
10
+ | CLI Framework| [e.g. Commander.js, Click, Cobra] |
11
+ | Output | [e.g. Chalk, Rich, colored] |
12
+ | Testing | [e.g. Vitest, pytest] |
13
+ | Distribution | [e.g. npm, PyPI, Homebrew] |
14
+
15
+ ## Commands
16
+ | Command | Description | Flags / Options |
17
+ |---------------------------|--------------------------------------|--------------------------------|
18
+ | `{project_name} init` | [Initialize configuration/project] | `--template <name>`, `--force` |
19
+ | `{project_name} [verb]` | [Primary action of the tool] | `--flag`, `-f <value>` |
20
+ | `{project_name} [verb]` | [Secondary action] | `--verbose`, `--json` |
21
+ | `{project_name} config` | [View/edit configuration] | `--set <key=value>`, `--list` |
22
+ | `{project_name} --help` | Show help text | — |
23
+ | `{project_name} --version`| Print version | — |
24
+ | [add commands...] | [description] | [flags] |
25
+
26
+ ## Configuration
27
+ **Config file:** `~/.{project_name}rc` or `.{project_name}.json` in project root
28
+
29
+ **Precedence (highest to lowest):** CLI flags > env vars (`{PROJECT_NAME}_[KEY]`) > project config > user config > defaults
30
+
31
+ | Variable | Purpose | Default |
32
+ |------------------------------|----------------------------------|-------------|
33
+ | `{PROJECT_NAME}_CONFIG` | [Path to config file] | [~/.rc] |
34
+ | `{PROJECT_NAME}_[OPTION]` | [Override for specific option] | [default] |
35
+
36
+ ## Input / Output Formats
37
+ - **stdin:** [Does the tool read from stdin? Pipe support?]
38
+ - **stdout:** [Human-readable by default, machine-readable with `--json`]
39
+ - **stderr:** [Error messages, progress info, warnings]
40
+ - **File I/O:** [Does it read/write files? Which formats?]
41
+
42
+ Example output:
43
+ ```
44
+ [Show a realistic example of the tool's primary output]
45
+ ```
46
+
47
+ ## Error Handling
48
+ | Exit Code | Meaning |
49
+ |-----------|--------------------------------------|
50
+ | 0 | Success |
51
+ | 1 | General error |
52
+ | 2 | Invalid usage / bad arguments |
53
+ | 3 | Configuration error |
54
+ | [code] | [specific error condition] |
55
+
56
+ - **Error format:** `Error: [message]` to stderr, non-zero exit code
57
+ - **Verbose mode:** `--verbose` or `-v` for debug output
58
+ - **Graceful shutdown:** Handle SIGINT/SIGTERM for cleanup
59
+
60
+ ## Implementation Phases
61
+
62
+ ### Phase 1 — Foundation
63
+ - [ ] Project scaffolding and CLI argument parsing
64
+ - [ ] Config file loading and validation
65
+ - [ ] Help text and version flag
66
+ - [ ] Basic `init` command
67
+ - [ ] Error handling framework
68
+
69
+ ### Phase 2 — Core Commands
70
+ - [ ] Primary command ([verb]) with full functionality
71
+ - [ ] Secondary commands
72
+ - [ ] stdin/stdout pipe support
73
+ - [ ] `--json` output mode
74
+
75
+ ### Phase 3 — Polish
76
+ - [ ] Interactive prompts, progress indicators, `--no-color` support
77
+ - [ ] Shell completions (bash, zsh, fish)
78
+ - [ ] Tests for all commands and edge cases
79
+ - [ ] Package and publish
@@ -0,0 +1,74 @@
1
+ # SPEC.md — {project_name}
2
+
3
+ ## Product Overview
4
+ {description}
5
+
6
+ ## Tech Stack
7
+ | Layer | Technology |
8
+ |----------------|-----------------------------------|
9
+ | Language | {tech_stack_table} |{docker_row}
10
+ | ML Framework | [e.g. PyTorch, scikit-learn, TF] |
11
+ | Data Storage | [e.g. S3, BigQuery, PostgreSQL] |
12
+ | Orchestration | [e.g. Airflow, Prefect, Dagster] |
13
+ | Experiment Tracking | [e.g. MLflow, W&B, DVC] |
14
+ | Serving | [e.g. FastAPI, BentoML, SageMaker]|
15
+
16
+ ## Data Sources
17
+ | Source | Format | Frequency | Volume | Notes |
18
+ |-------------------|-----------|---------------|----------------|----------------------|
19
+ | [Database/API] | [CSV/JSON]| [Daily/Real-time] | [~N rows/GB] | [Access method] |
20
+ | [File system] | [Parquet] | [One-time] | [~N GB] | [Schema notes] |
21
+ | [External API] | [JSON] | [Hourly] | [~N records] | [Rate limits, auth] |
22
+ | [add sources...] | [format] | [frequency] | [volume] | [notes] |
23
+
24
+ ## Pipeline Architecture
25
+ ```
26
+ [Data Source] -> [Ingestion] -> [Raw Storage] -> [Validation & Cleaning]
27
+ -> [Feature Engineering] -> [Training] / [Analytics]
28
+ -> [Model Registry] -> [Serving / Inference]
29
+ ```
30
+ [Describe each stage: tools used, data transformations, scheduling, failure handling]
31
+
32
+ ## Model Architecture
33
+ [Skip this section if not an ML project]
34
+ - **Task type:** [Classification / Regression / Generation / etc.]
35
+ - **Input features:** [List key features and their types]
36
+ - **Output:** [Prediction format, e.g. class label, score, text]
37
+ - **Baseline model:** [Simple approach to benchmark against]
38
+ - **Target model:** [Architecture description — layers, parameters]
39
+ - **Training data split:** [e.g. 80/10/10 train/val/test]
40
+ - **Hyperparameters:** [Key tunable values and search strategy]
41
+
42
+ ## Evaluation Metrics
43
+ | Metric | Target | Baseline | Purpose |
44
+ |--------------|----------|----------|----------------------------------|
45
+ | [Accuracy] | [>0.95] | [0.82] | [Primary performance measure] |
46
+ | [Latency] | [<100ms] | [—] | [Inference speed requirement] |
47
+ | [F1 Score] | [>0.90] | [0.75] | [Balance precision and recall] |
48
+ | [add more...] | [target]| [current]| [why this metric matters] |
49
+
50
+ - **Monitoring:** [How model drift and data quality are tracked in production]
51
+ - **Retraining trigger:** [Schedule-based, drift-based, or manual]
52
+
53
+ ## Implementation Phases
54
+
55
+ ### Phase 1 — Data Foundation
56
+ - [ ] Data source connectors and ingestion scripts
57
+ - [ ] Raw data storage and schema validation
58
+ - [ ] Exploratory data analysis notebook
59
+ - [ ] Data cleaning and preprocessing pipeline
60
+ - [ ] Pipeline orchestration setup
61
+
62
+ ### Phase 2 — Feature Engineering & Modeling
63
+ - [ ] Feature engineering pipeline
64
+ - [ ] Baseline model training and evaluation
65
+ - [ ] Target model experimentation
66
+ - [ ] Hyperparameter tuning
67
+ - [ ] Experiment tracking integration
68
+
69
+ ### Phase 3 — Productionization
70
+ - [ ] Model serialization and registry
71
+ - [ ] Serving API or batch inference pipeline
72
+ - [ ] Monitoring and alerting (data drift, model performance)
73
+ - [ ] Automated retraining pipeline
74
+ - [ ] Documentation and reproducibility checks
@@ -0,0 +1,87 @@
1
+ # SPEC.md — {project_name}
2
+
3
+ ## Product Overview
4
+ {description}
5
+
6
+ ## Infrastructure Stack
7
+ | Layer | Technology |
8
+ |------------------|-----------------------------------|
9
+ | Language | {tech_stack_table} |{docker_row}
10
+ | IaC | [e.g. Terraform, Pulumi, CDK] |
11
+ | Container Runtime| [e.g. Docker, Podman] |
12
+ | Orchestration | [e.g. Kubernetes, ECS, Nomad] |
13
+ | CI/CD | [e.g. GitHub Actions, GitLab CI] |
14
+ | Registry | [e.g. ECR, GHCR, Docker Hub] |
15
+ | DNS / CDN | [e.g. Cloudflare, Route53+CF] |
16
+ | Secrets | [e.g. Vault, AWS SSM, SOPS] |
17
+
18
+ ## Environments
19
+ | Name | URL / Endpoint | Purpose | Access |
20
+ |-------------|-----------------------------|----------------------------|---------------------|
21
+ | Development | [dev.example.com] | [Feature testing] | [Team-wide] |
22
+ | Staging | [staging.example.com] | [Pre-prod validation] | [Team + QA] |
23
+ | Production | [example.com] | [Live user traffic] | [Restricted] |
24
+ | [add env...] | [url] | [purpose] | [who has access] |
25
+
26
+ **Promotion flow:** Development -> Staging -> Production
27
+ [Describe how code and config move between environments — automated, manual gate, etc.]
28
+
29
+ ## CI/CD Pipeline
30
+ ```
31
+ [push] -> Lint -> Test -> Build -> [merge to main] -> Deploy Staging -> Smoke Tests
32
+ [tag pushed] -> Deploy Production -> Smoke Tests -> Post-deploy checks
33
+ ```
34
+ | Stage | Trigger | Actions |
35
+ |--------------------|------------------|--------------------------------------|
36
+ | Lint & Test | Every push | [Linter, type check, unit tests] |
37
+ | Build | PR to main | [Docker build, artifact creation] |
38
+ | Deploy Staging | Merge to main | [Auto-deploy, run migrations] |
39
+ | Deploy Production | Git tag / manual | [Blue-green or rolling deploy] |
40
+ | Rollback | Manual | [Revert to previous version] |
41
+
42
+ ## Monitoring & Alerting
43
+ | Signal | Tool | Alert Threshold |
44
+ |-----------------|-------------------------|-------------------------------|
45
+ | Uptime | [e.g. UptimeRobot] | [< 99.9% over 5m window] |
46
+ | Error rate | [e.g. Sentry, Datadog] | [> 1% of requests] |
47
+ | Latency (p99) | [e.g. Prometheus+Grafana]| [> 500ms] |
48
+ | CPU / Memory | [e.g. CloudWatch] | [> 80% sustained 5m] |
49
+ | Disk usage | [e.g. node-exporter] | [> 85%] |
50
+ | [custom metric] | [tool] | [threshold] |
51
+
52
+ - **On-call rotation:** [Describe who gets paged and escalation path]
53
+ - **Dashboards:** [List key dashboards and what they show]
54
+ - **Log aggregation:** [e.g. ELK, Loki, CloudWatch Logs — retention policy]
55
+
56
+ ## Security & Compliance
57
+ - **Network:** [VPC layout, public/private subnets, security groups]
58
+ - **Secrets management:** [How secrets are stored, rotated, and accessed]
59
+ - **TLS:** [Certificate provisioning — Let's Encrypt, ACM, etc.]
60
+ - **Access control:** [IAM roles, RBAC, least-privilege approach]
61
+ - **Scanning:** [Container image scanning, dependency audit, SAST]
62
+ - **Backup & DR:** [Backup schedule, RTO/RPO targets, disaster recovery plan]
63
+ - **Compliance:** [SOC2, GDPR, HIPAA — list applicable standards]
64
+
65
+ ## Implementation Phases
66
+
67
+ ### Phase 1 — Foundation
68
+ - [ ] IaC repository setup and state backend
69
+ - [ ] Networking (VPC, subnets, security groups)
70
+ - [ ] Container registry and base image
71
+ - [ ] CI pipeline (lint, test, build)
72
+ - [ ] Development environment provisioning
73
+
74
+ ### Phase 2 — Deployment Pipeline
75
+ - [ ] Staging environment provisioning
76
+ - [ ] Automated deployment to staging
77
+ - [ ] Database provisioning and migration strategy
78
+ - [ ] Secrets management integration
79
+ - [ ] Production environment provisioning
80
+
81
+ ### Phase 3 — Observability & Hardening
82
+ - [ ] Monitoring stack deployment
83
+ - [ ] Alerting rules and on-call setup
84
+ - [ ] Log aggregation and retention
85
+ - [ ] Security scanning in CI
86
+ - [ ] Backup automation and DR drill
87
+ - [ ] Runbook documentation for incident response