Skip to content
AI CODING / LESSON 1 NOTES

Give your AI coding agent a verifiable task.

Define the expected behavior, the permitted change and the evidence you need before the agent edits a file. These notes accompany the first Cloudpeakify AI coding lesson.

Free lesson notes · Python 3.9+ · Video in English, 17:42

AI Coding Guardrails: behavior, scope and evidence▶ Watch lesson 1 on YouTube ↗

Jump to a chapter

  1. The problem
  2. Find the defect
  3. Write the contract
  4. Repair and verify
  5. Challenge the evidence
  6. Exercise and handoff

Lesson 1 of a planned eight-part video series is available. The seven continuation videos are in preparation.

1. Define “done” before editing.

A request such as “fix the validator” leaves key decisions open: accepted types, boundary values, conversions and the size of the change. Write those decisions into a short task contract.

For this independent illustration, the function validates a retry count. The example below is a companion exercise, not a transcript of the video’s validator.

Goal: valid_retry_count(value) returns a boolean.
Accept: exactly the built-in int type, from 0 to 5 inclusive.
Reject: bool, float, strings, None and other types.
Scope: the validator and its acceptance cases.
Constraints: preserve the function name; add no dependencies.
Evidence: report the cases exercised and the observed results.

The scope makes review manageable. If the agent discovers an unrelated issue, record it separately and decide whether it belongs in another change.

2. Make the type rule explicit.

Python’s bool is a subtype of int. As a result, isinstance(True, int) evaluates to True. A validator using that check alone would admit a value this contract rejects. See the Python type documentation.

def valid_retry_count(value):
    return type(value) is int and 0 <= value <= 5

Here, type(value) is int implements the exact-type requirement. It excludes booleans and integer subclasses. The and short-circuits, so other types are rejected before the range comparison.

Choose type and conversion rules for the actual interface. This example deliberately performs no coercion: "3" and 3.0 are rejected even though they can represent a number.

3. Cover boundaries and challenge the checks.

Start with the contract and write down expected results. The table is a small illustrative set; the video demonstrates a separate set of 16 acceptance cases.

InputExpectedReason
0TrueLower boundary
5TrueUpper boundary
-1FalseBelow the range
6FalseAbove the range
TrueFalseBoolean type
FalseFalseBoolean type
3.0FalseFloating-point type
"3"FalseString type
NoneFalseMissing value

Then introduce a known defect in a temporary local copy and confirm that a relevant check detects it. Four useful challenges for this example are:

  • Exclude the lower boundary: change the comparison so that 0 is rejected.
  • Exclude the upper boundary: change the comparison so that 5 is rejected.
  • Admit booleans: replace the exact type check with isinstance(value, int).
  • Silently convert strings: coerce "3" into an integer before checking it.

If a deliberately broken variant passes, identify the missing assertion. A case should demonstrate the required behavior, rather than repeat the implementation’s decisions.

4. Leave a useful handoff.

The next person needs to see what changed and what supports the conclusion. Keep the summary tied to the actual work:

  • Change: the files and behavior that were modified.
  • Evidence: the command, cases and results you actually observed.
  • Open findings: unresolved issues, their impact and the next owner.
  • Limits: environments or behavior that were not checked.

A local validator exercise establishes a small part of repository readiness. Tool access, secrets, CI and production approval need their own explicit decisions when you expand the agent’s role.

Take the next step in your repository.

FREE

Free repo readiness checklist

Review repository instructions, acceptance criteria, secret isolation, tool permissions and change approval. Includes an editable CSV scorecard.

Get the free checklist ↗
PAID COURSE

AI Coding Guardrails course + lab

Continue with eight written learning modules and four guided labs for DevOps and platform work. The remaining videos are still in preparation.

View the paid course and contents ↗

Planning a team rollout? Discuss an AI coding agent readiness assessment →

Sources and related material

← Back to Insights