harness-everything 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.
- package/AGENTS.md +2 -0
- package/BENCHMARK_SOP.md +62 -0
- package/CHANGELOG.md +107 -0
- package/Dockerfile +18 -0
- package/LICENSE +201 -0
- package/README.md +197 -0
- package/VERIFICATION.md +347 -0
- package/bin/cli.js +97 -0
- package/build-multi-agent-system/AGENTS.md +50 -0
- package/build-multi-agent-system/README.md +63 -0
- package/build-multi-agent-system/SKILL.md +68 -0
- package/create-agent-launcher/SKILL.md +48 -0
- package/create-agent-launcher/examples/csharp-monorepo.md +123 -0
- package/create-agent-launcher/examples/typescript-cli.md +126 -0
- package/create-agent-launcher/guidelines/platform-claude.md +77 -0
- package/create-agent-launcher/guidelines/platform-codex.md +146 -0
- package/create-agent-launcher/guidelines/platform-copilot.md +74 -0
- package/create-agent-launcher/guidelines/platform-gemini.md +101 -0
- package/create-agent-launcher/guidelines/role-capabilities.md +108 -0
- package/create-agent-launcher/templates/README.md +17 -0
- package/create-agent-launcher/templates/agent-launcher.md +68 -0
- package/create-agent-launcher/templates/backend-developer-csharp.md +56 -0
- package/create-agent-launcher/templates/backend-developer-polyglot.md +62 -0
- package/create-agent-launcher/templates/backend-developer-ts.md +57 -0
- package/create-agent-launcher/templates/memory-keeper.md +37 -0
- package/create-agent-launcher/templates/requirement-analyzer.md +66 -0
- package/create-agent-launcher/templates/specialist-agent.md +34 -0
- package/create-agent-launcher/templates/task-verifier.md +56 -0
- package/create-agent-launcher/templates/tool-maker.md +33 -0
- package/create-agent-launcher/workflows/01-init.md +22 -0
- package/create-agent-launcher/workflows/02-analysis.md +26 -0
- package/create-agent-launcher/workflows/03-generation.md +29 -0
- package/create-agent-launcher/workflows/04-launcher.md +20 -0
- package/docker-verify.sh +266 -0
- package/docs/architecture.md +95 -0
- package/docs/philosophy.md +45 -0
- package/docs/reflection.md +34 -0
- package/docs/routing.md +45 -0
- package/docs/workflows/build-multi-agent-system.md +62 -0
- package/docs/workflows/create-agent-launcher.md +62 -0
- package/docs/workflows/environment-detection.md +63 -0
- package/docs/workflows/eval-harness.md +57 -0
- package/docs/workflows/fable-discipline.md +59 -0
- package/docs/workflows/fable-mode.md +32 -0
- package/docs/workflows/git-commit.md +62 -0
- package/docs/workflows/grill-me.md +62 -0
- package/docs/workflows/grill-with-docs.md +62 -0
- package/docs/workflows/harness-everything.md +92 -0
- package/docs/workflows/improve-codebase-architecture.md +60 -0
- package/docs/workflows/install-cognitive-os.md +60 -0
- package/docs/workflows/repo-docs.md +59 -0
- package/docs/workflows/rewrite-commits.md +60 -0
- package/docs/workflows/security-review.md +58 -0
- package/docs/workflows/self-evolve.md +59 -0
- package/docs/workflows/skill-creator.md +75 -0
- package/docs/workflows/skill-style.md +64 -0
- package/docs/workflows/tdd.md +39 -0
- package/docs/workflows/todo-driven-workflow.md +36 -0
- package/docs/workflows/using-git-worktrees.md +63 -0
- package/docs/workflows/verification-loop.md +69 -0
- package/docs/workflows/verify-before-claim.md +60 -0
- package/docs/workflows/zoom-out.md +62 -0
- package/environment-detection/SKILL.md +77 -0
- package/environment-detection/scripts/preflight.js +93 -0
- package/eval-framework/behavioral-test.js +105 -0
- package/eval-framework/cases/case1.json +5 -0
- package/eval-framework/cases/case2.json +5 -0
- package/eval-framework/cases/case3.json +5 -0
- package/eval-framework/cases/case4-zh-tier2.json +5 -0
- package/eval-framework/cases/case5-zh-tier3.json +5 -0
- package/eval-framework/mechanism-test.js +251 -0
- package/eval-framework/runner.js +56 -0
- package/eval-harness/SKILL.md +59 -0
- package/eval-harness/scripts/evaluate.js +61 -0
- package/fable-discipline/SKILL.md +38 -0
- package/fable-mode/CONTRACT-FORMAT.md +51 -0
- package/fable-mode/SKILL.md +51 -0
- package/fable-mode/agents/fable-orchestrator.md +92 -0
- package/fable-mode/agents/fable-verifier.md +32 -0
- package/fable-mode/agents/fable-worker-haiku.md +48 -0
- package/fable-mode/agents/fable-worker-sonnet.md +49 -0
- package/fable-mode/execution-guardrails/SKILL.md +87 -0
- package/fable-mode/fable-haiku/SKILL.md +48 -0
- package/git-commit/SKILL.md +55 -0
- package/git-commit/guides/ANGULAR_STYLE.md +61 -0
- package/git-commit/guides/COMMIT_GENERATION.md +24 -0
- package/git-commit/guides/LANGUAGE_DETECTION.md +16 -0
- package/git-commit/guides/MAIN_REPO.md +15 -0
- package/git-commit/guides/SUBMODULES.md +27 -0
- package/grill-me/SKILL.md +36 -0
- package/grill-with-docs/ADR-FORMAT.md +47 -0
- package/grill-with-docs/CONTEXT-FORMAT.md +63 -0
- package/grill-with-docs/SKILL.md +99 -0
- package/harness-everything/SKILL.md +141 -0
- package/harness-everything/examples/README.md +9 -0
- package/harness-everything/examples/todo-workflow.md +22 -0
- package/harness-everything/scripts/bootstrap.js +140 -0
- package/harness-everything/scripts/self-heal.js +189 -0
- package/harness-everything/scripts/tier-router.js +219 -0
- package/harness-everything/scripts/todo-cli.js +157 -0
- package/harness-everything/scripts/verify-gate.js +31 -0
- package/hooks/hooks.json +155 -0
- package/hooks/scripts/atomic-commit-check.js +68 -0
- package/hooks/scripts/boundary-guard.js +55 -0
- package/hooks/scripts/context-compact.js +114 -0
- package/hooks/scripts/contract-test.js +79 -0
- package/hooks/scripts/depth-guard.js +65 -0
- package/hooks/scripts/lib/harness-state.js +202 -0
- package/hooks/scripts/lib/platforms/claude.js +42 -0
- package/hooks/scripts/lib/platforms/codex.js +46 -0
- package/hooks/scripts/lib/platforms/continue.js +41 -0
- package/hooks/scripts/lib/platforms/copilot.js +41 -0
- package/hooks/scripts/lib/platforms/cursor.js +41 -0
- package/hooks/scripts/lib/platforms/hermes.js +32 -0
- package/hooks/scripts/lib/platforms/index.js +17 -0
- package/hooks/scripts/lib/platforms/worktrees.js +20 -0
- package/hooks/scripts/reset-circuit-breaker.js +30 -0
- package/hooks/scripts/rule-of-3-tracker.js +91 -0
- package/hooks/scripts/rule-of-3.js +176 -0
- package/hooks/scripts/state-persist.js +99 -0
- package/hooks/scripts/stop-gate.js +80 -0
- package/hooks/scripts/subagent-scope-guard.js +88 -0
- package/improve-codebase-architecture/SKILL.md +44 -0
- package/improve-codebase-architecture/guides/DEEPENING.md +37 -0
- package/improve-codebase-architecture/guides/HTML-REPORT.md +123 -0
- package/improve-codebase-architecture/guides/INTERFACE-DESIGN.md +44 -0
- package/improve-codebase-architecture/guides/LANGUAGE.md +53 -0
- package/install-cognitive-os/SKILL.md +95 -0
- package/package.json +22 -0
- package/repo-docs/SKILL.md +45 -0
- package/repo-docs/templates/agents-template.md +264 -0
- package/repo-docs/templates/knowledge-agents-template.md +50 -0
- package/repo-docs/templates/knowledge-readme-template.md +83 -0
- package/repo-docs/templates/manual-recon.md +117 -0
- package/repo-docs/templates/multi-skills-readme-template.md +72 -0
- package/repo-docs/templates/product-agents-template.md +78 -0
- package/repo-docs/templates/product-readme-template.md +95 -0
- package/repo-docs/templates/readme-template.md +136 -0
- package/repo-docs/templates/single-skill-readme-template.md +70 -0
- package/repo-docs/templates/skills-agents-template.md +60 -0
- package/rewrite-commits/SKILL.md +32 -0
- package/scripts/installer.js +649 -0
- package/scripts/lib/advisory-text.js +163 -0
- package/scripts/lib/claude-hooks.js +71 -0
- package/scripts/lib/gitignore.js +58 -0
- package/scripts/lib/manifest.js +82 -0
- package/scripts/lib/prompts.js +241 -0
- package/scripts/lib/skills.js +172 -0
- package/scripts/lib/workspace.js +28 -0
- package/security-review/SKILL.md +511 -0
- package/self-evolve/SKILL.md +54 -0
- package/self-evolve/scripts/persist-memory.js +40 -0
- package/self-evolve/scripts/self-regression.js +113 -0
- package/skill-creator/SKILL.md +91 -0
- package/skill-creator/references/quality-principles.md +81 -0
- package/skill-creator/references/testing-workflow.md +32 -0
- package/skill-style/SKILL.md +48 -0
- package/skill-style/STYLE.md +37 -0
- package/tdd/SKILL.md +53 -0
- package/tdd/guides/deep-modules.md +33 -0
- package/tdd/guides/interface-design.md +31 -0
- package/tdd/guides/mocking.md +59 -0
- package/tdd/guides/refactoring.md +10 -0
- package/tdd/guides/tests.md +61 -0
- package/todo-driven-workflow/SKILL.md +54 -0
- package/using-git-worktrees/SKILL.md +161 -0
- package/verification-loop/SKILL.md +138 -0
- package/verify-before-claim/SKILL.md +86 -0
- package/zoom-out/SKILL.md +90 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Interface Design for Testability
|
|
2
|
+
|
|
3
|
+
Good interfaces make testing natural:
|
|
4
|
+
|
|
5
|
+
1. **Accept dependencies, don't create them**
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
// Testable
|
|
9
|
+
function processOrder(order, paymentGateway) {}
|
|
10
|
+
|
|
11
|
+
// Hard to test
|
|
12
|
+
function processOrder(order) {
|
|
13
|
+
const gateway = new StripeGateway();
|
|
14
|
+
}
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
2. **Return results, don't produce side effects**
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
// Testable
|
|
21
|
+
function calculateDiscount(cart): Discount {}
|
|
22
|
+
|
|
23
|
+
// Hard to test
|
|
24
|
+
function applyDiscount(cart): void {
|
|
25
|
+
cart.total -= discount;
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
3. **Small surface area**
|
|
30
|
+
- Fewer methods = fewer tests needed
|
|
31
|
+
- Fewer params = simpler test setup
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# When to Mock
|
|
2
|
+
|
|
3
|
+
Mock at **system boundaries** only:
|
|
4
|
+
|
|
5
|
+
- External APIs (payment, email, etc.)
|
|
6
|
+
- Databases (sometimes - prefer test DB)
|
|
7
|
+
- Time/randomness
|
|
8
|
+
- File system (sometimes)
|
|
9
|
+
|
|
10
|
+
Don't mock:
|
|
11
|
+
|
|
12
|
+
- Your own classes/modules
|
|
13
|
+
- Internal collaborators
|
|
14
|
+
- Anything you control
|
|
15
|
+
|
|
16
|
+
## Designing for Mockability
|
|
17
|
+
|
|
18
|
+
At system boundaries, design interfaces that are easy to mock:
|
|
19
|
+
|
|
20
|
+
**1. Use dependency injection**
|
|
21
|
+
|
|
22
|
+
Pass external dependencies in rather than creating them internally:
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
// Easy to mock
|
|
26
|
+
function processPayment(order, paymentClient) {
|
|
27
|
+
return paymentClient.charge(order.total);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Hard to mock
|
|
31
|
+
function processPayment(order) {
|
|
32
|
+
const client = new StripeClient(process.env.STRIPE_KEY);
|
|
33
|
+
return client.charge(order.total);
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**2. Prefer SDK-style interfaces over generic fetchers**
|
|
38
|
+
|
|
39
|
+
Create specific functions for each external operation instead of one generic function with conditional logic:
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
// GOOD: Each function is independently mockable
|
|
43
|
+
const api = {
|
|
44
|
+
getUser: (id) => fetch(`/users/${id}`),
|
|
45
|
+
getOrders: (userId) => fetch(`/users/${userId}/orders`),
|
|
46
|
+
createOrder: (data) => fetch('/orders', { method: 'POST', body: data }),
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// BAD: Mocking requires conditional logic inside the mock
|
|
50
|
+
const api = {
|
|
51
|
+
fetch: (endpoint, options) => fetch(endpoint, options),
|
|
52
|
+
};
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The SDK approach means:
|
|
56
|
+
- Each mock returns one specific shape
|
|
57
|
+
- No conditional logic in test setup
|
|
58
|
+
- Easier to see which endpoints a test exercises
|
|
59
|
+
- Type safety per endpoint
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Refactor Candidates
|
|
2
|
+
|
|
3
|
+
After TDD cycle, look for:
|
|
4
|
+
|
|
5
|
+
- **Duplication** → Extract function/class
|
|
6
|
+
- **Long methods** → Break into private helpers (keep tests on public interface)
|
|
7
|
+
- **Shallow modules** → Combine or deepen
|
|
8
|
+
- **Feature envy** → Move logic to where data lives
|
|
9
|
+
- **Primitive obsession** → Introduce value objects
|
|
10
|
+
- **Existing code** the new code reveals as problematic
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Good and Bad Tests
|
|
2
|
+
|
|
3
|
+
## Good Tests
|
|
4
|
+
|
|
5
|
+
**Integration-style**: Test through real interfaces, not mocks of internal parts.
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
// GOOD: Tests observable behavior
|
|
9
|
+
test("user can checkout with valid cart", async () => {
|
|
10
|
+
const cart = createCart();
|
|
11
|
+
cart.add(product);
|
|
12
|
+
const result = await checkout(cart, paymentMethod);
|
|
13
|
+
expect(result.status).toBe("confirmed");
|
|
14
|
+
});
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Characteristics:
|
|
18
|
+
|
|
19
|
+
- Tests behavior users/callers care about
|
|
20
|
+
- Uses public API only
|
|
21
|
+
- Survives internal refactors
|
|
22
|
+
- Describes WHAT, not HOW
|
|
23
|
+
- One logical assertion per test
|
|
24
|
+
|
|
25
|
+
## Bad Tests
|
|
26
|
+
|
|
27
|
+
**Implementation-detail tests**: Coupled to internal structure.
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
// BAD: Tests implementation details
|
|
31
|
+
test("checkout calls paymentService.process", async () => {
|
|
32
|
+
const mockPayment = jest.mock(paymentService);
|
|
33
|
+
await checkout(cart, payment);
|
|
34
|
+
expect(mockPayment.process).toHaveBeenCalledWith(cart.total);
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Red flags:
|
|
39
|
+
|
|
40
|
+
- Mocking internal collaborators
|
|
41
|
+
- Testing private methods
|
|
42
|
+
- Asserting on call counts/order
|
|
43
|
+
- Test breaks when refactoring without behavior change
|
|
44
|
+
- Test name describes HOW not WHAT
|
|
45
|
+
- Verifying through external means instead of interface
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
// BAD: Bypasses interface to verify
|
|
49
|
+
test("createUser saves to database", async () => {
|
|
50
|
+
await createUser({ name: "Alice" });
|
|
51
|
+
const row = await db.query("SELECT * FROM users WHERE name = ?", ["Alice"]);
|
|
52
|
+
expect(row).toBeDefined();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// GOOD: Verifies through interface
|
|
56
|
+
test("createUser makes user retrievable", async () => {
|
|
57
|
+
const user = await createUser({ name: "Alice" });
|
|
58
|
+
const retrieved = await getUser(user.id);
|
|
59
|
+
expect(retrieved.name).toBe("Alice");
|
|
60
|
+
});
|
|
61
|
+
```
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: todo-driven-workflow
|
|
3
|
+
description: Enforces a deliberate, step-by-step execution loop.
|
|
4
|
+
author: Miya Daniel | Harness Core Team
|
|
5
|
+
version: 1.1.0
|
|
6
|
+
metadata:
|
|
7
|
+
type: harness-discipline
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Todo-Driven Workflow (以 TODO 驅動的自動化工作流)
|
|
11
|
+
|
|
12
|
+
## 📋 Skill Contract
|
|
13
|
+
|
|
14
|
+
| Component | Specification |
|
|
15
|
+
| :--- | :--- |
|
|
16
|
+
| **Trigger / Input** | Tier 2/3 Task Identification. Input: High-level task description. |
|
|
17
|
+
| **Expected Output** | Granular execution state. A series of terminal calls to `todo-cli.js`. |
|
|
18
|
+
| **State Mutations** | MUST write to `.claude/harness-state/todo-state.json` via CLI. |
|
|
19
|
+
| **Enforcement Gate** | `node harness-everything/scripts/todo-cli.js`. Exits with Code 1 if multitasking, bypassing initialization, or skipping `verify-gate.js`. |
|
|
20
|
+
|
|
21
|
+
This skill enforces a disciplined execution loop. It prevents "hallucinated progress" by forcing the Agent to track exact state and prove completion before moving to the next step.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## ⚡ Core Trigger (觸發時機)
|
|
26
|
+
This workflow is **the default operating behavior** for any complex, multi-step, or multi-file development tasks (Tier 2 and Tier 3).
|
|
27
|
+
|
|
28
|
+
## ⚙️ Execution Method
|
|
29
|
+
|
|
30
|
+
| Environment | Primary Task Tracker | Implementation Method |
|
|
31
|
+
| :--- | :--- | :--- |
|
|
32
|
+
| **All Environments** | `todo-cli.js` | You MUST use `node harness-everything/scripts/todo-cli.js` for all state transitions. Do NOT rely on prompt text. |
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## 🔄 Execution Loop: Think > Try > Summarize > Record
|
|
37
|
+
|
|
38
|
+
### 1. Analyze and Plan (Think)
|
|
39
|
+
Break the high-level goal into **3 to 7 concrete, verifiable sub-tasks**.
|
|
40
|
+
|
|
41
|
+
### 2. Initialize the Todo List (Record)
|
|
42
|
+
- **CRITICAL ACTION**: You MUST use the `run_in_terminal` tool to run `node harness-everything/scripts/todo-cli.js init "Task 1" "Task 2"` BEFORE modifying any code.
|
|
43
|
+
- *Rule*: The terminal output will confirm the list is initialized.
|
|
44
|
+
|
|
45
|
+
### 3. Step-by-Step Execution
|
|
46
|
+
1. **Start**: Use `run_in_terminal` to run `node harness-everything/scripts/todo-cli.js start <id>`. **If you try to start two tasks, the script will crash and block you.**
|
|
47
|
+
2. **Execute**: Perform the necessary actions (read files, grep, run terminal commands, edit files).
|
|
48
|
+
3. **Verify**: The validation gate is hardcoded into the completion step.
|
|
49
|
+
4. **Complete**: Use `run_in_terminal` to run `node harness-everything/scripts/todo-cli.js complete <id>`. If the internal `verify-gate.js` check fails, this command will Exit 1 and block you.
|
|
50
|
+
|
|
51
|
+
### 4. Handling Blocker Failures (Dynamic Adaptation)
|
|
52
|
+
If a step fails:
|
|
53
|
+
- Use `node harness-everything/scripts/todo-cli.js add "Fix specific error"` to insert a blocker.
|
|
54
|
+
- Do NOT silently ignore or bypass the error.
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: using-git-worktrees
|
|
3
|
+
description: Use when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback
|
|
4
|
+
author: Miya Daniel | Harness Core Team
|
|
5
|
+
version: 0.2.0
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Using Git Worktrees
|
|
9
|
+
|
|
10
|
+
## 📋 Skill Contract
|
|
11
|
+
|
|
12
|
+
| Component | Specification |
|
|
13
|
+
| :--- | :--- |
|
|
14
|
+
| **Trigger / Input** | Starting feature work that needs isolation from the current workspace, or before executing an implementation plan. |
|
|
15
|
+
| **Expected Output** | An isolated workspace (native worktree tool preferred, `git worktree add` fallback) with dependencies installed and a clean baseline test run confirmed. |
|
|
16
|
+
| **State Mutations** | May create a new worktree directory/branch (`.worktrees/<branch>` by default) and add it to `.gitignore` if not already ignored. |
|
|
17
|
+
| **Enforcement Gate** | **MUST** detect an already-isolated workspace first (`GIT_DIR != GIT_COMMON`, excluding submodules) and skip creating a redundant one. **MUST** verify the worktree directory is gitignored before creating it. **MUST** get human consent before creating a new worktree if no preference was already declared. |
|
|
18
|
+
|
|
19
|
+
## Overview
|
|
20
|
+
|
|
21
|
+
Ensure work happens in an isolated workspace. Prefer your platform's native worktree tools. Fall back to manual git worktrees only when no native tool is available.
|
|
22
|
+
|
|
23
|
+
**Core principle:** Detect existing isolation first. Then use native tools. Then fall back to git. Never fight the harness.
|
|
24
|
+
|
|
25
|
+
**Announce at start:** "I'm using the using-git-worktrees skill to set up an isolated workspace."
|
|
26
|
+
|
|
27
|
+
## Step 0: Detect Existing Isolation
|
|
28
|
+
|
|
29
|
+
**Before creating anything, check if you are already in an isolated workspace.**
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
GIT_DIR=$(cd "$(git rev-parse --git-dir)" 2>/dev/null && pwd -P)
|
|
33
|
+
GIT_COMMON=$(cd "$(git rev-parse --git-common-dir)" 2>/dev/null && pwd -P)
|
|
34
|
+
BRANCH=$(git branch --show-current)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Submodule guard:** `GIT_DIR != GIT_COMMON` is also true inside git submodules. Before concluding "already in a worktree," verify you are not in a submodule:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
# If this returns a path, you're in a submodule, not a worktree — treat as normal repo
|
|
41
|
+
git rev-parse --show-superproject-working-tree 2>/dev/null
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**If `GIT_DIR != GIT_COMMON` (and not a submodule):** You are already in a linked worktree. Skip to Step 2 (Project Setup). Do NOT create another worktree.
|
|
45
|
+
|
|
46
|
+
Report with branch state:
|
|
47
|
+
- On a branch: "Already in isolated workspace at `<path>` on branch `<name>`."
|
|
48
|
+
- Detached HEAD: "Already in isolated workspace at `<path>` (detached HEAD, externally managed). Branch creation needed at finish time."
|
|
49
|
+
|
|
50
|
+
**If `GIT_DIR == GIT_COMMON` (or in a submodule):** You are in a normal repo checkout.
|
|
51
|
+
|
|
52
|
+
Has the user already indicated their worktree preference in your instructions? If not, ask for consent before creating a worktree:
|
|
53
|
+
|
|
54
|
+
> "Would you like me to set up an isolated worktree? It protects your current branch from changes."
|
|
55
|
+
|
|
56
|
+
Honor any existing declared preference without asking. If the user declines consent, work in place and skip to Step 2.
|
|
57
|
+
|
|
58
|
+
## Step 1: Create Isolated Workspace
|
|
59
|
+
|
|
60
|
+
**You have two mechanisms. Try them in this order.**
|
|
61
|
+
|
|
62
|
+
### 1a. Native Worktree Tools (preferred)
|
|
63
|
+
|
|
64
|
+
The user has asked for an isolated workspace (Step 0 consent). Do you already have a way to create a worktree? It might be a tool with a name like `EnterWorktree`, `WorktreeCreate`, a `/worktree` command, or a `--worktree` flag. If you do, use it and skip to Step 2.
|
|
65
|
+
|
|
66
|
+
Native tools handle directory placement, branch creation, and cleanup automatically. Using `git worktree add` when you have a native tool creates phantom state your harness can't see or manage.
|
|
67
|
+
|
|
68
|
+
Only proceed to Step 1b if you have no native worktree tool available.
|
|
69
|
+
|
|
70
|
+
### 1b. Git Worktree Fallback
|
|
71
|
+
|
|
72
|
+
**Only use this if Step 1a does not apply** — you have no native worktree tool available. Create a worktree manually using git.
|
|
73
|
+
|
|
74
|
+
#### Directory Selection
|
|
75
|
+
|
|
76
|
+
Follow this priority order. Explicit user preference always beats observed filesystem state.
|
|
77
|
+
|
|
78
|
+
1. **Check your instructions for a declared worktree directory preference.** If the user has already specified one, use it without asking.
|
|
79
|
+
|
|
80
|
+
2. **Check for an existing project-local worktree directory:**
|
|
81
|
+
```bash
|
|
82
|
+
ls -d .worktrees 2>/dev/null # Preferred (hidden)
|
|
83
|
+
ls -d worktrees 2>/dev/null # Alternative
|
|
84
|
+
```
|
|
85
|
+
If found, use it. If both exist, `.worktrees` wins.
|
|
86
|
+
|
|
87
|
+
3. **If there is no other guidance available**, default to `.worktrees/` at the project root.
|
|
88
|
+
|
|
89
|
+
#### Safety Verification (project-local directories only)
|
|
90
|
+
|
|
91
|
+
**MUST verify directory is ignored before creating worktree:**
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
git check-ignore -q .worktrees 2>/dev/null || git check-ignore -q worktrees 2>/dev/null
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**If NOT ignored:** Add to .gitignore, commit the change, then proceed.
|
|
98
|
+
|
|
99
|
+
**Why critical:** Prevents accidentally committing worktree contents to repository.
|
|
100
|
+
|
|
101
|
+
#### Create the Worktree
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
# Determine path based on chosen location
|
|
105
|
+
path="$LOCATION/$BRANCH_NAME"
|
|
106
|
+
|
|
107
|
+
git worktree add "$path" -b "$BRANCH_NAME"
|
|
108
|
+
cd "$path"
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
**Sandbox fallback:** If `git worktree add` fails with a permission error (sandbox denial), tell the user the sandbox blocked worktree creation and you're working in the current directory instead. Then run setup and baseline tests in place.
|
|
112
|
+
|
|
113
|
+
## Step 2: Project Setup
|
|
114
|
+
|
|
115
|
+
Auto-detect and run appropriate setup:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
# Node.js
|
|
119
|
+
if [ -f package.json ]; then npm install; fi
|
|
120
|
+
|
|
121
|
+
# Rust
|
|
122
|
+
if [ -f Cargo.toml ]; then cargo build; fi
|
|
123
|
+
|
|
124
|
+
# Python
|
|
125
|
+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
|
126
|
+
if [ -f pyproject.toml ]; then poetry install; fi
|
|
127
|
+
|
|
128
|
+
# Go
|
|
129
|
+
if [ -f go.mod ]; then go mod download; fi
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Step 3: Verify Clean Baseline
|
|
133
|
+
|
|
134
|
+
Run tests to ensure workspace starts clean:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
# Use project-appropriate command
|
|
138
|
+
npm test / cargo test / pytest / go test ./...
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
**If tests fail:** Report failures, ask whether to proceed or investigate.
|
|
142
|
+
|
|
143
|
+
**If tests pass:** Report ready.
|
|
144
|
+
|
|
145
|
+
### Report
|
|
146
|
+
|
|
147
|
+
```
|
|
148
|
+
Worktree ready at <full-path>
|
|
149
|
+
Tests passing (<N> tests, 0 failures)
|
|
150
|
+
Ready to implement <feature-name>
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Quick Reference
|
|
154
|
+
|
|
155
|
+
| Situation | Action |
|
|
156
|
+
|-----------|--------|
|
|
157
|
+
| Already in linked worktree | Skip creation (Step 0) |
|
|
158
|
+
| In a submodule | Treat as normal repo (Step 0 guard) |
|
|
159
|
+
| Native worktree tool available | Use it (Step 1a) |
|
|
160
|
+
| No native tool | Git worktree fallback (Step 1b) |
|
|
161
|
+
| `.worktrees/` exists | Use it (verify ignored) |
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: verification-loop
|
|
3
|
+
description: "A comprehensive verification system for Claude Code sessions."
|
|
4
|
+
author: Miya Daniel | Harness Core Team
|
|
5
|
+
version: 0.2.0
|
|
6
|
+
metadata:
|
|
7
|
+
origin: ECC
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Verification Loop Skill
|
|
11
|
+
|
|
12
|
+
## 📋 Skill Contract
|
|
13
|
+
|
|
14
|
+
| Component | Specification |
|
|
15
|
+
| :--- | :--- |
|
|
16
|
+
| **Trigger / Input** | Approaching task completion or PR creation. Input: The modified project files. |
|
|
17
|
+
| **Expected Output** | Terminal logs showing successful Build, Type Check, Lint, and Test execution. |
|
|
18
|
+
| **State Mutations** | None. Pure verification. |
|
|
19
|
+
| **Enforcement Gate** | You MUST execute `npm run build`, `npm run lint`, and `npm run test` (or equivalent). You cannot complete the task if any of these return Exit Code 1. |
|
|
20
|
+
|
|
21
|
+
A comprehensive verification system for Claude Code sessions.
|
|
22
|
+
|
|
23
|
+
## When to Use
|
|
24
|
+
|
|
25
|
+
Invoke this skill:
|
|
26
|
+
- After completing a feature or significant code change
|
|
27
|
+
- Before creating a PR
|
|
28
|
+
- When you want to ensure quality gates pass
|
|
29
|
+
- After refactoring
|
|
30
|
+
|
|
31
|
+
## Verification Phases
|
|
32
|
+
|
|
33
|
+
### Phase 1: Build Verification
|
|
34
|
+
```bash
|
|
35
|
+
# Check if project builds
|
|
36
|
+
npm run build 2>&1 | tail -20
|
|
37
|
+
# OR
|
|
38
|
+
pnpm build 2>&1 | tail -20
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
If build fails, STOP and fix before continuing.
|
|
42
|
+
|
|
43
|
+
### Phase 2: Type Check
|
|
44
|
+
```bash
|
|
45
|
+
# TypeScript projects
|
|
46
|
+
npx tsc --noEmit 2>&1 | head -30
|
|
47
|
+
|
|
48
|
+
# Python projects
|
|
49
|
+
pyright . 2>&1 | head -30
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Report all type errors. Fix critical ones before continuing.
|
|
53
|
+
|
|
54
|
+
### Phase 3: Lint Check
|
|
55
|
+
```bash
|
|
56
|
+
# JavaScript/TypeScript
|
|
57
|
+
npm run lint 2>&1 | head -30
|
|
58
|
+
|
|
59
|
+
# Python
|
|
60
|
+
ruff check . 2>&1 | head -30
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Phase 4: Test Suite
|
|
64
|
+
```bash
|
|
65
|
+
# Run tests with coverage
|
|
66
|
+
npm run test -- --coverage 2>&1 | tail -50
|
|
67
|
+
|
|
68
|
+
# Check coverage threshold
|
|
69
|
+
# Target: 80% minimum
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Report:
|
|
73
|
+
- Total tests: X
|
|
74
|
+
- Passed: X
|
|
75
|
+
- Failed: X
|
|
76
|
+
- Coverage: X%
|
|
77
|
+
|
|
78
|
+
### Phase 5: Security Scan
|
|
79
|
+
```bash
|
|
80
|
+
# Check for secrets
|
|
81
|
+
grep -rn "sk-" --include="*.ts" --include="*.js" . 2>/dev/null | head -10
|
|
82
|
+
grep -rn "api_key" --include="*.ts" --include="*.js" . 2>/dev/null | head -10
|
|
83
|
+
|
|
84
|
+
# Check for console.log
|
|
85
|
+
grep -rn "console.log" --include="*.ts" --include="*.tsx" src/ 2>/dev/null | head -10
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Phase 6: Diff Review
|
|
89
|
+
```bash
|
|
90
|
+
# Show what changed
|
|
91
|
+
git diff --stat
|
|
92
|
+
git diff HEAD~1 --name-only
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Review each changed file for:
|
|
96
|
+
- Unintended changes
|
|
97
|
+
- Missing error handling
|
|
98
|
+
- Potential edge cases
|
|
99
|
+
|
|
100
|
+
## Output Format
|
|
101
|
+
|
|
102
|
+
After running all phases, produce a verification report:
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
VERIFICATION REPORT
|
|
106
|
+
==================
|
|
107
|
+
|
|
108
|
+
Build: [PASS/FAIL]
|
|
109
|
+
Types: [PASS/FAIL] (X errors)
|
|
110
|
+
Lint: [PASS/FAIL] (X warnings)
|
|
111
|
+
Tests: [PASS/FAIL] (X/Y passed, Z% coverage)
|
|
112
|
+
Security: [PASS/FAIL] (X issues)
|
|
113
|
+
Diff: [X files changed]
|
|
114
|
+
|
|
115
|
+
Overall: [READY/NOT READY] for PR
|
|
116
|
+
|
|
117
|
+
Issues to Fix:
|
|
118
|
+
1. ...
|
|
119
|
+
2. ...
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Continuous Mode
|
|
123
|
+
|
|
124
|
+
For long sessions, run verification every 15 minutes or after major changes:
|
|
125
|
+
|
|
126
|
+
```markdown
|
|
127
|
+
Set a mental checkpoint:
|
|
128
|
+
- After completing each function
|
|
129
|
+
- After finishing a component
|
|
130
|
+
- Before moving to next task
|
|
131
|
+
|
|
132
|
+
Run: /verify
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Integration with Hooks
|
|
136
|
+
|
|
137
|
+
This skill complements PostToolUse hooks but provides deeper verification.
|
|
138
|
+
Hooks catch issues immediately; this skill provides comprehensive review.
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: verify-before-claim
|
|
3
|
+
description: "Verify external framework/API claims and unmeasured perf/cost estimates against an authoritative source before asserting them, instead of answering from training memory."
|
|
4
|
+
author: Miya Daniel | Harness Core Team
|
|
5
|
+
version: 0.2.0
|
|
6
|
+
metadata:
|
|
7
|
+
type: harness-discipline
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Verify Before Claim
|
|
11
|
+
|
|
12
|
+
## 📋 Skill Contract
|
|
13
|
+
|
|
14
|
+
| Component | Specification |
|
|
15
|
+
| :--- | :--- |
|
|
16
|
+
| **Trigger / Input** | About to state how an external system (framework/library/SDK/API/service) currently behaves, or about to state an unmeasured performance/cost/timing number. |
|
|
17
|
+
| **Expected Output** | The claim is backed by a `WebFetch`/`WebSearch`-sourced quote from authoritative docs, or an actual measurement — never asserted from training memory alone. |
|
|
18
|
+
| **State Mutations** | None — this is a discipline governing what gets asserted in the response, not a file-mutating skill. |
|
|
19
|
+
| **Enforcement Gate** | An external-behavior claim without a same-session fetch/search backing it **MUST NOT** be asserted with confidence; an unmeasured number **MUST** be explicitly labeled as an estimate, not presented as fact. |
|
|
20
|
+
|
|
21
|
+
Training memory goes stale and is easy to misremember with full confidence.
|
|
22
|
+
This skill exists because that failure mode is real and already happened in
|
|
23
|
+
this repo: an early claim that `rule-of-3.js`'s `process.exit(1)` blocked a
|
|
24
|
+
Claude Code `PreToolUse` hook was wrong — the official docs say only
|
|
25
|
+
`exit(2)` blocks, `exit(1)` is a non-blocking error — and it was only caught
|
|
26
|
+
by actually fetching `code.claude.com/docs/en/hooks` instead of trusting the
|
|
27
|
+
assumption. The circuit breaker had never blocked anything until that got
|
|
28
|
+
checked.
|
|
29
|
+
|
|
30
|
+
`harness-everything/scripts/tier-router.js` fires a lightweight keyword-based
|
|
31
|
+
reminder for this automatically (`UserPromptSubmit`, "FACT-AUDIT REMINDER"
|
|
32
|
+
block) so you don't have to be manually pushed into checking every time. This
|
|
33
|
+
file is the actual discipline behind that reminder.
|
|
34
|
+
|
|
35
|
+
## TRIGGER — verify before asserting, don't skip because the answer "feels obvious"
|
|
36
|
+
|
|
37
|
+
Whenever either is true:
|
|
38
|
+
|
|
39
|
+
1. **You are about to state how an external system currently behaves** —
|
|
40
|
+
a framework, library, SDK, CLI tool, API, or service's schema, defaults,
|
|
41
|
+
exit codes, config flags, pricing, rate limits, version-specific behavior,
|
|
42
|
+
or "does X support Y." This includes cases that feel like common
|
|
43
|
+
knowledge — exit-code conventions, hook payload shapes, and default
|
|
44
|
+
values are exactly where confident misremembering happens.
|
|
45
|
+
2. **You are about to state a performance, cost, or timing number that
|
|
46
|
+
wasn't produced by an actual run in this session** — "this should take
|
|
47
|
+
~X," "this is O(n)," "this will cost about $Y," "this should be fast
|
|
48
|
+
enough." An estimate rendered with confidence is still an estimate.
|
|
49
|
+
|
|
50
|
+
## Procedure
|
|
51
|
+
|
|
52
|
+
- For claim (1): `WebFetch` the tool's official documentation first. If the
|
|
53
|
+
official docs don't cover it, `WebSearch` and cite what you find. Quote the
|
|
54
|
+
relevant part back rather than paraphrasing from memory — paraphrasing
|
|
55
|
+
reintroduces the same risk you're trying to avoid.
|
|
56
|
+
- For claim (2): if the stakes justify it (the number feeds a design
|
|
57
|
+
decision, a rejection/deferral, or something the user will act on),
|
|
58
|
+
actually run it — a real benchmark, a real timing, a real measurement —
|
|
59
|
+
instead of reasoning about what it "should" be. If running it isn't
|
|
60
|
+
feasible, say explicitly that the number is an unverified estimate; don't
|
|
61
|
+
present it with the same confidence as a measured fact.
|
|
62
|
+
- If a fetch or search comes back inconclusive or contradicts your prior
|
|
63
|
+
assumption, say so and show the source — don't quietly reconcile it into
|
|
64
|
+
something that sounds more confident than what you actually found.
|
|
65
|
+
|
|
66
|
+
## SKIP — don't over-trigger
|
|
67
|
+
|
|
68
|
+
- **The claim is about this repository's own code**, not an external system.
|
|
69
|
+
Reading the actual source here already is the authoritative check; no web
|
|
70
|
+
verification needed.
|
|
71
|
+
- **The user supplied the fact or number directly** in this conversation —
|
|
72
|
+
trust their firsthand statement, don't second-guess it with a search.
|
|
73
|
+
- **Already verified this session** — don't re-fetch the same source
|
|
74
|
+
redundantly if it was already checked earlier in this conversation and
|
|
75
|
+
nothing suggests it changed.
|
|
76
|
+
- **Generic, non-version-specific CS/engineering knowledge** (what a hash map
|
|
77
|
+
is, what Big-O notation means) — this isn't tied to any particular tool's
|
|
78
|
+
current implementation, so there's nothing to go stale.
|
|
79
|
+
|
|
80
|
+
## Why this is a skill, not just a hook
|
|
81
|
+
|
|
82
|
+
The `tier-router.js` reminder is a keyword net — cheap, broad, and it can
|
|
83
|
+
only nudge, not judge whether a specific sentence you're about to write is
|
|
84
|
+
actually an unverified claim. The judgment call is still yours: notice when
|
|
85
|
+
you're about to assert something you haven't actually checked this session,
|
|
86
|
+
regardless of whether a keyword happened to fire.
|