@harnessforce/claude-code-plugin 0.0.0-stage → 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.
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "harnessforce",
3
+ "version": "0.2.0",
4
+ "description": "Harnessforce plugin for Claude Code",
5
+ "author": {
6
+ "name": "Lambda Script"
7
+ },
8
+ "homepage": "https://github.com/lambda-script/harnessforce-agent",
9
+ "repository": "https://github.com/lambda-script/harnessforce-agent",
10
+ "license": "Apache-2.0"
11
+ }
package/.mcp.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "mcpServers": {
3
+ "harnessforce": {
4
+ "type": "http",
5
+ "url": "${HARNESSFORCE_URL:-https://harnessforce.dev}/mcp"
6
+ }
7
+ }
8
+ }
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,144 @@
1
- # Temporary Holding Version
1
+ # harnessforce plugin for Claude Code
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
+ The `harnessforce` Claude Code plugin links your Claude Code sessions to
4
+ [Harnessforce](https://github.com/lambda-script/harnessforce-agent) Issues. It is distributed through
5
+ the `harnessforce-agent` marketplace in this repository and as the npm package
6
+ `@harnessforce/claude-code-plugin`, which holds the plugin built against the production connection URL
7
+ and does not bundle the CLI (`/harnessforce:setup` installs `@harnessforce/cli` from npm).
8
+
9
+ ## What it contains
10
+
11
+ | Part | Purpose |
12
+ | --- | --- |
13
+ | `SessionStart` and `UserPromptSubmit` hooks | Register each session and its config snapshot with Harnessforce |
14
+ | `PostToolUse`, `PostToolUseFailure`, `UserPromptExpansion`, `PermissionRequest`, `PostCompact` and `SessionEnd` hooks | Count the configured skills, commands, subagents and MCP servers a session uses, and send the session usage summary |
15
+ | MCP server `harnessforce` (`<connection URL>/mcp`, HTTP) | Tools to start a run, read an Issue, and complete a run |
16
+ | Skill `using-harnessforce` | What Harnessforce records and does not collect, which hook sends what, and when to use the other skills. The `SessionStart` hook injects its body into the context of every session (the build embeds the same text into the hook and the CLI) |
17
+ | Skill `record-run` | Tells the agent when to start and complete a run |
18
+ | Command `/harnessforce:setup` | Checks Node.js, installs the `harnessforce` CLI, asks whether to send content, runs `harnessforce init` (`--send-content` when chosen) and `harnessforce import`, and confirms the first event after a restart |
19
+ | Command `/harnessforce:tune` | Tells you that the agent reads parts of your transcripts through your model provider, runs `harnessforce tune --json`, shows the analysis and the before and after of earlier applied proposals, and makes proposals for the targets with enough data |
20
+ | Command `/harnessforce:status` | Runs `harnessforce top --once --json` and summarizes the sessions on this machine. Read-only |
21
+ | Command `/harnessforce:import` | Runs `harnessforce import` and shows the imported count and why sessions were skipped |
22
+ | Command `/harnessforce:run <issue>` | Shows how to start an agent on an Issue with `harnessforce run --issue <issue> -- <agent>` in a terminal, and how `HARNESSFORCE_ISSUE` ties a session to an Issue. Runs nothing |
23
+ | Command `/harnessforce:help` | Lists the CLI commands (`harnessforce --help`) and these commands, and says which ones are not wrapped (`init`, the interactive `top`) |
24
+ | Skill `propose-improvements` | How the agent writes a proposal (evidence, diff or pull request draft, expected effect, how to measure), keeps permissions minimal and loops bounded, and records it with `harnessforce tune record` before showing it |
25
+
26
+ The hooks and the MCP server exist only in the build output, because their scripts and connection URL
27
+ come from the build. The copy of the plugin in this repository has no hooks and no MCP server. See
28
+ [Building the local marketplace](../../docs/runbooks/local-marketplace.md).
29
+
30
+ ## Install
31
+
32
+ The marketplace installs the plugin from npm, with no version pinned, so you get the latest
33
+ published version:
34
+
35
+ ```text
36
+ /plugin marketplace add lambda-script/harnessforce-agent
37
+ /plugin install harnessforce@harnessforce-agent
38
+ /harnessforce:setup
39
+ ```
40
+
41
+ To connect to a staging or local `apps/web` instead, install the
42
+ [local marketplace build](../../docs/runbooks/local-marketplace.md).
43
+
44
+ ## Requirements
45
+
46
+ Node.js 18 or later on `PATH`. Without it, Claude Code shows a non-blocking `hook error` and the session
47
+ continues without sending anything.
48
+
49
+ ## Warnings
50
+
51
+ When a hook cannot send, it shows one line in the session instead of staying silent: Node.js older than 18,
52
+ a failed restart of the hook process, sending not set up (`/harnessforce:setup`), an endpoint that is set
53
+ but not allowed, no ingest key in the keychain (for example after a reboot cleared the kernel keyring), a
54
+ destination that differs from the one `harnessforce init` saved, the Claude Code telemetry settings that
55
+ `harnessforce init` wrote missing from the user settings, a keychain that could not be read, and a session
56
+ registration that failed with anything other than 401. The line appears only at a session start that
57
+ registers (`startup`, `clear`, `fork`), except for the two startup failures, which appear at every session
58
+ start. Nothing is shown while sending works, and nothing is checked again later in the session. When
59
+ `harnessforce` is not on `PATH`, the hook shows nothing: Claude Code reports that `otelHeadersHelper` failed.
60
+
61
+ ## Updates
62
+
63
+ The hooks send `User-Agent: harnessforce-claude-code-plugin/<version>` and keep the update status the
64
+ server returns in `${CLAUDE_PLUGIN_DATA}/update-status.json`. When a session starts they show one line
65
+ for a newer version (once a day, and not while Claude Code updates the plugin automatically), for the
66
+ date a version stops sending after a security fix, or for an unsupported version. An unsupported version
67
+ sends nothing until you run `claude plugin update harnessforce@harnessforce-agent`; the session keeps
68
+ running. `harnessforce init` turns on automatic updates for the `harnessforce-agent` marketplace.
69
+
70
+ ## Session registration hooks
71
+
72
+ The `harnessforce` plugin registers each Claude Code session with Harnessforce so that runs can be
73
+ linked to issues. On `SessionStart` (`startup`, `clear`, `fork`) it sends the session ID and the git
74
+ repository, branch and commit of `cwd` to `POST <HARNESSFORCE_ENDPOINT>/v1/sessions`. On the first
75
+ prompt it sends the same registration again with the prompt ID. Prompts, responses and file
76
+ contents are never sent.
77
+
78
+ - For an organization, set `HARNESSFORCE_ENDPOINT` (the ingest base URL, `https:`) and
79
+ `HARNESSFORCE_INGEST_KEY` (a Workspace ingest key) in
80
+ the `env` of the managed settings file (`managed-settings.json` or `managed-settings.d/*.json` in
81
+ the managed directory). The hook reads the Workspace key and its endpoint only from those files,
82
+ never from the process environment, because a repository's `.claude/settings.json` can set
83
+ environment variables. Values distributed through MDM or server-managed settings are not read.
84
+ Hooks do not receive `OTEL_*` variables, so these are separate.
85
+ - Without a managed Workspace key, the hook sends to `HARNESSFORCE_ENDPOINT` from the environment with
86
+ the user ingest key that `harnessforce init` stored for
87
+ `HARNESSFORCE_WORKSPACE_ID`, reading it by running `harnessforce otel-headers` from `PATH` (1 second limit).
88
+ With a user key and `HARNESSFORCE_ISSUE` (set by `harnessforce run`), the registration claims `source=cli`
89
+ with that issue identifier. A Workspace key never claims `source=cli`.
90
+ - Requires Node.js 18 or later on `PATH`. The hook always exits 0: outside a git repository, without
91
+ configuration, on errors, or after 2 seconds it gives up quietly and writes the reason to stderr
92
+ (Claude Code's debug log). Without Node.js, Claude Code shows a non-blocking `hook error`.
93
+ - If the key is revoked, Claude Code shows once per session:
94
+ "The organization's ingest key has been revoked. Contact a Workspace administrator" (Workspace key) or
95
+ "Your ingest key has been revoked. Run `harnessforce init`" (user key)
96
+
97
+ ## Config snapshot
98
+
99
+ At the same `SessionStart`, the hook also sends a config snapshot to
100
+ `POST <HARNESSFORCE_ENDPOINT>/v1/config-snapshots`, including outside a git repository. The snapshot
101
+ describes the agent configuration as a list of components. Each component has a kind, a scope and
102
+ an identifier, plus a SHA-256 hash:
103
+
104
+ - CLAUDE.md files and rules, skills, agents, commands and workflows, from the managed directory,
105
+ `~/.claude` and the repository root.
106
+ - `hooks`, `permissions` and `model` from each settings file.
107
+ - MCP servers from `.mcp.json`, `~/.claude.json` and `managed-mcp.json`.
108
+ - The same kinds of component from enabled marketplace plugins in the plugin cache.
109
+
110
+ File contents, settings values and MCP server configuration (URLs, headers, environment) are never
111
+ sent, only their hashes. The hashes of hooks and MCP servers leave out the values that can carry
112
+ credentials: `env` and `headers` values, `args`, and the userinfo, query and fragment of URLs, so a
113
+ hash cannot be brute-forced back to a short secret. Nothing is sent when there are no components, and the snapshot is skipped
114
+ when collection takes over 1 second or finds more than 1,000 components. The collector lives in
115
+ `packages/agent-core/src/config`, shared with `harnessforce run` so it can compute the same snapshot ID.
116
+
117
+ ## Session usage summary
118
+
119
+ The hooks count, per session, the calls and failures of skills (started through the Skill tool),
120
+ commands (typed by you), subagents (started through the Agent tool) and MCP servers, plus permission
121
+ requests and compactions, and send one summary per session to
122
+ `POST <HARNESSFORCE_ENDPOINT>/v1/session-usage`. Claude Code's telemetry hides the names of your own
123
+ skills, commands, subagents and MCP servers, and the setting that reveals them also sends Bash
124
+ commands and file paths, so the hooks count the names themselves.
125
+
126
+ - Only names that are identifiers in the session's config snapshot are sent; other calls, such as
127
+ built-in subagents, are added to an `other` count. Each list keeps the 200 most called names. Prompts,
128
+ command arguments, tool inputs and results, error messages, compaction summaries and file paths are
129
+ never read into the record or sent. The MCP tool name is reduced to its server.
130
+ - The record lives in `${CLAUDE_PLUGIN_DATA}/usage/`: `<session_id>.jsonl` holds one line per counted
131
+ call (time, prompt ID, kind, identifier, failure) and `<session_id>.json` holds the Workspace, the
132
+ session's identifiers and how much of the record was sent. `SessionStart` creates them when it has a
133
+ destination and a key, and removes files unchanged for 30 days, up to 100 at a time.
134
+ - With a Workspace key from managed settings, `SessionEnd` sends the summary within 1 second of its
135
+ start, without running `harnessforce otel-headers`, because Claude Code gives all `SessionEnd` hooks 1.5 seconds
136
+ together. With a user key, or when that send fails, the next `SessionStart` sends up to 20 summaries of
137
+ other sessions of the same Workspace whose record has not changed for 10 minutes, oldest first.
138
+ - The counting hooks run asynchronously and never delay the agent. Failures are written to stderr as
139
+ `harnessforce: session usage failed (<reason>)`; a `401` at `SessionStart` shows the revoked-key
140
+ notice like the registration does.
141
+
142
+ ## License
143
+
144
+ [Apache-2.0](../../LICENSE)
@@ -0,0 +1,31 @@
1
+ ---
2
+ description: List the harnessforce CLI commands and the /harnessforce:* commands, and say which one to use for what
3
+ disable-model-invocation: true
4
+ ---
5
+
6
+ # Harnessforce help
7
+
8
+ Show the user this guide. To list the CLI commands with a one-line description each, run:
9
+
10
+ ```sh
11
+ harnessforce --help
12
+ ```
13
+
14
+ If the command is not found, tell the user to run `/harnessforce:setup`. `harnessforce <command> --help` shows what a command does, what it sends and does not send, and its exit codes.
15
+
16
+ ## Commands in a session
17
+
18
+ | Command | What it does |
19
+ | --- | --- |
20
+ | `/harnessforce:setup` | Installs the CLI, connects to Harnessforce with `harnessforce init`, imports past sessions and confirms the first event. |
21
+ | `/harnessforce:status` | Summarizes the sessions on this machine (read-only). |
22
+ | `/harnessforce:import` | Imports past sessions. |
23
+ | `/harnessforce:tune` | Analyzes your past sessions and proposes improvements. |
24
+ | `/harnessforce:run <issue>` | Shows how to start an agent on an Issue. |
25
+
26
+ ## Not wrapped
27
+
28
+ - `harnessforce init` opens a browser to log in and takes up to 5 minutes, so it is not wrapped as its own command. `/harnessforce:setup` runs it for you.
29
+ - `harnessforce top` without `--once` is an interactive view that needs a terminal. Run it in a terminal.
30
+ - `harnessforce run` starts an agent as a new process. See `/harnessforce:run`.
31
+ - `harnessforce otel-headers` and `harnessforce hook` are run by the agents, not by you.
@@ -0,0 +1,18 @@
1
+ ---
2
+ description: Import your past sessions on this machine into Harnessforce and report how many were imported and why others were skipped
3
+ disable-model-invocation: true
4
+ ---
5
+
6
+ # Import past sessions
7
+
8
+ `harnessforce import` sends a summary of each past session of the repositories connected to your Workspace, inside the import window. It sends no prompt text, responses, tool inputs or results, or code. It is safe to run again, because sessions that were already sent are skipped.
9
+
10
+ Run it:
11
+
12
+ ```sh
13
+ harnessforce import
14
+ ```
15
+
16
+ - If the command is not found, tell the user to run `/harnessforce:setup` and stop.
17
+ - If it reports that you are not logged in, tell the user to run `/harnessforce:setup` (it runs `harnessforce init`, which needs a browser) and stop.
18
+ - Show the imported count and the breakdown of skipped sessions with the next action, exactly as printed. Do not leave out the reason when nothing was imported.
@@ -0,0 +1,25 @@
1
+ ---
2
+ description: Explain how to start an agent on a Harnessforce Issue with harnessforce run, because a session cannot start its own agent
3
+ argument-hint: "<issue-identifier>"
4
+ disable-model-invocation: true
5
+ ---
6
+
7
+ # Run an agent on an Issue
8
+
9
+ `harnessforce run` starts an agent for an Issue. It has to start that agent as a new process in a terminal, so this command cannot do it from inside a session. It runs nothing. It only shows the steps.
10
+
11
+ Take the Issue identifier from `$ARGUMENTS` (for example `ABC-123`). If it is empty, ask the user for it.
12
+
13
+ ## Start the agent in a terminal
14
+
15
+ Tell the user to run this in a terminal, outside this session. Replace `claude` with the agent to start (for example `codex`).
16
+
17
+ ```text
18
+ harnessforce run --issue <identifier> -- claude
19
+ ```
20
+
21
+ Everything after `--` is passed to the agent unchanged. The agent's exit code becomes the exit code of `harnessforce run`. It needs `harnessforce init` to have been done; if not, run `/harnessforce:setup` first.
22
+
23
+ ## Already in a session?
24
+
25
+ The plugin's hooks tie a session to an Issue when the environment variable `HARNESSFORCE_ISSUE` is set to the identifier before the agent starts. `harnessforce run` sets it for you. This session was started without it unless the user set it, and an environment variable cannot be added to a running session. To work on the Issue, start a new session as above.
@@ -0,0 +1,65 @@
1
+ ---
2
+ description: Harnessforce setup. Walks through checking Node.js, choosing whether to send prompt content, installing the CLI, running harnessforce init, importing past sessions, and confirming the first event after the restart
3
+ disable-model-invocation: true
4
+ ---
5
+
6
+ # Harnessforce setup
7
+
8
+ Go through the steps below in order, interacting with the user. If a command fails, show its output to the user and stop without moving on to the later steps.
9
+
10
+ ## 1. Check Node.js
11
+
12
+ First run `node --version`. If the command is not found, or the version is below 18, do not move on to installing the CLI. Show the following text as it is and stop.
13
+
14
+ > Harnessforce hooks require Node.js 18 or later. Install Node.js, restart Claude Code, then run `/harnessforce:setup` again.
15
+
16
+ ## 2. Check whether this run is after the restart
17
+
18
+ If `harnessforce --version` succeeds and the environment variable `HARNESSFORCE_WORKSPACE_ID` of this session is not empty, this is a session restarted after `harnessforce init`. Skip steps 3 to 7 and go to step 8.
19
+
20
+ ## 3. Install the CLI
21
+
22
+ Run the following, then confirm the install with `harnessforce --version`.
23
+
24
+ ```sh
25
+ npm install -g @harnessforce/cli
26
+ ```
27
+
28
+ ## 4. Choose whether to send prompt content
29
+
30
+ Before `harnessforce init`, present the option to send prompt content to the user, not selected by default. The login is not done yet at this point, so neither the Workspace to connect nor its opt-in state is known. Do not change what you show depending on the opt-in.
31
+
32
+ Present the option together with the following.
33
+
34
+ - If selected, the body of the prompts the user types to the agent is delivered to this Workspace. Secret patterns, email addresses, and phone numbers are replaced with `[REDACTED:kind]` before storing, and the content is deleted after the content retention period (at most 30 days). Secrets and personal information that do not match a pattern are not masked, and not everything can be detected. Within the Workspace, only the person who sent the stored content can read it; Owners and Admins cannot read it either. That person can delete their own content at any time from My practices.
35
+ - Content is stored only when both this setting on the device and the Workspace opt-in are in place. If the Workspace opt-in is withdrawn, later content is discarded on receipt and existing content data can no longer be read. This setting does not enable sending model responses or tool input and output.
36
+ - If selected, run `harnessforce init --send-content`; if not, run `harnessforce init` (step 5). Write this setting to the `env` of the Claude Code user settings, and do not write it to the `env` of the project (`.claude/settings.json`) or local (`.claude/settings.local.json`) files, because the content variable is ignored in the `env` of those two files.
37
+ - To stop after selecting it, set `OTEL_LOG_USER_PROMPTS` in the `env` of the user settings to `0`. The value that stops it also takes effect in the project and local `env`.
38
+
39
+ Use the following option text as it is.
40
+
41
+ > You can send the prompts you type for analysis (off by default; it takes effect only if the workspace has opted in to prompts you typed). If enabled, the prompts you type to the agent are delivered to this workspace and stored. Values that match known patterns for secrets and personal information are replaced with `[REDACTED:kind]`, but not everything can be detected. Content is deleted after the content retention period (at most 30 days), and within the workspace only you can read it. You can delete it at any time from My practices. Enable this?
42
+ >
43
+ > Content is not sent (by default). You can enable it later.
44
+
45
+ ## 5. Connect to Harnessforce
46
+
47
+ Follow the choice in step 4: run `harnessforce init --send-content` if selected, or `harnessforce init` if not. Tell the user to log in to Harnessforce in the browser and choose one Workspace to connect. If the browser does not open, show the user the URL that `harnessforce init` prints. The command waits up to 5 minutes for the login to complete, so run it with a Bash timeout of 10 minutes.
48
+
49
+ For a Workspace that has not opted in, `harnessforce init --send-content` does not write the content setting. It prints a message about that and about the Data retention page of the Workspace settings, and exits with code 0. Do not treat this as a failure; show the printed text to the user as it is.
50
+
51
+ ## 6. Import past sessions
52
+
53
+ Run `harnessforce import` and tell the user, as it is, the imported count it prints, along with the breakdown of sessions that were not imported and the guidance. Do not omit the printed reason and the next action even when the count is 0.
54
+
55
+ ## 7. Ask for a restart
56
+
57
+ Tell the user the following and stop.
58
+
59
+ > Harnessforce setup, part 1 of 2, is done. Restart Claude Code, then run `/harnessforce:setup` again in the new session. Part 2 checks that the first event arrived.
60
+
61
+ ## 8. Confirm the first event
62
+
63
+ At the start of this session, the plugin hook sent the session to Harnessforce. Tell the user to open the Harnessforce Home in the browser (the URL in the environment variable `HARNESSFORCE_URL`) and confirm on the waiting screen for the first Run that it was received. If nothing arrives after 15 minutes, tell the user to follow the checks for each cause shown on the waiting screen. Finish with the following line.
64
+
65
+ > Harnessforce setup is complete.
@@ -0,0 +1,26 @@
1
+ ---
2
+ description: Show the running and recent agent sessions on this machine as a short summary, using a read-only snapshot of harnessforce top
3
+ disable-model-invocation: true
4
+ ---
5
+
6
+ # Session status
7
+
8
+ This command only reads. It changes no file, setting or Workspace data, and sends nothing to Harnessforce.
9
+
10
+ ## 1. Take a snapshot
11
+
12
+ Run this once. It prints one snapshot as JSON and exits, so it does not open the interactive view.
13
+
14
+ ```sh
15
+ harnessforce top --once --json
16
+ ```
17
+
18
+ If the command is not found, tell the user to run `/harnessforce:setup` and stop. If it fails, show its output as is and stop.
19
+
20
+ ## 2. Summarize
21
+
22
+ Summarize the snapshot for the user in a few lines: how many sessions are running, which agent and repository each belongs to, and any recent sessions that ended. Report only values that are in the JSON. Do not guess a value that is missing, and do not turn a missing value into 0.
23
+
24
+ ## 3. Point to the live view
25
+
26
+ The interactive view needs a terminal, so this command does not start it. Tell the user to run `harnessforce top` in a terminal when they want the live view.
@@ -0,0 +1,39 @@
1
+ ---
2
+ description: Analyze your past sessions and show the analysis results, the before and after of the previous suggestion, and suggested improvements for human interventions, repeatable loops, MCP servers, and usage. Does not modify files
3
+ argument-hint: "[--all] [--no-send]"
4
+ disable-model-invocation: true
5
+ ---
6
+
7
+ # Analyze past sessions and suggest improvements
8
+
9
+ Go through the steps below in order. This run does not modify the user's files, settings, repository, or managed settings. The only things written are what `harnessforce tune` and `harnessforce tune record` write to `~/.harnessforce/tune/`.
10
+
11
+ ## 1. Say that content goes to the model provider
12
+
13
+ Before running anything, show the following text as it is.
14
+
15
+ > To make suggestions, the agent reads part of the session records on this device in this run. What it reads goes to the provider of the model you normally use with this agent, through the same path as a normal session. It does not go to Harnessforce. Harnessforce receives only the analysis result values counted by the public rules.
16
+
17
+ ## 2. Analyze
18
+
19
+ Run the following. It starts `harnessforce tune --json` and shows the analysis results and, for each target, the result of checking the conditions for making a suggestion. It includes sending and resending unsent results, so set the Bash timeout to 10 minutes.
20
+
21
+ ```sh
22
+ node "${CLAUDE_PLUGIN_ROOT}/skills/propose-improvements/scripts/summarize.mjs" $ARGUMENTS
23
+ ```
24
+
25
+ - The lines on stderr are the messages of `harnessforce tune`. Show all of them as they are, without omitting or rephrasing them.
26
+ - Show the analysis results on stdout (human interventions, repeatable loops, MCP servers, usage) as they are. Do not rephrase "not measured" as 0. Usage values stay on this device and are not sent to Harnessforce.
27
+ - If there is a "Before and after the previous suggestion" section, show it as it is before the new suggestions, and do not omit "Before/after difference (does not show causation)" or "The starting point is the time the application was detected". Do not rephrase "No comparison data" as a difference of 0.
28
+ - If the exit code is anything other than 0 or 3, finish without making suggestions. The same applies when the message says `harnessforce` was not found.
29
+ - If there is a "Not enough data, so no suggestions are made" line, show that line and finish without making suggestions.
30
+
31
+ ## 3. Make suggestions
32
+
33
+ Show all the "Targets for suggestions" lines. Show the "Not enough data" and "not measured, so no suggestion is made" lines as they are, including what is still needed, and make no suggestion for those targets.
34
+
35
+ For the targets marked "a suggestion can be made", make suggestions by following the `propose-improvements` skill of this plugin, record them with `harnessforce tune record`, and then show them. Do not show a suggestion whose recording did not end with exit code 0.
36
+
37
+ ## 4. Explain how to apply
38
+
39
+ Finally, tell the user that applying the suggestions is up to the user. They apply them by editing by hand, running `git apply`, or telling the agent in their own session to apply them. This command does not apply them. A suggestion that was applied is detected in the next run of `/harnessforce:tune`, and only counts are sent to Harnessforce.