Add Harness Component
Add layers, documentation, components, or skills to an existing harness project with proper integration. Validate against existing constraints, wire into architecture, and verify the result.
When to Use
- Adding a new layer to the project's architecture
- Adding a new documentation file that harness should track
- Adding a new component (module, service, package) that must be wired into existing layer boundaries
- Adding a new skill to the project's skill library
- When a plan calls for introducing a new architectural boundary or module
- NOT when initializing a project from scratch (use harness-initialize-project)
- NOT when modifying an existing component (use standard editing workflows)
- NOT when removing components (manual process — removing requires careful dependency analysis)
Process
Phase 1: DETERMINE — Identify What to Add
Clarify the component type. Ask if not obvious from context:
- Layer: A new architectural boundary (e.g., adding an "infrastructure" layer to a project that only has "business" and "data")
- Document: A documentation file that harness should track for drift detection (e.g., API docs, architecture decision records)
- Component: A code module, service, or package that lives within an existing layer
- Skill: A new harness skill definition for the project's workflow
Gather requirements. For each type:
- Layer: Name, which directories belong to it, which layers it can import from, which layers can import from it
- Document: Path, what it documents, which code files it relates to
- Component: Name, which layer it belongs to, what it depends on, what will depend on it
- Skill: Name, purpose, type (rigid or flexible), triggers
Check prerequisites. The project must already be initialized with harness. If harness.config.json does not exist, stop and run harness-initialize-project first.
Phase 2: VALIDATE — Check Against Existing Constraints
Read the current configuration. Load harness.config.json and AGENTS.md to understand existing layers, constraints, and architecture.
Verify the new component does not conflict:
- Does the layer name already exist?
- Does the component directory already exist?
- Would the new dependency relationships create circular imports?
- Does the component violate any existing forbidden-import rules?
If conflicts are found, report them clearly: "Adding layer X would conflict with existing layer Y because [reason]. Options: [A] rename, [B] merge into existing layer, [C] restructure. Which do you prefer?"
Run harness check-deps on the current state to establish a clean baseline. If it already fails, fix existing violations before adding new components.
Phase 3: ADD — Create the Component
Run harness add with appropriate arguments:
- Layer:
harness add layer <name> --dirs <dir1,dir2> --imports <allowed-layers>
- Document:
harness add doc <path> --tracks <related-code-paths>
- Component:
harness add component <name> --layer <layer-name>
- Skill:
harness add skill <name> --type <rigid|flexible>
Review generated files and configuration changes. harness add modifies harness.config.json and may generate template files. Check that the changes look correct.
Create the actual code or content. harness add creates the configuration entry but not necessarily the implementation. Create the directories, files, and initial code as needed.
Phase 4: WIRE — Integrate into Architecture
Update imports and exports. If the new component needs to be imported by existing code, add the imports. If existing code needs to be aware of the new layer, update barrel files or index modules.
Update AGENTS.md. Add the new component to the architecture section. Document its purpose, boundaries, and relationships to other components. This keeps agent instructions accurate.
Update layer configuration if the new component changes dependency relationships. Ensure harness.config.json reflects the actual import graph.
For new skills: Write the skill.yaml and SKILL.md files following the harness skill format. Use harness-skill-authoring for guidance on writing good skill content.
Phase 5: VERIFY — Confirm Integration
Run harness validate to verify the full project configuration is still valid after the addition.
Run harness check-deps to verify no dependency violations were introduced. The new component's imports must respect layer boundaries.
Graph Refresh
If a knowledge graph exists at .harness/graph/, refresh it after code changes to keep graph queries accurate:
harness scan [path]
Skipping this step means subsequent graph queries (impact analysis, dependency health, test advisor) may return stale results.
If validation fails, fix the issues before committing. Common causes:
- New layer not properly registered in
harness.config.json
- Component placed in wrong directory for its declared layer
- Imports from forbidden layers
AGENTS.md references outdated architecture
Commit the addition. All new and modified files in a single atomic commit.
Harness Integration
harness add layer <name> — Register a new architectural layer with directory mappings and import rules.
harness add doc <path> — Register a documentation file for drift tracking.
harness add component <name> --layer <layer> — Register a new code component within an existing layer.
harness add skill <name> --type <type> — Scaffold a new skill definition.
harness validate — Verify project configuration after the addition.
harness check-deps — Verify dependency constraints are respected after the addition.
Success Criteria
- The new component is properly registered in
harness.config.json
- The component's files exist in the correct directories for its declared layer
AGENTS.md is updated to reflect the new component
harness validate passes after the addition
harness check-deps passes after the addition (no new violations)
- No circular dependencies were introduced
- The addition is committed as a single atomic commit
Rationalizations to Reject
| Rationalization |
Why It Is Wrong |
| "I will add the component and fix any constraint violations later" |
Phase 2 requires running harness check-deps for a clean baseline BEFORE adding. Phase 5 requires it to pass AFTER adding. |
| "AGENTS.md does not need updating for a small internal component" |
Phase 4 explicitly requires updating AGENTS.md for every new component. Without it, AI agents have no context. |
| "The new layer imports are obvious, so I do not need to check for circularity" |
Phase 2 checks whether new dependency relationships create circular imports. Circular dependencies are invisible until they cause runtime failures. |
| "I will commit the config change and the code separately for cleaner history" |
The success criteria require a single atomic commit. Splitting creates a window where config references a nonexistent component. |
Examples
Example: Adding a New Layer
Human: "We need an infrastructure layer for external API clients."
DETERMINE: Adding a layer. Name: infrastructure. Dirs: src/infrastructure/.
Imports from: (none — infrastructure is a leaf layer, no internal dependencies).
Imported by: business layer (services call external APIs through infrastructure).
VALIDATE:
Read harness.config.json — existing layers: presentation, business, data.
No conflict with "infrastructure" name.
Run: harness check-deps — passes (clean baseline).
ADD:
harness add layer infrastructure --dirs src/infrastructure --imports none
mkdir -p src/infrastructure
WIRE:
Update harness.config.json: allow business → infrastructure imports.
Update AGENTS.md: document infrastructure layer purpose and boundaries.
VERIFY:
harness validate # Pass
harness check-deps # Pass
git add harness.config.json AGENTS.md src/infrastructure/
git commit -m "feat: add infrastructure layer for external API clients"
Example: Adding a Document for Drift Tracking
Human: "Track our API specification for documentation drift."
DETERMINE: Adding a document. Path: docs/api-spec.md.
Tracks: src/routes/, src/models/response.ts.
ADD:
harness add doc docs/api-spec.md --tracks src/routes,src/models/response.ts
WIRE:
Update AGENTS.md: note that docs/api-spec.md is tracked for drift.
VERIFY:
harness validate # Pass
git add harness.config.json AGENTS.md
git commit -m "feat: track API spec for documentation drift detection"
Example: Adding a Component to an Existing Layer
Human: "Add a notification service to the business layer."
DETERMINE: Adding a component. Name: notification-service. Layer: business.
Depends on: data layer (notification repository). Depended on by: presentation layer (routes).
VALIDATE:
Read harness.config.json — business layer exists, maps to src/services/.
No existing notification-service directory.
business → data is an allowed import. Presentation → business is allowed.
Run: harness check-deps — passes.
ADD:
harness add component notification-service --layer business
Create src/services/notification-service.ts
Create src/services/notification-service.test.ts
WIRE:
Add export to src/services/index.ts (if barrel file exists).
Update AGENTS.md: add notification service to business layer component list.
VERIFY:
harness validate # Pass
harness check-deps # Pass
git add harness.config.json AGENTS.md src/services/notification-service.*
git commit -m "feat: add notification service to business layer"
1---2name: add-harness-component3description: Add Harness Component4---5# Add Harness Component67> Add layers, documentation, components, or skills to an existing harness project with proper integration. Validate against existing constraints, wire into architecture, and verify the result.89## When to Use1011- Adding a new layer to the project's architecture12- Adding a new documentation file that harness should track13- Adding a new component (module, service, package) that must be wired into existing layer boundaries14- Adding a new skill to the project's skill library15- When a plan calls for introducing a new architectural boundary or module16- NOT when initializing a project from scratch (use harness-initialize-project)17- NOT when modifying an existing component (use standard editing workflows)18- NOT when removing components (manual process — removing requires careful dependency analysis)1920## Process2122### Phase 1: DETERMINE — Identify What to Add23241. **Clarify the component type.** Ask if not obvious from context:25 - **Layer:** A new architectural boundary (e.g., adding an "infrastructure" layer to a project that only has "business" and "data")26 - **Document:** A documentation file that harness should track for drift detection (e.g., API docs, architecture decision records)27 - **Component:** A code module, service, or package that lives within an existing layer28 - **Skill:** A new harness skill definition for the project's workflow29302. **Gather requirements.** For each type:31 - **Layer:** Name, which directories belong to it, which layers it can import from, which layers can import from it32 - **Document:** Path, what it documents, which code files it relates to33 - **Component:** Name, which layer it belongs to, what it depends on, what will depend on it34 - **Skill:** Name, purpose, type (rigid or flexible), triggers35363. **Check prerequisites.** The project must already be initialized with harness. If `harness.config.json` does not exist, stop and run harness-initialize-project first.3738### Phase 2: VALIDATE — Check Against Existing Constraints39401. **Read the current configuration.** Load `harness.config.json` and `AGENTS.md` to understand existing layers, constraints, and architecture.41422. **Verify the new component does not conflict:**43 - Does the layer name already exist?44 - Does the component directory already exist?45 - Would the new dependency relationships create circular imports?46 - Does the component violate any existing forbidden-import rules?47483. **If conflicts are found,** report them clearly: "Adding layer X would conflict with existing layer Y because [reason]. Options: [A] rename, [B] merge into existing layer, [C] restructure. Which do you prefer?"49504. **Run `harness check-deps`** on the current state to establish a clean baseline. If it already fails, fix existing violations before adding new components.5152### Phase 3: ADD — Create the Component53541. **Run `harness add` with appropriate arguments:**55 - Layer: `harness add layer <name> --dirs <dir1,dir2> --imports <allowed-layers>`56 - Document: `harness add doc <path> --tracks <related-code-paths>`57 - Component: `harness add component <name> --layer <layer-name>`58 - Skill: `harness add skill <name> --type <rigid|flexible>`59602. **Review generated files and configuration changes.** `harness add` modifies `harness.config.json` and may generate template files. Check that the changes look correct.61623. **Create the actual code or content.** `harness add` creates the configuration entry but not necessarily the implementation. Create the directories, files, and initial code as needed.6364### Phase 4: WIRE — Integrate into Architecture65661. **Update imports and exports.** If the new component needs to be imported by existing code, add the imports. If existing code needs to be aware of the new layer, update barrel files or index modules.67682. **Update `AGENTS.md`.** Add the new component to the architecture section. Document its purpose, boundaries, and relationships to other components. This keeps agent instructions accurate.69703. **Update layer configuration** if the new component changes dependency relationships. Ensure `harness.config.json` reflects the actual import graph.71724. **For new skills:** Write the `skill.yaml` and `SKILL.md` files following the harness skill format. Use harness-skill-authoring for guidance on writing good skill content.7374### Phase 5: VERIFY — Confirm Integration75761. **Run `harness validate`** to verify the full project configuration is still valid after the addition.77782. **Run `harness check-deps`** to verify no dependency violations were introduced. The new component's imports must respect layer boundaries.7980### Graph Refresh8182If a knowledge graph exists at `.harness/graph/`, refresh it after code changes to keep graph queries accurate:8384```85harness scan [path]86```8788Skipping this step means subsequent graph queries (impact analysis, dependency health, test advisor) may return stale results.89903. **If validation fails,** fix the issues before committing. Common causes:91 - New layer not properly registered in `harness.config.json`92 - Component placed in wrong directory for its declared layer93 - Imports from forbidden layers94 - `AGENTS.md` references outdated architecture95964. **Commit the addition.** All new and modified files in a single atomic commit.9798## Harness Integration99100- **`harness add layer <name>`** — Register a new architectural layer with directory mappings and import rules.101- **`harness add doc <path>`** — Register a documentation file for drift tracking.102- **`harness add component <name> --layer <layer>`** — Register a new code component within an existing layer.103- **`harness add skill <name> --type <type>`** — Scaffold a new skill definition.104- **`harness validate`** — Verify project configuration after the addition.105- **`harness check-deps`** — Verify dependency constraints are respected after the addition.106107## Success Criteria108109- The new component is properly registered in `harness.config.json`110- The component's files exist in the correct directories for its declared layer111- `AGENTS.md` is updated to reflect the new component112- `harness validate` passes after the addition113- `harness check-deps` passes after the addition (no new violations)114- No circular dependencies were introduced115- The addition is committed as a single atomic commit116117## Rationalizations to Reject118119| Rationalization | Why It Is Wrong |120| ------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------- |121| "I will add the component and fix any constraint violations later" | Phase 2 requires running harness check-deps for a clean baseline BEFORE adding. Phase 5 requires it to pass AFTER adding. |122| "AGENTS.md does not need updating for a small internal component" | Phase 4 explicitly requires updating AGENTS.md for every new component. Without it, AI agents have no context. |123| "The new layer imports are obvious, so I do not need to check for circularity" | Phase 2 checks whether new dependency relationships create circular imports. Circular dependencies are invisible until they cause runtime failures. |124| "I will commit the config change and the code separately for cleaner history" | The success criteria require a single atomic commit. Splitting creates a window where config references a nonexistent component. |125126## Examples127128### Example: Adding a New Layer129130```131Human: "We need an infrastructure layer for external API clients."132133DETERMINE: Adding a layer. Name: infrastructure. Dirs: src/infrastructure/.134 Imports from: (none — infrastructure is a leaf layer, no internal dependencies).135 Imported by: business layer (services call external APIs through infrastructure).136137VALIDATE:138 Read harness.config.json — existing layers: presentation, business, data.139 No conflict with "infrastructure" name.140 Run: harness check-deps — passes (clean baseline).141142ADD:143 harness add layer infrastructure --dirs src/infrastructure --imports none144 mkdir -p src/infrastructure145146WIRE:147 Update harness.config.json: allow business → infrastructure imports.148 Update AGENTS.md: document infrastructure layer purpose and boundaries.149150VERIFY:151 harness validate # Pass152 harness check-deps # Pass153 git add harness.config.json AGENTS.md src/infrastructure/154 git commit -m "feat: add infrastructure layer for external API clients"155```156157### Example: Adding a Document for Drift Tracking158159```160Human: "Track our API specification for documentation drift."161162DETERMINE: Adding a document. Path: docs/api-spec.md.163 Tracks: src/routes/, src/models/response.ts.164165ADD:166 harness add doc docs/api-spec.md --tracks src/routes,src/models/response.ts167168WIRE:169 Update AGENTS.md: note that docs/api-spec.md is tracked for drift.170171VERIFY:172 harness validate # Pass173 git add harness.config.json AGENTS.md174 git commit -m "feat: track API spec for documentation drift detection"175```176177### Example: Adding a Component to an Existing Layer178179```180Human: "Add a notification service to the business layer."181182DETERMINE: Adding a component. Name: notification-service. Layer: business.183 Depends on: data layer (notification repository). Depended on by: presentation layer (routes).184185VALIDATE:186 Read harness.config.json — business layer exists, maps to src/services/.187 No existing notification-service directory.188 business → data is an allowed import. Presentation → business is allowed.189 Run: harness check-deps — passes.190191ADD:192 harness add component notification-service --layer business193 Create src/services/notification-service.ts194 Create src/services/notification-service.test.ts195196WIRE:197 Add export to src/services/index.ts (if barrel file exists).198 Update AGENTS.md: add notification service to business layer component list.199200VERIFY:201 harness validate # Pass202 harness check-deps # Pass203 git add harness.config.json AGENTS.md src/services/notification-service.*204 git commit -m "feat: add notification service to business layer"205```