agentleFS
MicrosoftKnown publishermicrosoft/devsquad-copilot/.github/plugins/devsquad/skills/harness-learnings/SKILL.md

harness-learnings

Skill50 starsChanged 16 days agoMITView on GitHub

Capture and consult codebase-specific learnings across the lifecycle. Use when an agent encounters a correction loop, review finding, test prerequisite, or recurring pattern that future sessions should know about. Also use at the start of implement, verify, or review to check for known patterns. Do not use for architecture decisions (use ADRs), for debugging the current failure (use debugging-recovery), or for one-time context that will not recur.

We split this skill into the rules it gives an agent

20 rules. About 0 are common, 11 are distinctive, and 9 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈11

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 9

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Read .memory/harness-learnings.md (create from template if it does not exist)

    line 68
  2. Very specific:

    If match found: increment Occurrences, update Last seen, upgrade Confidence if warranted

    line 71
  3. Very specific:

    If no match: append new entry with next sequential L-NNN ID

    line 72
  4. Distinctive:

    If file does not exist, skip (no learnings yet)

    line 148
  5. Very specific:

    Read the file header and ## L-NNN: heading lines first (first 2-3 lines per entry) to identify relevant IDs by Scope and Phase

    line 160
  6. Distinctive:

    Read full entries only for matching learnings

    line 161
  7. Distinctive:

    If file exceeds 100 entries, skip entries with Confidence = low

    line 162
  8. Distinctive:

    When a learning reaches Confidence = high AND Occurrences >= 3, suggest promotion:

    line 168
  9. Very specific:

    After promotion, add Promoted: [target file] to the entry.

    line 192
  10. Distinctive:

    Run on each capture operation:

    line 198
  11. Distinctive:

    Prune: remove entries with Confidence = low AND Last seen > 60 days

    line 200
  12. Very specific:

    Conflict detection: if the new learning has overlapping Scope AND opposite Guidance to an existing entry, flag CONFLICT: may contradict …

    line 202
  13. Distinctive:

    Size cap: if file exceeds 200 entries, remove all low-confidence entries older than 30 days, then suggest promotion for all high-confidence …

    line 203
  14. Very specific:

    When .memory/harness-learnings.md does not exist, create it with the header from references/learning-template.md in this skill's directory.

    line 209
  15. Distinctive:

    Do not capture vague observations without actionable Guidance ("API is hard to use" provides no fix)

    line 217
  16. Very specific:

    Do not capture learnings that duplicate existing .instructions.md rules or coding-guidelines.md

    line 218
  17. Distinctive:

    Do not set Confidence to high on first observation (it must be earned through recurrence)

    line 219
  18. Distinctive:

    Do not skip deduplication: duplicate entries dilute signal and waste context

    line 220
  19. Distinctive:

    Do not capture framework behavior as codebase learnings (report framework issues instead)

    line 221
  20. Very specific:

    Do not bloat Scope with /* or other overly broad patterns.

    line 222

≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Harness Learnings

Principle

Agent sessions are ephemeral. Codebase knowledge is not. When an agent discovers a pattern through trial and error (failed tests, correction loops, review findings), that knowledge should persist so the next session starts smarter.

Operations

This skill has two modes: capture (write a learning) and consult (read learnings relevant to the current task).

How This Skill Is Invoked

Capture is auto-prompted by the lifecycle agents at trigger moments where the agent has likely done something that future sessions should know about. The auto-prompt sites are:

  • devsquad.implement.execute after self-correction loops (2+ correction attempts, reverts of own work, max-attempt exhaustion)
  • devsquad.implement.verify after discovering a test or build prerequisite through a failed run
  • devsquad.review.code after producing Major or Critical findings that match a codebase-specific pattern
  • devsquad.implement.finalize after human PR feedback contradicts prior agent output, or CI fails on a missing prerequisite

At each trigger, the calling agent surfaces a [Y] / [N] / [E] prompt before returning its output. Default is [Y] to capture. The user can also invoke this skill explicitly at any time ("add this as a learning", "capture this as a learning"); the skill runs in capture mode without a trigger.

Consult is automatic at the start of implement.execute, implement.verify, and review.code (see "When to Consult" below).


1. Capture: Record a Learning

When to Capture

TriggerWhat to capture
Self-correction loop needed (test failure, lint failure)Root cause, fix pattern, affected files
Max correction attempts (2) exhaustedWhat the agent could not self-correct and why
Build/lint/test prerequisite missedRequired setup step (seed scripts, env vars, build order)
Review finding classified Major or CriticalAnti-pattern detected, correct pattern for this codebase
Recurring drift detected by refine.healthWhat drifts and how to prevent it
Successful debugging triage of non-obvious issueRoot cause pattern, diagnostic path
Human PR feedback on preventable issueWhat the human caught that the agent missed

When NOT to Capture

  • Generic best practices already covered by coding-guidelines.md or .instructions.md
  • One-time errors caused by typos, environment issues, or transient failures
  • Learnings about the framework itself (report as issues instead)
  • Context that only applies to a single task and will not recur
  • Observations with no actionable guidance ("this was hard" is not a learning)

Capture Procedure

  1. Read .memory/harness-learnings.md (create from template if it does not exist)
  2. Deduplicate: scan existing entries for overlap
    • Match criteria: overlapping Scope (shared file paths or modules) AND similar failure type
    • If match found: increment Occurrences, update Last seen, upgrade Confidence if warranted
    • If no match: append new entry with next sequential L-NNN ID
  3. Assign fields for new entries:
    • Phase: the lifecycle phase where this learning is most relevant for consumption (not necessarily where it was captured). A review finding about missing error handling should have Phase = implement if the fix belongs at coding time.
    • Dimension: what it regulates (maintainability, architecture, behaviour)
    • Scope: concrete file paths, directories, or module names. Use glob patterns when appropriate (e.g., src/api/**, *.controller.ts). This is the primary field agents use to match learnings to their current task.
    • Pattern: factual description of what happened (the observation)
    • Guidance: actionable instruction for what to do differently (the prescription). Must include file paths, commands, or specific checks.
    • Confidence: low (first observation), medium (seen twice or confirmed by human), high (3+ occurrences or human-validated)
    • Occurrences: 1 for new entries
    • First seen / Last seen: current date (YYYY-MM-DD)
  4. Auto-prune stale entries (see Hygiene section)
  5. Write updated file

Confidence Progression

low ──[seen again]──> medium ──[seen again OR human-validated]──> high

Human validation (explicit confirmation or PR feedback) can jump to medium or high directly.

Format

Each learning is a level-2 heading in .memory/harness-learnings.md:

## L-NNN: [short descriptive title]

- Phase: [implement|verify|review|refine|debug|plan|specify]
- Dimension: [maintainability|architecture|behaviour]
- Scope: [file paths, module names, or glob patterns]
- Pattern: [factual description of what happened]
- Guidance: [actionable instruction for next time]
- Confidence: [low|medium|high]
- Occurrences: [N]
- First seen: [YYYY-MM-DD]
- Last seen: [YYYY-MM-DD]

Example

## L-003: Integration tests require database seed before running

- Phase: verify
- Dimension: maintainability
- Scope: tests/integration/**, scripts/db-seed.sh
- Pattern: Test suite failed because agent ran `npm test` without
  `npm run db:seed` first. Debugging took 3 self-correction attempts
  before discovering the prerequisite.
- Guidance: Before running the full test suite, execute
  `npm run db:seed` to populate test fixtures. The seed script is
  idempotent. Check `scripts/db-seed.sh` for the expected schema.
- Confidence: high
- Occurrences: 5
- First seen: 2026-02-20
- Last seen: 2026-04-19

2. Consult: Read Learnings Before Acting

When to Consult

Agent / PhaseFilterHow to use
implement.execute (before coding)Scope overlaps with task filesApply Guidance proactively to avoid known pitfalls
implement.verify (before tests)Phase = verify, Scope overlapsCheck for known prerequisites (seeds, env vars)
review.code (before checking)Scope overlaps with diff filesCheck for known anti-patterns; elevate severity if matched
plan (during design)Dimension = architectureAnticipate known architectural constraints
specify (writing conformance cases)Dimension = behaviourInclude known edge cases from past failures

Consult Procedure

  1. Read .memory/harness-learnings.md
    • If file does not exist, skip (no learnings yet)
  2. Filter entries by relevance (both filters apply):
    • Scope overlaps with the current task's files or modules (primary)
    • Phase matches the current lifecycle phase (secondary)
    • Either filter matching is sufficient to include the entry
  3. Apply confidence-based signal strength:
    • high: strong signal, apply Guidance proactively
    • medium: recommendation, apply if applicable
    • low: note but do not change behavior (insufficient evidence)

Context Cost Management

  • Read the file header and ## L-NNN: heading lines first (first 2-3 lines per entry) to identify relevant IDs by Scope and Phase
  • Read full entries only for matching learnings
  • If file exceeds 100 entries, skip entries with Confidence = low

3. Promotion to Permanent Harness Control

When a learning reaches Confidence = high AND Occurrences >= 3, suggest promotion:

DimensionTarget mechanism
MaintainabilityInstruction rule (.instructions.md) or coding-guidelines
ArchitectureADR or architecture fitness check
BehaviourApproved test fixture or test guard
PrerequisitesHook script (sessionStart or postToolUse)

Present the promotion to the developer:

Learning L-NNN has been confirmed 3+ times with high confidence.
Consider promoting it to a permanent harness control:

- Current: .memory/harness-learnings.md (workspace-local)
- Suggested target: [specific file and content]
- Mechanism: [instruction rule | hook | skill amendment | ADR]

[P] Promote via devsquad.extend
[K] Keep as learning (do not promote yet)
[D] Dismiss (remove learning)

After promotion, add Promoted: [target file] to the entry. Do not remove it (audit trail).


4. Hygiene

Run on each capture operation:

  • Prune: remove entries with Confidence = low AND Last seen > 60 days
  • Downgrade: entries with Confidence = medium AND Last seen > 120 days become low
  • Conflict detection: if the new learning has overlapping Scope AND opposite Guidance to an existing entry, flag CONFLICT: may contradict L-NNN instead of overwriting
  • Size cap: if file exceeds 200 entries, remove all low-confidence entries older than 30 days, then suggest promotion for all high-confidence entries

5. File Management

When .memory/harness-learnings.md does not exist, create it with the header from references/learning-template.md in this skill's directory.

.memory/ is typically gitignored (learnings are workspace-local). For teams that want shared learnings: commit the file (add a .gitignore exception) or rely on Tier 2 promotion to share durable patterns via instructions/hooks/skills.


Anti-patterns

  • Do not capture vague observations without actionable Guidance ("API is hard to use" provides no fix)
  • Do not capture learnings that duplicate existing .instructions.md rules or coding-guidelines.md
  • Do not set Confidence to high on first observation (it must be earned through recurrence)
  • Do not skip deduplication: duplicate entries dilute signal and waste context
  • Do not capture framework behavior as codebase learnings (report framework issues instead)
  • Do not bloat Scope with **/* or other overly broad patterns; learnings with broad scope match everything and lose filtering value

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.