Skip to content

Sample code for: How to Write an AGENTS.md File for a Python Project#781

Merged
bzaczynski merged 3 commits into
masterfrom
agents-md
Jul 26, 2026
Merged

Sample code for: How to Write an AGENTS.md File for a Python Project#781
bzaczynski merged 3 commits into
masterfrom
agents-md

Conversation

@lpozo

@lpozo lpozo commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Where to put new files:

  • New files should go into a top-level subfolder, named after the article slug. For example: my-awesome-article

How to merge your changes:

  1. Make sure the CI code style tests all pass (+ run the automatic code formatter if necessary).
  2. Find an RP Team member on Slack and ask them to review & approve your PR.
  3. Once the PR has one positive ("approved") review, GitHub lets you merge the PR.
  4. 🎉

Code examples for the How to Write an AGENTS.md File for a Python Project tutorial. Files live in the agents-md/ top-level folder, named after the article slug.

Generated from the tutorial markdown with the post-materials skill, then verified locally before pushing.

Contents:

  • original_main.py — the starter FastAPI app
  • run1_main.py — the agent's output without an AGENTS.md (the flawed run)
  • run2_main.py — the agent's output with the AGENTS.md in place
  • test_main.py — tests against run2_main.py (both pass)
  • cars.json — the sample dataset
  • AGENTS.md — the complete config file built across the tutorial

@stephengruppetta stephengruppetta left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lpozo just a minor comment here

Comment thread agents-md/run1_main.py Outdated
Comment on lines +29 to +41
def create_car(car: dict):
car["id"] = len(cars) + 1
cars.append(car)
return {"message": "Car created successfully", "car": car}


@app.delete("/cars/{car_id}")
def delete_car(car_id: int):
for i in range(len(cars)):
if cars[i]["id"] == car_id:
cars.pop(i)
return {"message": "Car deleted"}
return {"error": "Car not found"}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original code in the tutorial uses single quotes for the strings in the dicts and for 'id', and this is one of the "flaws" you discuss from the first run. I suggest breaking our convention for proper formatting in the materials and use the original single quotes here, even if CI complains!

bzaczynski and others added 2 commits July 26, 2026 15:15
The tutorial presents run1_main.py as the agent's flawed first-run
output, and one of the flaws it calls out is the use of single-quoted
strings. Ruff formatting had normalized them to double quotes, which
contradicted the article.

Restore the original single quotes and exclude this one file from Ruff,
following the existing how-to-indent-in-python/sample_code.py precedent.

Addresses @stephengruppetta's review comment on PR #781.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@bzaczynski
bzaczynski merged commit 03ba550 into master Jul 26, 2026
1 check passed
@bzaczynski
bzaczynski deleted the agents-md branch July 26, 2026 13:17
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.

3 participants