Skip to content

my-coder v0.2: feed a style anchor so generated code meets house standards - #4

Merged
lorenzoliuzzo merged 1 commit into
mainfrom
improve-mycoder-v0.2-standards
Jul 18, 2026
Merged

my-coder v0.2: feed a style anchor so generated code meets house standards#4
lorenzoliuzzo merged 1 commit into
mainfrom
improve-mycoder-v0.2-standards

Conversation

@lorenzoliuzzo

Copy link
Copy Markdown
Contributor

Second iteration of the self-improvement loop — raising the standards bar, as requested.

The gap this closes

The my-raytracer#10 review had to hand-fix the generated tests: they lacked -> None and from __future__ import annotations, diverging from the repo's own test_smoke.py. Root cause: my-raytracer has no CLAUDE.md, so the session had no stated conventions and guessed. Polishing in review doesn't scale — the tool should meet the standard the first time.

Change

  • _style_anchor() — inject the target repo's existing code into the session prompt: the file tree + the largest src//tests/ .py files (capped at 3 files × 6 KB). A repo's house style lives in its code even without a CLAUDE.md.
  • Stronger standards rule in the prompt: match the shown code's module layout, import style, type hints on every signature (tests included), naming, and test style — imitate the nearest file rather than inventing a style.

Why this is the right depth

It generalizes: every target repo benefits, CLAUDE.md or not. And it doubles as correctness grounding — for my-raytracer#3 (camera), the session now sees the merged vec.py/ray.py, so it uses Vec3/Ray correctly, not just stylistically.

Tests

25 tests, 96% coverage. New test asserts the session prompt carries the existing code as a style anchor. .format() substitution is safe against braces in injected code (values aren't re-parsed).

Readiness

  • tests green locally (pytest, ruff, ruff format)
  • scope matches the goal (better standards, at the source)

🤖 Generated with Claude Code

…dards

The PR#10 review had to hand-fix generated tests (missing `-> None` and
`from __future__ import annotations`) — root cause: my-raytracer has no
CLAUDE.md, so the session had no convention to follow and guessed. Fix it at the
source: show the session the repo's existing code.

- _style_anchor(): include the repo file tree + the largest existing src/tests
  .py files (capped) in the session prompt, so generation matches conventions
  (type hints, imports, test shape) the first time instead of in review.
- Strengthen the prompt's standards rule: match the shown code's layout, import
  style, type hints on EVERY signature (tests included), naming, and test style.

25 tests, 96% coverage.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.66667% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/mycoder/coder.py 86.66% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@lorenzoliuzzo
lorenzoliuzzo merged commit 369231a into main Jul 18, 2026
1 of 2 checks passed
@lorenzoliuzzo
lorenzoliuzzo deleted the improve-mycoder-v0.2-standards branch July 18, 2026 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant