Draft

Complete a Greenfield Refactor with a Coding Agent: Add Tests and Make CI Green

  • Not yet verified
  • Versions not pinned
  • 1 min read

Task

What you will complete

In a small public or sample repo, add tests, commit the change, and make CI green.

Success criteria

  • The repository has new tests for the behavior the refactor changes.
  • The change is committed without unrelated files.
  • CI for that commit is green, and the run URL can be linked from the evidence section.

What this is not

Not a formatting-only edit, and not a tutorial that stops while CI is still failing.

Prerequisites

  • A small public or sample repository you can commit to, with CI already configured.
  • A coding agent that can edit that repository.
  • A refactor you can describe as a behavior change.

Environment

Not recorded. A verified revision will list the operating system, the tool builds, and the model identifiers that were present for the run.

1. Choose the repository and the refactor

Use a small public or sample repository that already has CI. Name a behavior change you can test. A formatting-only edit does not count. Write the repository URL in your notes. This draft does not link one, because no repository has been chosen.

2. Add tests for the behavior you are about to change

Have the coding agent add tests that pass on the current code and would fail if the refactor went wrong. Read the tests before you trust them. Delete any test that does not lock the behavior you named.

3. Make the refactor with the agent

Ask for the behavior change and keep the tests green on your machine. Review the diff. Remove unrelated edits before you commit.

4. Commit the change

Commit the tests and the refactor together, with a message that names the behavior. The verified page will link the commit. This draft does not, because the commit does not exist.

Planned commands. Not run for this draft.

git status
git diff

5. Make CI green

Push, or open a pull request, and wait for the existing CI. If it fails, fix the cause and keep the failing log as well as the green one. The evidence section needs the URL of the green run. It is not here yet.

Evidence it actually ran

This is the shape of the stamp. It has not been earned, and the example date that follows is a placeholder, not a run: Ran on YYYY-MM-DD (Asia/Shanghai) with the pinned versions.

Command output
None recorded. A verified revision will quote the output from the run, not a sample written in advance.
Tests, CI, or Inspector
Not run for this draft.
Repository or config
No link recorded.

Failure modes

Anticipated only. None of these has been checked against a run of this tutorial.

  • Unchecked

    Tests pass locally and fail in CI

    A green local run can hide a missing dependency, a path, or a secret the CI job does not have.

  • Unchecked

    The commit includes unrelated files

    An agent diff often touches files the task did not name. Those do not belong in the commit.

  • Unchecked

    CI is green because the new tests were not run

    A passing workflow that does not execute the new tests is not the check this task requires.

Other tutorials in Tasks.