Workspace/Lesson workspace
Loading progress
Reliable systems45 min

Tools, skills, and the lifecycle of repository instructions

Lesson 2 of 3
How to study this lesson

Read one section, trace the worked example, and try the knowledge check. Bookmark saves a shortcut; notes appear in My notebook. Mark lesson complete is your own assessment and does not mark its lab passed.

By the end, you can

  • Distinguish executable tool capabilities from reusable guidance.
  • Load scoped instructions with provenance and version information.
  • Test instruction changes against actual coding behavior.

A tool does work; a skill guides work

A tool provides an executable capability such as searching files, running a command, or applying a patch. A skill packages reusable instructions and sometimes supporting scripts or reference material for a particular workflow. It can tell an agent how to perform a review, but it does not grant operating-system access by itself. The launcher and tool broker still enforce actual permissions.

This distinction helps diagnose failures. If the agent knows the correct test command but cannot access the environment, the problem is capability or setup. If it can run commands but repeatedly chooses the wrong validation, the problem may be guidance or context. More instruction text cannot repair a missing dependency automatically, and a more powerful shell does not ensure the agent understands the repository's conventions. Treat both interfaces as parts of an engineered workflow.

Discover, select, then load the needed detail

The Agent Skills specification describes a directory with a SKILL.md file and optional supporting resources. A practical lifecycle begins with lightweight metadata so the agent can identify relevant guidance, then loads the full instructions when the task warrants it. This limits context consumption while keeping specialized procedures available. Selection should depend on the actual work, not merely a keyword appearing in a user message.

Record the source and version of loaded guidance. If a skill invokes a script, inspect its contract and ensure it matches the repository and runtime. Guidance can become stale when commands, file paths, or APIs change. The example hashes a small instruction bundle and demonstrates that changing a test command changes its identity. A hash helps detect a changed bundle; it does not establish trust, correctness, or permission to execute every command in it.

Respect scope and authority

Repositories may use AGENTS.md to explain setup, coding conventions, test commands, and review expectations. Instruction scope and precedence depend on the agent product, so check its documented rules rather than inventing a universal hierarchy. Within that hierarchy, repository guidance should help implement the user's task and must not become an excuse to expand authority beyond what was granted.

A downloaded example file or a comment inside an issue can contain imperative text, but that does not automatically make it an instruction source. Keep trusted workflow guidance separate from arbitrary repository data and tool output. If an unfamiliar instruction asks for secrets, external publication, or unrelated changes, evaluate its authority and scope before acting. A markdown extension is a format, not a trust signal. This matters because coding agents routinely read files that someone else can modify.

Manage changes like any other behavior change

Instruction changes can alter tool selection, patch size, approval behavior, and test coverage even when no application code changes. Version them and review their effects. A useful instruction explains a concrete repository fact, such as the supported environment command or where integration tests live. Vague mandates like always be perfect add little actionable information and can compete with more precise guidance.

Test a proposed instruction on representative tasks. For example, a new requirement to run all integration tests may catch regressions but also fail on machines lacking credentials. Clarify the actual required gate and the documented fallback, while preserving any necessary approval boundary. Compare task completion, command failures, and unnecessary user interruptions before and after the change. An instruction package is maintained software-facing documentation, not a magical optimization that improves every task simply by being longer.

Preserve a useful record of applied guidance

A coding run should be able to report which guidance influenced its decisions, which files were changed, and which checks established the result. Store references or content hashes where appropriate so a later investigation can distinguish a code regression from a changed instruction bundle. When a task resumes after a checkpoint, verify that important instructions still correspond to the current repository version.

The code below implements a tiny in-memory catalog and explicit activation. It is not a full Agent Skills loader: it does not parse frontmatter, resolve resources, enforce precedence, or run scripts. Those are deliberate extension points. The learning goal is lifecycle discipline: discover the right guidance, load its actual content, apply it within the existing authority model, and validate the resulting behavior. The same discipline prevents a cached summary from silently overriding a corrected instruction.

Work through the code

The catalog separates brief discovery metadata from activated instructions and detects a changed bundle. All strings are local teaching fixtures. This is not a conforming Agent Skills parser or an authorization mechanism.

m25_lesson_2.py
python
import hashlib
from dataclasses import dataclass

@dataclass(frozen=True)
class Skill:
    name: str
    description: str
    instructions: str

    def version_hash(self):
        payload = self.name + "\n" + self.description + "\n" + self.instructions
        return hashlib.sha256(payload.encode()).hexdigest()

catalog = {
    "tests": Skill("tests", "Validate Python patches.",
                   "Run the focused regression and the documented suite."),
    "docs": Skill("docs", "Review public API documentation.",
                  "Check examples against the changed interface."),
}
print("discovered:", sorted(catalog))
active = catalog["tests"]
revised = Skill(active.name, active.description, "Run the focused regression.")
print("active:", active.name)
print("same version:", active.version_hash() == revised.version_hash())
EXPECTED / ILLUSTRATIVE OUTPUT
discovered: ['docs', 'tests']
active: tests
same version: False

Run Python snippets locally with the prerequisites named above. The module coding lab runs directly in your browser.

Pause and reason

A repository instruction says to run a deleted test script. The agent has verified the replacement command in current project configuration. How should it proceed and how should the guidance be maintained?

Check your understanding

What does a changed instruction-bundle hash tell you?

Your notes

Explain the mechanism in your own words. Add a failure you want to test.

Saved notes appear in your notebook

Go deeper with primary sources

Practice this module