@watchtowerobservability/skills 0.0.0-stage → 0.1.1

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.
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,60 @@
1
- # Temporary Holding Version
1
+ # Watchtower agent skills
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Five skills that teach coding agents to use Watchtower: `watchtower-setup`, `watchtower-debug-issue`,
4
+ `watchtower-write-alerts`, `watchtower-query` and `watchtower-activity` (add a customer-facing activity
5
+ log: record events, mint viewer sessions, and show the log embedded or in the app's own components). They drive the read-only `wtctl agent inspect` commands
6
+ and the Watchtower MCP server; they never print or store a key.
7
+
8
+ ## Install
9
+
10
+ ```sh
11
+ npx @watchtowerobservability/skills install # every tool, in the current project
12
+ npx @watchtowerobservability/skills install claude # claude | cursor | codex | gemini | all
13
+ ```
14
+
15
+ | Tool | Written to |
16
+ |---|---|
17
+ | Claude Code | `.claude/skills/<skill>/SKILL.md` |
18
+ | Cursor | `.cursor/rules/<skill>.mdc` |
19
+ | Codex | managed block in `AGENTS.md` |
20
+ | Gemini | managed block in `GEMINI.md` |
21
+
22
+ Re-running updates in place; text outside the managed block is kept. To also trace the agent itself and
23
+ give it read access, run `wtctl agent setup <tool> --endpoint <gateway url>`.
24
+
25
+ ## Quick start
26
+
27
+ ```sh
28
+ export WT_API_URL=... WT_API_KEY=... WT_PROJECT_ID=...
29
+ npx @watchtowerobservability/skills install claude
30
+ # ask your agent: "debug the newest Watchtower issue"
31
+ ```
32
+
33
+ ## Configuration
34
+
35
+ | Variable | Used by | Meaning |
36
+ |---|---|---|
37
+ | `WT_API_URL` | `wtctl agent inspect` | API base URL |
38
+ | `WT_API_KEY` | `wtctl agent inspect` | API key (read) |
39
+ | `WT_PROJECT_ID` | `wtctl agent inspect` | project id |
40
+ | `WT_INGEST_KEY` | `wtctl agent setup` | ingest key, read at runtime, never written to disk |
41
+ | `WT_OTLP_ENDPOINT` | `wtctl agent setup` | gateway OTLP/HTTP URL (default `http://localhost:4318`) |
42
+
43
+ ## Integrations
44
+
45
+ | Agent | Skills | Telemetry of the agent |
46
+ |---|---|---|
47
+ | Claude Code | yes | via `wtctl agent setup claude` |
48
+ | Cursor | yes (rules) | MCP only |
49
+ | Codex | yes | via `wtctl agent setup codex` |
50
+ | Gemini CLI | yes | via `wtctl agent setup gemini` |
51
+
52
+ Source of truth for the commands: `plugins/claude-code/` and `go/wtctl/agent.go` in the monorepo.
53
+
54
+ ## Verify a release
55
+
56
+ `gh attestation verify watchtowerobservability-skills-0.1.1.tgz --repo watchtowerobservability/watchtower-skills`
57
+
58
+ ## License
59
+
60
+ Apache-2.0.
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ const { install, TOOLS } = require('../src/install.js');
4
+
5
+ const usage = `usage: watchtower-skills install [${TOOLS.join('|')}|all] [--dir <project dir>]`;
6
+ const args = process.argv.slice(2);
7
+ if (args[0] !== 'install') {
8
+ console.error(usage);
9
+ process.exit(2);
10
+ }
11
+ let tool = 'all';
12
+ let dir = '.';
13
+ for (let i = 1; i < args.length; i++) {
14
+ if (args[i] === '--dir') dir = args[++i] ?? '';
15
+ else if (!args[i].startsWith('-')) tool = args[i];
16
+ else { console.error(usage); process.exit(2); }
17
+ }
18
+ if (!dir || (tool !== 'all' && !TOOLS.includes(tool))) {
19
+ console.error(usage);
20
+ process.exit(2);
21
+ }
22
+ for (const t of tool === 'all' ? TOOLS : [tool]) {
23
+ for (const f of install(t, dir)) console.log(`${t}: wrote ${f}`);
24
+ }
package/package.json CHANGED
@@ -1,6 +1,17 @@
1
1
  {
2
2
  "name": "@watchtowerobservability/skills",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "repository": { "type": "git", "url": "git+https://github.com/watchtowerobservability/watchtower-skills.git" },
5
+ "publishConfig": {
6
+ "access": "public",
7
+ "registry": "https://registry.npmjs.org/"
8
+ },
9
+ "description": "Watchtower agent skills for Claude Code, Cursor, Codex and Gemini (plain JavaScript)",
10
+ "main": "src/install.js",
11
+ "types": "src/install.d.ts",
12
+ "bin": { "watchtower-skills": "bin/watchtower-skills.js" },
13
+ "files": ["bin", "src", "skills"],
14
+ "license": "Apache-2.0",
15
+ "engines": { "node": ">=18" },
16
+ "scripts": { "test": "node --test test/*.test.js" }
17
+ }
@@ -0,0 +1,50 @@
1
+ ---
2
+ name: watchtower-activity
3
+ description: Add a customer-facing activity (audit) log to an app with Watchtower - record events on the server, mint viewer sessions, and show the log in the app's own UI (embedded <wt-activity> or app-native components over the feed API). Use for "add an audit log", "show customers their activity", "record who did what", "SOC 2 audit trail for our tenants".
4
+ ---
5
+
6
+ Goal: every tenant of the user's app sees its own tamper-evident activity log inside the app, styled like the app. Three parts: record (server), session (server), display (client). Do them in this order and test each before the next.
7
+
8
+ ## Rules
9
+
10
+ - Two credentials, never mixed: the project secret `wti_...` (`WT_SECRET_KEY`, server only: record events, mint sessions) and a short-lived viewer session token (browser). Never send the secret to a browser, a mobile app, a log line or a commit; read it from the environment and tell the user where to set it.
11
+ - The account is the app's tenant (organisation, workspace, team id), never the end user. Take it from the authenticated server session, never from a request parameter.
12
+ - Actions are `noun.verb` in past tense (`invoice.paid`, `member.role_changed`, `api_key.created`); `wt.*` is reserved. Keep one list of action constants in the codebase.
13
+ - Never put secrets, passwords, tokens or full card numbers in `metadata`; configure redaction (`PUT /v1/projects/$WT_PROJECT_ID/activity/redaction`) for fields that might carry personal data.
14
+
15
+ ## 1. Record (server)
16
+
17
+ Install the server SDK of the stack: npm `@watchtowerobservability/activity`, PyPI `watchtower-activity`, Go `github.com/watchtowerobservability/watchtower-activity-go`, and the Ruby, PHP (Laravel facade), Java, .NET, Rust and Elixir packages from `github.com/watchtowerobservability/watchtower-activity-<lang>`. Find the places where the app changes state (handlers, service methods, model hooks, webhook receivers) and record after the change commits:
18
+
19
+ ```ts
20
+ await activity.record({ account_id: org.id, action: 'member.role_changed', actor: { id: user.id, name: user.name, email: user.email },
21
+ target: { type: 'member', id: member.id, name: member.email }, changes: [{ field: 'role', old: before, new: after }],
22
+ outcome: 'success', context: { ip: req.ip, user_agent: req.headers['user-agent'], request_id: req.id },
23
+ idempotency_key: `member-${member.id}-role-${version}` });
24
+ ```
25
+
26
+ Record denials too (`outcome: 'denied'`, `severity: 'warning'`): they are what auditors look for. When an AI agent or an API key acts for a person, set `actor` to the agent or key and `on_behalf_of` to the person. A stable `idempotency_key` makes retries safe (delivery is at least once). Check the shape without storing with `POST /v1/activity/events/validate` or `record(..., { dryRun: true })`; register schemas for the important actions (`PUT /v1/projects/$WT_PROJECT_ID/activity/schemas/{action}`, start with `mode: warn`).
27
+
28
+ ## 2. Session (server)
29
+
30
+ Add one authenticated endpoint in the app, for example `POST /api/activity-session`, that checks the signed-in user may see the tenant's log and returns a viewer session:
31
+
32
+ ```ts
33
+ const { token } = await activity.createViewerSession({ accountId: org.id, capabilities: ['read', 'export', 'verify'], expiresIn: 900, locale: user.locale, timeZone: user.timeZone });
34
+ return { token };
35
+ ```
36
+
37
+ Give `export`/`verify` only to roles that should have them; `actorId` limits a session to one user's own events and `subScope` to one object. On logout or a tenant offboarding call `revokeAccountSessions(org.id)`. The client refreshes the token before `expiresIn` runs out.
38
+
39
+ ## 3. Display (client)
40
+
41
+ Match the app first: read its design tokens (CSS variables, Tailwind config, theme file) and component library before writing UI. Then pick one:
42
+
43
+ - Embedded element, least code: `npm i @watchtowerobservability/activity-web` plus the wrapper of the framework: `/react` (`<ActivityLog session={token} />`), `@watchtowerobservability/activity-vue` (`<ActivityLog :session="token" @open="..." />`), `@watchtowerobservability/activity-angular` (`<wt-activity [session]="token" (activityOpen)="...">` with the standalone `WtActivityComponent` in `imports`), `@watchtowerobservability/activity-svelte` (`<div use:wtActivity={{ session: token }} />` or `<ActivityLog session={token} />`). Plain HTML: `<wt-activity session="..." base-url="https://api..."></wt-activity>`. Set `theme`, `accent`, `density` and `locale` from the app; brand colours, fonts, columns and strings go in the project theme (`PUT /v1/projects/$WT_PROJECT_ID/activity/theme` then `.../theme/publish`), so every surface matches.
44
+ - App-native UI, when the log must look exactly like the app: build the list with the app's own table, filter and drawer components over the viewer API, with the token as `Authorization: Bearer`. `GET /v1/activity/feed?limit=&cursor=&q=&actor_id=&action=&outcome=&from=&to=` returns `{data: [Event], next_cursor, theme}`; `GET /v1/activity/feed/facets?field=action|actor|target_type|target` fills filter selects; `GET /v1/activity/actions` gives display names; `GET /v1/activity/feed/histogram` the volume chart; `GET /v1/activity/feed/export?format=csv|ndjson|ocsf` (cap `export`) downloads; `GET /v1/activity/feed/verify` and `.../feed/proof?id=` (cap `verify`) prove integrity; `GET /v1/activity/feed/stream` is live SSE. An Event has `id, account_id, action, actor {id, name, email, type}, on_behalf_of, target, targets[], changes[], outcome, severity, context {country, request_id}, metadata, occurred_at, received_at`. Render `changes` as before/after, times in the user's zone, and keep a "Verified" badge from the verify call. Search input takes the query language (`action:member.* -actor:bot outcome:denied created:>=2026-01-01`); an AI search box can call `POST /v1/activity/query/translate {text}` and run the returned `q` when it is not null.
45
+
46
+ Every list needs empty, loading and error states, keyboard access and pagination by `next_cursor` (never by page numbers).
47
+
48
+ ## 4. Verify
49
+
50
+ Run the app, perform one recorded action, open the log as a tenant user and confirm the event shows with actor, target and changes. Confirm a second tenant cannot see it (a foreign account is a 404). Then summarise for the user: the actions now recorded (file and line of each), the session endpoint and who may call it, and the config they must set (`WT_SECRET_KEY`, `WT_API_URL`, the project id). Optional: Terraform resources `watchtower_activity_stream`, `_rule`, `_schema`, `_retention`, `_redaction`, `_theme`, `_domain`, `_export_schedule` keep the configuration in code; the MCP server's `activity` toolset (`search_activity`, `verify_activity`, ...) lets an agent inspect the log afterwards.
@@ -0,0 +1,15 @@
1
+ ---
2
+ name: watchtower-debug-issue
3
+ description: Investigate a production error, alert or slow request using Watchtower before changing code. Use when debugging an exception, a regression after a deploy, or a latency complaint.
4
+ ---
5
+
6
+ Everything here is read-only. Credentials come from `WT_API_URL`, `WT_API_KEY`, `WT_PROJECT_ID`; never print them.
7
+
8
+ 1. `wtctl agent inspect issues --limit 10`: find the issue; note its id, culprit, first seen release and times seen.
9
+ 2. Read the newest event of the issue (`GET /v1/projects/$WT_PROJECT_ID/issues/<id>/events?limit=1`, or the MCP tools) and take the top in-app stack frame. Open that file at that line.
10
+ 3. The event carries a `trace_id`: `wtctl agent inspect trace <trace id>` shows the failing span, its parent request and neighbouring spans. Look for the slow or failing child.
11
+ 4. `wtctl agent inspect logs --text "<error text>"` for the log lines around the failure.
12
+ 5. Check whether the first-seen release matches a recent deploy; suspect commits are listed on the issue (`/issues/<id>/suspects`).
13
+ 6. State the root cause with the evidence (frame, span, log line) before editing. Reproduce with a test, fix, and mention the issue id in the commit message so Watchtower links the resolution to the release.
14
+
15
+ Do not resolve, ignore or merge issues unless the user asks.
@@ -0,0 +1,14 @@
1
+ ---
2
+ name: watchtower-query
3
+ description: Query Watchtower traces, logs, metrics and profiles to answer how production is behaving. Use for "how slow is X", "show errors for Y", "find logs containing Z".
4
+ ---
5
+
6
+ Read-only. Credentials from `WT_API_URL`, `WT_API_KEY`, `WT_PROJECT_ID` (never print them).
7
+
8
+ - Logs: `wtctl agent inspect logs --text "<substring>" --limit 50`.
9
+ - One trace: `wtctl agent inspect trace <trace id>`; sort spans by duration to find the slow child.
10
+ - Issues and monitors: `wtctl agent inspect issues|monitors --limit 20`.
11
+ - Metrics and anything else: the MCP server (`wtctl mcp serve --stdio`) exposes the API; the OpenAPI document is the source of truth for paths under `/v1/projects/$WT_PROJECT_ID/`.
12
+ - Profiles: `GET /v1/projects/$WT_PROJECT_ID/profiles/table?service=<svc>` lists functions with self and total cost.
13
+
14
+ Always bound the time range and the limit. Summarise results (counts, top offenders, one representative id) instead of pasting raw JSON, and give the user the ids so they can open them in Watchtower.
@@ -0,0 +1,11 @@
1
+ ---
2
+ name: watchtower-setup
3
+ description: Wire an application to Watchtower (errors, traces, logs, releases) and trace this coding agent itself. Use when asked to add Watchtower, instrument a service, or send telemetry.
4
+ ---
5
+
6
+ 1. Detect the stack (package.json, pyproject.toml, go.mod, pom.xml, composer.json, Gemfile, Cargo.toml) and install the matching SDK from `github.com/watchtowerobservability/watchtower-<lang>` (node, python, go, java, php, ruby, dotnet, rust, browser, android, ios). Or run `npx @watchtowerobservability/wizard`.
7
+ 2. Configure with environment variables, identical in every SDK: `WT_INGEST_KEY` (secret, server SDKs only), `WT_OTLP_ENDPOINT` (default `http://localhost:4318`), `WT_SERVICE`, `WT_ENVIRONMENT`, `WT_RELEASE`. Browser, mobile and desktop SDKs take the publishable key as an option instead.
8
+ 3. Never write a key into a file, a commit or a log. Read it from the environment or a secret manager and tell the user where to set it.
9
+ 4. Verify with `wtctl send-test --endpoint "$WT_OTLP_ENDPOINT" --key "$WT_INGEST_KEY"`, then confirm the service appears with `wtctl agent inspect issues --limit 5`.
10
+ 5. To trace this coding session too: `wtctl agent setup claude|cursor|codex|gemini --endpoint <gateway url>` (run once; the ingest key stays in `WT_INGEST_KEY`).
11
+ 6. Upload source maps or debug files from CI with `wtctl sourcemaps upload <dir>` and `wtctl debug-files upload <path>`, and create the release with `wtctl release create <version> --deploy <env>`.
@@ -0,0 +1,29 @@
1
+ ---
2
+ name: watchtower-write-alerts
3
+ description: Write Watchtower alert rules as Prometheus-style rule files and import them. Use when asked to add, tune or review alerts, SLOs or monitors.
4
+ ---
5
+
6
+ Rule files use the Prometheus rule-group format. Import with
7
+ `wtctl rules import rules.yaml --api "$WT_API_URL" --key "$WT_API_KEY" --project "$WT_PROJECT_ID"`.
8
+
9
+ ```yaml
10
+ groups:
11
+ - name: checkout
12
+ interval: 1m
13
+ rules:
14
+ - alert: CheckoutErrorRateHigh
15
+ expr: sum(rate(http_server_requests_total{service="checkout",status=~"5.."}[5m])) / sum(rate(http_server_requests_total{service="checkout"}[5m])) > 0.05
16
+ for: 10m
17
+ labels: { severity: critical }
18
+ annotations:
19
+ summary: "Checkout 5xx above 5%"
20
+ runbook_url: https://example.com/runbooks/checkout
21
+ ```
22
+
23
+ Guidelines:
24
+ - Alert on symptoms users feel (error rate, latency percentile, saturation), not causes.
25
+ - Always set `for:` (at least 5m for ratios) and a `severity` label (critical, high, warning, info). Every rule needs a `summary` and ideally a `runbook_url`.
26
+ - Use ratios over absolute counts so traffic changes do not page anyone.
27
+ - List existing monitors first: `wtctl agent inspect monitors`. Avoid duplicates; tune thresholds instead.
28
+ - Import an existing Alertmanager config with `wtctl routing import-alertmanager <file>` (dry run unless `--apply`).
29
+ - Show the user the file before importing anything.
@@ -0,0 +1,8 @@
1
+ export type Tool = 'claude' | 'cursor' | 'codex' | 'gemini';
2
+ export interface Skill { name: string; description: string; body: string; raw: string }
3
+ export const TOOLS: Tool[];
4
+ export const BEGIN: string;
5
+ export const END: string;
6
+ export function loadSkills(dir?: string): Skill[];
7
+ /** Installs every skill for one tool under dir and returns the files written. Safe to re-run. */
8
+ export function install(tool: Tool, dir?: string, skills?: Skill[]): string[];
package/src/install.js ADDED
@@ -0,0 +1,60 @@
1
+ 'use strict';
2
+ const fs = require('node:fs');
3
+ const path = require('node:path');
4
+
5
+ const SKILLS_DIR = path.join(__dirname, '..', 'skills');
6
+ const TOOLS = ['claude', 'cursor', 'codex', 'gemini'];
7
+ const BEGIN = '<!-- watchtower-skills:begin -->';
8
+ const END = '<!-- watchtower-skills:end -->';
9
+
10
+ /** Reads the bundled skills as [{name, description, body}]. */
11
+ function loadSkills(dir = SKILLS_DIR) {
12
+ return fs.readdirSync(dir).sort().map((name) => {
13
+ const raw = fs.readFileSync(path.join(dir, name, 'SKILL.md'), 'utf8');
14
+ const m = /^---\n([\s\S]*?)\n---\n([\s\S]*)$/.exec(raw);
15
+ if (!m) throw new Error(`${name}/SKILL.md has no frontmatter`);
16
+ const description = /^description:\s*(.+)$/m.exec(m[1])?.[1] ?? name;
17
+ return { name, description, body: m[2].trim(), raw };
18
+ });
19
+ }
20
+
21
+ function write(file, text) {
22
+ fs.mkdirSync(path.dirname(file), { recursive: true });
23
+ fs.writeFileSync(file, text);
24
+ return file;
25
+ }
26
+
27
+ // Replaces our marked block in a shared file (AGENTS.md, GEMINI.md); user text outside it is kept.
28
+ function upsertBlock(file, block) {
29
+ const cur = fs.existsSync(file) ? fs.readFileSync(file, 'utf8') : '';
30
+ const wrapped = `${BEGIN}\n${block}\n${END}`;
31
+ const i = cur.indexOf(BEGIN);
32
+ const j = cur.indexOf(END);
33
+ const next = i >= 0 && j > i
34
+ ? cur.slice(0, i) + wrapped + cur.slice(j + END.length)
35
+ : (cur ? cur.replace(/\n*$/, '\n\n') : '') + wrapped + '\n';
36
+ return write(file, next);
37
+ }
38
+
39
+ const asSections = (skills) => skills
40
+ .map((s) => `## ${s.name}\n\n${s.description}\n\n${s.body}`).join('\n\n');
41
+
42
+ /** Installs every skill for one tool under dir; returns the files written. Safe to re-run. */
43
+ function install(tool, dir = '.', skills = loadSkills()) {
44
+ if (!TOOLS.includes(tool)) throw new Error(`unknown tool "${tool}"; use one of ${TOOLS.join(', ')}`);
45
+ switch (tool) {
46
+ case 'claude':
47
+ return skills.map((s) => write(path.join(dir, '.claude', 'skills', s.name, 'SKILL.md'), s.raw));
48
+ case 'cursor':
49
+ return skills.map((s) => write(
50
+ path.join(dir, '.cursor', 'rules', `${s.name}.mdc`),
51
+ `---\ndescription: ${s.description}\nalwaysApply: false\n---\n\n${s.body}\n`,
52
+ ));
53
+ case 'codex':
54
+ return [upsertBlock(path.join(dir, 'AGENTS.md'), `# Watchtower\n\n${asSections(skills)}`)];
55
+ default:
56
+ return [upsertBlock(path.join(dir, 'GEMINI.md'), `# Watchtower\n\n${asSections(skills)}`)];
57
+ }
58
+ }
59
+
60
+ module.exports = { install, loadSkills, TOOLS, BEGIN, END };