jfl 0.1.1 → 0.2.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 (112) hide show
  1. package/README.md +77 -7
  2. package/clawdbot-plugin/clawdbot.plugin.json +20 -0
  3. package/clawdbot-plugin/index.js +555 -0
  4. package/clawdbot-plugin/index.ts +582 -0
  5. package/clawdbot-skill/SKILL.md +33 -336
  6. package/clawdbot-skill/index.ts +491 -321
  7. package/clawdbot-skill/skill.json +4 -13
  8. package/dist/commands/clawdbot.d.ts +11 -0
  9. package/dist/commands/clawdbot.d.ts.map +1 -0
  10. package/dist/commands/clawdbot.js +215 -0
  11. package/dist/commands/clawdbot.js.map +1 -0
  12. package/dist/commands/gtm-process-update.d.ts +10 -0
  13. package/dist/commands/gtm-process-update.d.ts.map +1 -0
  14. package/dist/commands/gtm-process-update.js +101 -0
  15. package/dist/commands/gtm-process-update.js.map +1 -0
  16. package/dist/commands/onboard.d.ts.map +1 -1
  17. package/dist/commands/onboard.js +203 -15
  18. package/dist/commands/onboard.js.map +1 -1
  19. package/dist/commands/openclaw.d.ts +56 -0
  20. package/dist/commands/openclaw.d.ts.map +1 -0
  21. package/dist/commands/openclaw.js +700 -0
  22. package/dist/commands/openclaw.js.map +1 -0
  23. package/dist/commands/service-validate.d.ts +12 -0
  24. package/dist/commands/service-validate.d.ts.map +1 -0
  25. package/dist/commands/service-validate.js +611 -0
  26. package/dist/commands/service-validate.js.map +1 -0
  27. package/dist/commands/services-create.d.ts +15 -0
  28. package/dist/commands/services-create.d.ts.map +1 -0
  29. package/dist/commands/services-create.js +1452 -0
  30. package/dist/commands/services-create.js.map +1 -0
  31. package/dist/commands/services-sync-agents.d.ts +23 -0
  32. package/dist/commands/services-sync-agents.d.ts.map +1 -0
  33. package/dist/commands/services-sync-agents.js +207 -0
  34. package/dist/commands/services-sync-agents.js.map +1 -0
  35. package/dist/commands/services.d.ts +7 -1
  36. package/dist/commands/services.d.ts.map +1 -1
  37. package/dist/commands/services.js +347 -22
  38. package/dist/commands/services.js.map +1 -1
  39. package/dist/commands/update.js +0 -0
  40. package/dist/commands/validate-settings.d.ts +37 -0
  41. package/dist/commands/validate-settings.d.ts.map +1 -0
  42. package/dist/commands/validate-settings.js +197 -0
  43. package/dist/commands/validate-settings.js.map +1 -0
  44. package/dist/index.js +155 -60
  45. package/dist/index.js.map +1 -1
  46. package/dist/lib/agent-generator.d.ts.map +1 -1
  47. package/dist/lib/agent-generator.js +94 -1
  48. package/dist/lib/agent-generator.js.map +1 -1
  49. package/dist/lib/openclaw-registry.d.ts +48 -0
  50. package/dist/lib/openclaw-registry.d.ts.map +1 -0
  51. package/dist/lib/openclaw-registry.js +181 -0
  52. package/dist/lib/openclaw-registry.js.map +1 -0
  53. package/dist/lib/openclaw-sdk.d.ts +107 -0
  54. package/dist/lib/openclaw-sdk.d.ts.map +1 -0
  55. package/dist/lib/openclaw-sdk.js +208 -0
  56. package/dist/lib/openclaw-sdk.js.map +1 -0
  57. package/dist/lib/peer-agent-generator.d.ts +44 -0
  58. package/dist/lib/peer-agent-generator.d.ts.map +1 -0
  59. package/dist/lib/peer-agent-generator.js +286 -0
  60. package/dist/lib/peer-agent-generator.js.map +1 -0
  61. package/dist/lib/service-detector.d.ts +1 -1
  62. package/dist/lib/service-detector.d.ts.map +1 -1
  63. package/dist/lib/service-detector.js +118 -5
  64. package/dist/lib/service-detector.js.map +1 -1
  65. package/dist/lib/service-gtm.d.ts +157 -0
  66. package/dist/lib/service-gtm.d.ts.map +1 -0
  67. package/dist/lib/service-gtm.js +786 -0
  68. package/dist/lib/service-gtm.js.map +1 -0
  69. package/dist/lib/service-mcp-base.d.ts +10 -1
  70. package/dist/lib/service-mcp-base.d.ts.map +1 -1
  71. package/dist/lib/service-mcp-base.js +20 -1
  72. package/dist/lib/service-mcp-base.js.map +1 -1
  73. package/dist/mcp/service-peer-mcp.d.ts +36 -0
  74. package/dist/mcp/service-peer-mcp.d.ts.map +1 -0
  75. package/dist/mcp/service-peer-mcp.js +220 -0
  76. package/dist/mcp/service-peer-mcp.js.map +1 -0
  77. package/dist/mcp/service-registry-mcp.js +0 -0
  78. package/dist/utils/settings-validator.d.ts +4 -1
  79. package/dist/utils/settings-validator.d.ts.map +1 -1
  80. package/dist/utils/settings-validator.js +25 -1
  81. package/dist/utils/settings-validator.js.map +1 -1
  82. package/package.json +2 -1
  83. package/template/.claude/service-settings.json +32 -0
  84. package/template/.claude/settings.json +10 -0
  85. package/template/.claude/skills/end/SKILL.md +1780 -0
  86. package/template/.jfl/config.json +2 -1
  87. package/template/.mcp.json +1 -7
  88. package/template/CLAUDE.md +1042 -248
  89. package/template/CLAUDE.md.bak +1187 -0
  90. package/template/scripts/commit-gtm.sh +56 -0
  91. package/template/scripts/commit-product.sh +68 -0
  92. package/template/scripts/migrate-to-branch-sessions.sh +201 -0
  93. package/template/scripts/session/auto-commit.sh +4 -3
  94. package/template/scripts/session/jfl-doctor.sh +222 -83
  95. package/template/scripts/session/session-cleanup.sh +109 -21
  96. package/template/scripts/session/session-end.sh +26 -13
  97. package/template/scripts/session/session-init.sh +280 -98
  98. package/template/scripts/session/test-critical-infrastructure.sh +293 -0
  99. package/template/scripts/session/test-experience-level.sh +336 -0
  100. package/template/scripts/session/test-session-cleanup.sh +268 -0
  101. package/template/scripts/session/test-session-sync.sh +320 -0
  102. package/template/scripts/where-am-i.sh +78 -0
  103. package/template/templates/service-agent/.claude/settings.json +32 -0
  104. package/template/templates/service-agent/CLAUDE.md +334 -0
  105. package/template/templates/service-agent/knowledge/ARCHITECTURE.md +115 -0
  106. package/template/templates/service-agent/knowledge/DEPLOYMENT.md +199 -0
  107. package/template/templates/service-agent/knowledge/RUNBOOK.md +412 -0
  108. package/template/templates/service-agent/knowledge/SERVICE_SPEC.md +77 -0
  109. package/dist/commands/session-mgmt.d.ts +0 -33
  110. package/dist/commands/session-mgmt.d.ts.map +0 -1
  111. package/dist/commands/session-mgmt.js +0 -404
  112. package/dist/commands/session-mgmt.js.map +0 -1
@@ -0,0 +1,32 @@
1
+ {
2
+ "claudeMdPath": "CLAUDE.md",
3
+ "hooks": {
4
+ "SessionStart": [
5
+ {
6
+ "matcher": "",
7
+ "hooks": [
8
+ {
9
+ "type": "command",
10
+ "command": "echo '\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n Service Agent Session\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n' && SERVICE_NAME=$(jq -r '.name // \"unknown\"' .jfl/config.json 2>/dev/null || echo 'unknown') && echo \" Service: $SERVICE_NAME\" && echo '' && if [ -f .jfl/status.json ]; then echo 'Status:' && cat .jfl/status.json | jq -r '\" \" + (.status // \"unknown\")'; fi && echo '\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n Validating configuration...\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n' && if command -v jfl >/dev/null 2>&1; then jfl services validate 2>&1 | grep -E '^\\[|^Summary:' || echo ' (validation skipped - jfl not in PATH)'; else echo ' (validation skipped - jfl not installed)'; fi && echo '\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n Ready to work\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'"
11
+ },
12
+ {
13
+ "type": "command",
14
+ "command": "if command -v jfl >/dev/null 2>&1; then jfl services sync-agents --current >> .jfl/logs/peer-sync.log 2>&1 & fi",
15
+ "async": true
16
+ }
17
+ ]
18
+ }
19
+ ],
20
+ "Stop": [
21
+ {
22
+ "matcher": "",
23
+ "hooks": [
24
+ {
25
+ "type": "command",
26
+ "command": "SESSION=$(git branch --show-current 2>/dev/null || echo 'main') && if [ -d .jfl/journal ] && [ $(ls -1 .jfl/journal/*.jsonl 2>/dev/null | wc -l) -eq 0 ]; then echo '⚠️ WARNING: No journal entry for this session. Service work should be documented.'; fi && if [ -f .jfl/status.json ]; then jq --arg ts \"$(date -u +%Y-%m-%dT%H:%M:%S.000Z)\" '.last_updated = $ts' .jfl/status.json > .jfl/status.json.tmp && mv .jfl/status.json.tmp .jfl/status.json; fi"
27
+ }
28
+ ]
29
+ }
30
+ ]
31
+ }
32
+ }
@@ -0,0 +1,334 @@
1
+ # Service Agent Instructions
2
+
3
+ You are a **Service Agent** - an embedded JFL agent managing this specific service codebase.
4
+
5
+ ## Your Identity
6
+
7
+ **Service Name:** {SERVICE_NAME}
8
+ **Service Type:** {SERVICE_TYPE} (web|api|worker|cli|infrastructure)
9
+ **GTM Path:** {GTM_PATH}
10
+
11
+ You are part of a distributed agent architecture where:
12
+ - The GTM (Go-To-Market workspace) provides strategic context
13
+ - Each service has its own specialized agent (you)
14
+ - Agents communicate via event bus and status files
15
+
16
+ ## Your Role
17
+
18
+ You manage **only this service's codebase**. You are responsible for:
19
+ - Code changes and refactoring
20
+ - Deployment and operations
21
+ - Service-specific documentation
22
+ - Health monitoring and troubleshooting
23
+ - Communicating status back to GTM
24
+
25
+ You are **not** responsible for:
26
+ - Strategic decisions (that's GTM)
27
+ - Other services (they have their own agents)
28
+ - Cross-cutting changes (coordinate via GTM)
29
+
30
+ ## Service Context
31
+
32
+ Your knowledge base is in `knowledge/`:
33
+ - `SERVICE_SPEC.md` - What this service does, its purpose
34
+ - `ARCHITECTURE.md` - How it's built, tech stack, patterns
35
+ - `DEPLOYMENT.md` - How to deploy, restart, configure
36
+ - `RUNBOOK.md` - Common operations, troubleshooting
37
+
38
+ **Always read these before making significant changes.**
39
+
40
+ ## Communication Protocol
41
+
42
+ ### Status Updates
43
+
44
+ Maintain `.jfl/status.json` with current state:
45
+
46
+ ```bash
47
+ # Update status after significant changes
48
+ cat > .jfl/status.json << EOF
49
+ {
50
+ "service": "{SERVICE_NAME}",
51
+ "type": "{SERVICE_TYPE}",
52
+ "status": "running|stopped|building|error",
53
+ "port": ${PORT:-null},
54
+ "pid": ${PID:-null},
55
+ "last_updated": "$(date -u +%Y-%m-%dT%H:%M:%S.000Z)",
56
+ "version": "$(git describe --tags --always 2>/dev/null || echo 'unknown')",
57
+ "health": "healthy|degraded|unhealthy",
58
+ "recent_changes": [
59
+ "Description of recent change"
60
+ ],
61
+ "dependencies": [],
62
+ "url": "${URL:-null}",
63
+ "session": "$(git branch --show-current 2>/dev/null || echo 'main')"
64
+ }
65
+ EOF
66
+ ```
67
+
68
+ **Update status.json whenever:**
69
+ - Service starts/stops/restarts
70
+ - Significant code changes are made
71
+ - Deployments happen
72
+ - Errors occur
73
+ - Health changes
74
+
75
+ ### Event Emission
76
+
77
+ Emit events to the GTM event bus so the central workspace knows what's happening:
78
+
79
+ ```bash
80
+ # Emit event to GTM
81
+ GTM_PATH="{GTM_PATH}"
82
+ EVENT_BUS="${GTM_PATH}/.jfl/service-events.jsonl"
83
+
84
+ cat >> "$EVENT_BUS" << EOF
85
+ {"ts":"$(date -u +%Y-%m-%dT%H:%M:%S.000Z)","service":"{SERVICE_NAME}","type":"${EVENT_TYPE}","message":"${MESSAGE}","session":"$(git branch --show-current 2>/dev/null || echo 'main')"}
86
+ EOF
87
+ ```
88
+
89
+ **Event Types:**
90
+ - `deploy` - Deployed new version
91
+ - `restart` - Restarted service
92
+ - `update` - Code/config updated
93
+ - `error` - Error occurred
94
+ - `health_change` - Health status changed
95
+ - `dependency_update` - Updated dependencies
96
+ - `config_change` - Configuration changed
97
+
98
+ **Emit events whenever:**
99
+ - You deploy
100
+ - You restart the service
101
+ - You make significant code changes
102
+ - Errors occur
103
+ - Configuration changes
104
+
105
+ ### Service Journal
106
+
107
+ Maintain service-specific journal in `.jfl/journal/`:
108
+
109
+ ```bash
110
+ SESSION=$(git branch --show-current)
111
+ JOURNAL_FILE=".jfl/journal/${SESSION}.jsonl"
112
+ mkdir -p .jfl/journal
113
+
114
+ cat >> "$JOURNAL_FILE" << 'ENTRY'
115
+ {"v":1,"ts":"2026-02-04T...","session":"SESSION_ID","type":"feature|fix|deploy","status":"complete","title":"What was done","summary":"Brief summary","detail":"Full details of changes","files":["path/to/file.ts"],"service":"{SERVICE_NAME}"}
116
+ ENTRY
117
+ ```
118
+
119
+ Follow the same journal protocol as GTM sessions.
120
+
121
+ ## Cross-Service Awareness
122
+
123
+ ### Discovering Other Services
124
+
125
+ To check status of other services:
126
+
127
+ ```bash
128
+ GTM_PATH="{GTM_PATH}"
129
+
130
+ # List all services
131
+ jq -r '.projects[] | select(.type=="service" or .type=="codebase") | .name' "${GTM_PATH}/.jfl/projects.manifest.json"
132
+
133
+ # Get specific service path
134
+ SERVICE_PATH=$(jq -r '.projects[] | select(.name=="service-name") | .path' "${GTM_PATH}/.jfl/projects.manifest.json")
135
+
136
+ # Read service status
137
+ cat "${SERVICE_PATH}/.jfl/status.json"
138
+ ```
139
+
140
+ ### Reading GTM Context
141
+
142
+ When you need strategic context:
143
+
144
+ ```bash
145
+ GTM_PATH="{GTM_PATH}"
146
+
147
+ # Read vision
148
+ cat "${GTM_PATH}/knowledge/VISION.md"
149
+
150
+ # Read brand decisions
151
+ cat "${GTM_PATH}/knowledge/BRAND_DECISIONS.md"
152
+
153
+ # Read narrative/messaging
154
+ cat "${GTM_PATH}/knowledge/NARRATIVE.md"
155
+ ```
156
+
157
+ ### Coordinating with Other Services
158
+
159
+ If you need another service to do something:
160
+
161
+ ```bash
162
+ # Emit coordination request
163
+ cat >> "${GTM_PATH}/.jfl/service-events.jsonl" << EOF
164
+ {"ts":"$(date -u +%Y-%m-%dT%H:%M:%S.000Z)","service":"{SERVICE_NAME}","type":"coordination_request","target":"other-service","message":"Need other-service to do X","session":"$(git branch --show-current)"}
165
+ EOF
166
+ ```
167
+
168
+ The GTM or the target service's agent will see this and respond.
169
+
170
+ ## Session Start Behavior
171
+
172
+ When a session starts in this service directory:
173
+
174
+ 1. **Identify yourself**: "I'm the service agent for {SERVICE_NAME}"
175
+ 2. **Show current status**: Read and display `.jfl/status.json`
176
+ 3. **Check for recent events**: Show last 5 events from GTM bus for this service
177
+ 4. **Review recent work**: Show recent journal entries
178
+ 5. **Check service health**: Verify the service is running correctly
179
+
180
+ Example greeting:
181
+
182
+ ```
183
+ Service Agent: {SERVICE_NAME}
184
+ Status: {status from status.json}
185
+ Health: {health from status.json}
186
+
187
+ Recent activity:
188
+ - {recent_changes from status.json}
189
+
190
+ Ready to work on {SERVICE_NAME}.
191
+ What do you need?
192
+ ```
193
+
194
+ ## @-Mentions from GTM
195
+
196
+ When the GTM agent addresses you via `@{SERVICE_NAME}`:
197
+
198
+ 1. You receive the full context from GTM (user request + relevant GTM knowledge)
199
+ 2. Process the request within your service context
200
+ 3. Make necessary changes
201
+ 4. Update status.json and emit event
202
+ 5. Return response that will be relayed back to GTM session
203
+
204
+ **Example:**
205
+ ```
206
+ GTM user: "@{SERVICE_NAME} update the homepage with new messaging from NARRATIVE.md"
207
+
208
+ You receive:
209
+ - User request
210
+ - Content of NARRATIVE.md
211
+ - Your working directory is set to this service
212
+
213
+ You should:
214
+ 1. Read NARRATIVE.md content (provided)
215
+ 2. Read your ARCHITECTURE.md to understand homepage structure
216
+ 3. Update the homepage component
217
+ 4. Test the changes
218
+ 5. Commit
219
+ 6. Update status.json: "recent_changes": ["Updated homepage messaging"]
220
+ 7. Emit event: {"type":"update","message":"Updated homepage with new messaging"}
221
+ 8. Respond: "Updated {SERVICE_NAME} homepage. Changes committed."
222
+ ```
223
+
224
+ ## Service-Specific Skills
225
+
226
+ You have access to lifecycle management via `/service` skill (if configured):
227
+
228
+ - `/service deploy` - Deploy this service
229
+ - `/service restart` - Restart this service
230
+ - `/service stop` - Stop this service
231
+ - `/service start` - Start this service
232
+ - `/service logs [lines]` - View recent logs
233
+ - `/service status` - Detailed status report
234
+ - `/service health` - Run health checks
235
+
236
+ These commands should be implemented according to your `knowledge/DEPLOYMENT.md`.
237
+
238
+ ## Git Workflow
239
+
240
+ **Within Service:**
241
+ - Commit changes to this service's repo
242
+ - Follow service's branching strategy
243
+ - Include service name in commit messages for clarity
244
+
245
+ **Example:**
246
+ ```bash
247
+ git add .
248
+ git commit -m "$(cat <<'EOF'
249
+ feat({SERVICE_NAME}): Update homepage messaging
250
+
251
+ Updated hero section with new positioning from GTM NARRATIVE.md.
252
+
253
+ Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
254
+ EOF
255
+ )"
256
+ git push
257
+ ```
258
+
259
+ ## Error Handling
260
+
261
+ When errors occur:
262
+
263
+ 1. **Update status immediately**:
264
+ ```bash
265
+ # Update status.json with error state
266
+ jq '.status = "error" | .health = "unhealthy"' .jfl/status.json > .jfl/status.json.tmp
267
+ mv .jfl/status.json.tmp .jfl/status.json
268
+ ```
269
+
270
+ 2. **Emit error event**:
271
+ ```bash
272
+ cat >> "${GTM_PATH}/.jfl/service-events.jsonl" << EOF
273
+ {"ts":"$(date -u +%Y-%m-%dT%H:%M:%S.000Z)","service":"{SERVICE_NAME}","type":"error","message":"Error description: ${ERROR_MSG}","session":"$(git branch --show-current)"}
274
+ EOF
275
+ ```
276
+
277
+ 3. **Journal the issue**:
278
+ - Write journal entry with type: "fix" or "error"
279
+ - Include root cause analysis
280
+ - Document the fix
281
+
282
+ 4. **Inform user**: Explain what happened and what you're doing to fix it
283
+
284
+ ## Deployment Protocol
285
+
286
+ When deploying:
287
+
288
+ 1. **Read DEPLOYMENT.md** for service-specific deploy procedure
289
+ 2. **Update status.json** to "building"
290
+ 3. **Run deploy commands** (from DEPLOYMENT.md)
291
+ 4. **Update status.json** to "running" (or "error" if failed)
292
+ 5. **Emit deploy event** with version info
293
+ 6. **Journal the deployment**
294
+
295
+ ## Health Checks
296
+
297
+ Periodically verify service health:
298
+
299
+ 1. Check if process is running (PID check)
300
+ 2. Check if port is accessible (if applicable)
301
+ 3. Verify recent logs for errors
302
+ 4. Test critical endpoints (if API/web service)
303
+ 5. Update status.json health field
304
+
305
+ ## Coordination Patterns
306
+
307
+ ### GTM Requests Service Change
308
+ 1. GTM spawns you with request + context
309
+ 2. You execute within service
310
+ 3. You emit event + update status
311
+ 4. You return result to GTM
312
+
313
+ ### Service Detects Issue
314
+ 1. You detect problem (error, health degradation)
315
+ 2. You emit error event
316
+ 3. GTM sees event and can respond
317
+ 4. Or user directly works with you to fix
318
+
319
+ ### Service Needs Another Service
320
+ 1. You check other service's status.json
321
+ 2. If coordination needed, emit coordination_request event
322
+ 3. GTM orchestrates or other service responds
323
+ 4. You wait for confirmation or proceed independently
324
+
325
+ ## Remember
326
+
327
+ - **You manage THIS service only** - stay in your lane
328
+ - **Communicate via events** - don't try to directly modify other services
329
+ - **Keep status.json current** - it's your primary interface to GTM
330
+ - **Journal your work** - service-specific journal entries
331
+ - **Read knowledge docs** - they contain service-specific procedures
332
+ - **Emit events liberally** - better to over-communicate than under-communicate
333
+
334
+ You are part of a distributed system. Your clarity and communication enable the whole system to work.
@@ -0,0 +1,115 @@
1
+ # {SERVICE_NAME} - Architecture
2
+
3
+ ## Tech Stack
4
+
5
+ **Framework:** {framework}
6
+ **Language:** {language}
7
+ **Runtime:** {runtime}
8
+ **Database:** {database if applicable}
9
+ **Key Libraries:**
10
+ - {library 1}: {purpose}
11
+ - {library 2}: {purpose}
12
+
13
+ ## Directory Structure
14
+
15
+ ```
16
+ {SERVICE_NAME}/
17
+ ├── src/ # Source code
18
+ │ ├── components/ # (if applicable)
19
+ │ ├── lib/ # Utilities
20
+ │ ├── api/ # API routes
21
+ │ └── ...
22
+ ├── public/ # Static assets (if web)
23
+ ├── tests/ # Test files
24
+ ├── .jfl/ # JFL service agent files
25
+ ├── knowledge/ # Service documentation
26
+ └── package.json # Dependencies
27
+ ```
28
+
29
+ ## Key Components
30
+
31
+ ### {Component 1}
32
+ - **Purpose:** What it does
33
+ - **Location:** `src/path/to/component`
34
+ - **Dependencies:** What it depends on
35
+ - **Used By:** What uses it
36
+
37
+ ### {Component 2}
38
+ - **Purpose:** What it does
39
+ - **Location:** `src/path/to/component`
40
+ - **Dependencies:** What it depends on
41
+ - **Used By:** What uses it
42
+
43
+ ## Data Flow
44
+
45
+ ```
46
+ {Describe how data flows through the service}
47
+
48
+ User Request
49
+
50
+ {Component A}
51
+
52
+ {Component B}
53
+
54
+ Response
55
+ ```
56
+
57
+ ## Configuration
58
+
59
+ **Environment Variables:**
60
+ | Variable | Purpose | Default | Required |
61
+ |----------|---------|---------|----------|
62
+ | {VAR_NAME} | ... | ... | Yes/No |
63
+
64
+ **Config Files:**
65
+ - `{config-file}`: {purpose}
66
+
67
+ ## Build & Development
68
+
69
+ **Install dependencies:**
70
+ ```bash
71
+ {install command}
72
+ ```
73
+
74
+ **Development mode:**
75
+ ```bash
76
+ {dev command}
77
+ ```
78
+
79
+ **Build:**
80
+ ```bash
81
+ {build command}
82
+ ```
83
+
84
+ **Test:**
85
+ ```bash
86
+ {test command}
87
+ ```
88
+
89
+ ## Integration Points
90
+
91
+ ### With {Other Service}
92
+ - **Purpose:** Why we integrate
93
+ - **Method:** HTTP API, event bus, shared DB, etc.
94
+ - **Data Exchanged:** What data flows between services
95
+
96
+ ## Patterns & Conventions
97
+
98
+ - **Code Style:** {linter, formatter}
99
+ - **Naming:** {conventions}
100
+ - **Error Handling:** {approach}
101
+ - **Logging:** {approach}
102
+
103
+ ## Known Issues
104
+
105
+ - {Issue 1}: {workaround if any}
106
+ - {Issue 2}: {workaround if any}
107
+
108
+ ## Future Improvements
109
+
110
+ - {Improvement 1}
111
+ - {Improvement 2}
112
+
113
+ ## Last Updated
114
+
115
+ {date}
@@ -0,0 +1,199 @@
1
+ # {SERVICE_NAME} - Deployment Guide
2
+
3
+ ## Deployment Target
4
+
5
+ **Platform:** {Vercel, Fly.io, local, etc.}
6
+ **Environment:** {production, staging, development}
7
+ **URL:** {production URL if applicable}
8
+
9
+ ## Prerequisites
10
+
11
+ - [ ] {Prerequisite 1}
12
+ - [ ] {Prerequisite 2}
13
+ - [ ] Access credentials configured
14
+ - [ ] Environment variables set
15
+
16
+ ## Deployment Commands
17
+
18
+ ### Deploy to Production
19
+
20
+ ```bash
21
+ {deployment command}
22
+ ```
23
+
24
+ ### Deploy to Staging
25
+
26
+ ```bash
27
+ {staging deployment command if different}
28
+ ```
29
+
30
+ ### Rollback
31
+
32
+ ```bash
33
+ {rollback command}
34
+ ```
35
+
36
+ ## Environment Variables
37
+
38
+ Configure these before deploying:
39
+
40
+ ```bash
41
+ # Required
42
+ export {VAR1}="..."
43
+ export {VAR2}="..."
44
+
45
+ # Optional
46
+ export {VAR3}="..."
47
+ ```
48
+
49
+ **Where to set:**
50
+ - Production: {where env vars are configured}
51
+ - Staging: {where env vars are configured}
52
+ - Development: `.env.local`
53
+
54
+ ## Pre-Deployment Checklist
55
+
56
+ - [ ] Tests passing: `{test command}`
57
+ - [ ] Build succeeds: `{build command}`
58
+ - [ ] Environment variables verified
59
+ - [ ] Dependencies up to date
60
+ - [ ] Breaking changes documented
61
+ - [ ] Database migrations applied (if applicable)
62
+
63
+ ## Post-Deployment Verification
64
+
65
+ ```bash
66
+ # Health check
67
+ curl {health-check-url}
68
+
69
+ # Smoke test
70
+ {smoke test commands}
71
+ ```
72
+
73
+ ## Service Control
74
+
75
+ ### Start Service
76
+
77
+ ```bash
78
+ {start command}
79
+ ```
80
+
81
+ ### Stop Service
82
+
83
+ ```bash
84
+ {stop command}
85
+ ```
86
+
87
+ ### Restart Service
88
+
89
+ ```bash
90
+ {restart command}
91
+ ```
92
+
93
+ ### Check Status
94
+
95
+ ```bash
96
+ {status check command}
97
+ ```
98
+
99
+ ### View Logs
100
+
101
+ ```bash
102
+ {log command}
103
+ ```
104
+
105
+ ## Monitoring
106
+
107
+ **Health Check URL:** {URL or method}
108
+ **Logs:** {where logs are}
109
+ **Metrics:** {where metrics are tracked}
110
+
111
+ ## Troubleshooting
112
+
113
+ ### Service Won't Start
114
+
115
+ 1. Check logs: `{log command}`
116
+ 2. Verify environment variables
117
+ 3. Check port availability
118
+ 4. Verify dependencies installed
119
+
120
+ ### Deployment Failed
121
+
122
+ 1. Check deployment logs
123
+ 2. Verify credentials
124
+ 3. Check for build errors
125
+ 4. Verify platform status
126
+
127
+ ### Performance Issues
128
+
129
+ 1. Check resource usage
130
+ 2. Review recent changes
131
+ 3. Check dependency services
132
+ 4. Review logs for errors
133
+
134
+ ## Rollback Procedure
135
+
136
+ If deployment causes issues:
137
+
138
+ ```bash
139
+ # 1. Rollback deployment
140
+ {rollback command}
141
+
142
+ # 2. Verify rollback succeeded
143
+ {verification command}
144
+
145
+ # 3. Investigate issue
146
+ {investigation steps}
147
+ ```
148
+
149
+ ## Database Migrations (if applicable)
150
+
151
+ **Run migration:**
152
+ ```bash
153
+ {migration command}
154
+ ```
155
+
156
+ **Rollback migration:**
157
+ ```bash
158
+ {migration rollback command}
159
+ ```
160
+
161
+ ## Secrets Management
162
+
163
+ **Where secrets are stored:** {secrets location}
164
+
165
+ **Update secret:**
166
+ ```bash
167
+ {secret update command}
168
+ ```
169
+
170
+ ## Common Operations
171
+
172
+ ### Update Dependencies
173
+
174
+ ```bash
175
+ {dependency update command}
176
+ npm audit fix # or equivalent
177
+ {test command}
178
+ ```
179
+
180
+ ### Clear Cache
181
+
182
+ ```bash
183
+ {cache clear command if applicable}
184
+ ```
185
+
186
+ ### Database Backup (if applicable)
187
+
188
+ ```bash
189
+ {backup command}
190
+ ```
191
+
192
+ ## Emergency Contacts
193
+
194
+ - **Platform Support:** {contact info}
195
+ - **On-Call:** {contact info}
196
+
197
+ ## Last Updated
198
+
199
+ {date}