agentleFS
MicrosoftKnown publishermicrosoft/typeagent-py/AGENTS.md

typeagent-py

AGENTS.md889 starsChanged 14 months agoMITView on GitHub

DO NOT BE OBSEQUIOUS **NEVER use TEST_MODEL_NAME or "test" embedding model outside of test files** Never run git commands that make any changes. (git status and git diff are fine) Exceptions: git push, git worktree, git branch (for tracking setup), as instructed below. Exceptions: git push, git worktree, git branch (for tracking setup), as instructed below. NEVER COMMIT CODE. Do not run git commit or any other git commands that make changes to the repository. Exception: Worktrees/Branches below. git add…

  • Commits and pushes
  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.

    Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repositoryOne other file it gives its agents.

The file

Show its rules and text

We split this AGENTS.md into the rules it gives an agent

46 rules. About 0 are common, 18 are distinctive, and 28 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈18

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 28

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Never run git commands that make any changes.

    line 5
  2. Distinctive:

    NEVER COMMIT CODE: Do not run git commit or any other git commands that make changes to the repository.

    line 9
  3. Distinctive:

    When moving, copying or deleting files, use the git commands: git mv, git cp, git rm

    line 13
  4. Distinctive:

    When I ask to update AGENTS.md (even if maybe) extract a general rule from what I said before and update AGENTS.md (unless it's already in …

    line 15
  5. Distinctive:

    Don't use '!' on the command line, it's some bash magic (even inside single quotes)

    line 20
  6. Distinctive:

    When running 'make' commands, do not use the venv (the Makefile uses 'uv run')

    line 21
  7. Distinctive:

    If a term can refer to OS behavior or repository code behavior (for example, 'force quit'), prefer the in-repo meaning first and verify by …

    line 22
  8. Very specific:

    Use pytest test to run tests in test/

    line 24
  9. Very specific:

    Use pyright to check type annotations in src/, tools/, tests/, examples/

    line 25
  10. Very specific:

    Use make check to type-check all files

    line 28
  11. Very specific:

    Use make test to run all tests

    line 29
  12. Very specific:

    Use make check test to run make check and if it passes also run make test

    line 30
  13. Very specific:

    Use make format to format all files using black.

    line 31
  14. Very specific:

    When validating changes, first run pytest only on new/modified test files, then run make format check test once at the end.

    line 32
  15. Very specific:

    Keep ad-hoc and performance benchmarks under tools/, not tests/, so make test does not run them.

    line 34
  16. Very specific:

    When adding precomputed-embedding write paths, expose explicit *_with_embeddings methods and have existing methods compute embeddings then …

    line 40
  17. Distinctive:

    Keep internal helper type naming consistent within a module.

    line 43
  18. Very specific:

    Prefer variable names that reflect role rather than lifecycle.

    line 44
  19. Distinctive:

    Avoid potential import cycles between conversation orchestration and pipeline modules by using neutral payload protocols/arguments instead …

    line 45
  20. Very specific:

    Prefer ordinal type aliases (e.g., MessageOrdinal, ChunkOrdinal) over raw int in pipeline code for readability.

    line 46
  21. Distinctive:

    When the user asks to "fix the test only", update tests/mocks first and avoid adding production compatibility fallbacks unless explicitly …

    line 47
  22. Very specific:

    Use uv add <package> to add new dependencies

    line 52
  23. Very specific:

    Use uv add <package> --upgrade to upgrade existing packages

    line 53
  24. Distinctive:

    When generating Python code (e.g.

    line 72
  25. Distinctive:

    When creating a new file, add a copyright header to the top:

    line 75
  26. Distinctive:

    Always strip trailing spaces

    line 85
  27. Distinctive:

    Keep docstrings in sync with code when changing implementation.

    line 87
  28. Very specific:

    Keep class and type names in PascalCase

    line 89
  29. Very specific:

    Use python_case for variable/field and function/method names

    line 90
  30. Very specific:

    Use Literal for unions of string literals

    line 92
  31. Very specific:

    Keep union notation (X | Y) for other unions

    line 93
  32. Very specific:

    Use Protocol for interfaces whose name starts with I followed by a capital letter

    line 94
  33. Very specific:

    Use dataclass for other classes and structured types

    line 95
  34. Very specific:

    Use type for type aliases (PascalCase again)

    line 96
  35. Very specific:

    Use list, tuple, dict, set etc., not List etc.

    line 97
  36. Distinctive:

    don't mock; use the regular implementation (maybe introduce a fixture to create it)

    line 102
  37. Distinctive:

    read the code of the tested functions to understand their behavior

    line 105
  38. Very specific:

    Don't put imports inside functions.

    line 110
  39. Very specific:

    Put them at the top of the file with the other imports.

    line 111
  40. Very specific:

    Default to Module-Qualified Imports: Prefer importing whole modules and using qualified calls (e.g., import math.

    line 125
  41. Very specific:

    Prohibit Wildcard Imports: Never use wildcard imports (from module import *) in normal code.

    line 131
  42. Very specific:

    Error Handling: Don't use try/except Exception to catch errors broadly.

    line 140
  43. Very specific:

    Code Validation: Don't use py_compile for syntax checking.

    line 143
  44. Very specific:

    Use pyright or make check instead for proper type checking and validation.

    line 144
  45. Distinctive:

    Deprecations: Don't deprecate things -- just delete them and fix the usage sites.

    line 146
  46. Distinctive:

    Don't create backward compatibility APIs or exports or whatever.

    line 147

≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

DO NOT BE OBSEQUIOUS

NEVER use TEST_MODEL_NAME or "test" embedding model outside of test files

Never run git commands that make any changes. (git status and git diff are fine) Exceptions: git push, git worktree, git branch (for tracking setup), as instructed below. Exceptions: git push, git worktree, git branch (for tracking setup), as instructed below.

NEVER COMMIT CODE. Do not run git commit or any other git commands that make changes to the repository. Exception: Worktrees/Branches below. git add is fine.

When moving, copying or deleting files, use the git commands: git mv, git cp, git rm

When I ask to update AGENTS.md (even if maybe) extract a general rule from what I said before and update AGENTS.md (unless it's already in there -- maybe reformulate since it apparently didn't work). Also, when it looks like I state a general rule, add it to AGENTS.md. In all cases show what you added to AGENTS.md.

  • Don't use '!' on the command line, it's some bash magic (even inside single quotes)
  • When running 'make' commands, do not use the venv (the Makefile uses 'uv run')
  • If a term can refer to OS behavior or repository code behavior (for example, 'force quit'), prefer the in-repo meaning first and verify by searching the code.
  • To get API keys in ad-hoc code, call load_dotenv()
  • Use pytest test to run tests in test/
  • Use pyright to check type annotations in src/, tools/, tests/, examples/
  • Ignore build/, dist/
  • You can also use the pylance extension for type checking in VS Code
  • Use make check to type-check all files
  • Use make test to run all tests
  • Use make check test to run make check and if it passes also run make test
  • Use make format to format all files using black. Do this before reporting success.
  • When validating changes, first run pytest only on new/modified test files, then run make format check test once at the end.
  • While building add_messages.py before dedicated tests exist, skip running the full test suite; run full tests after those tests are added.
  • Keep ad-hoc and performance benchmarks under tools/, not tests/, so make test does not run them.
  • In add-messages pipeline chunk processing, compute chunk-text embeddings with uncached model calls and related-term embeddings with cached model calls.
  • In add-messages pipeline flow, lower stop_at_message_id to min(existing, failing_message_id), and always enqueue queue-1 sentinels even when the input iterator fails so workers can drain and exit cleanly.
  • In add-messages pipeline data structures, use TextLocation as the chunk identifier instead of a formatted string chunk ID.
  • In add-messages reassembler validation, prefer explicit guard checks over wrapping validation-only logic in try/except blocks.
  • In add-messages reassembler validation, prefer a single validation_error variable with consistent if/elif checks over helper functions for simple message-only validation.
  • When adding precomputed-embedding write paths, expose explicit *_with_embeddings methods and have existing methods compute embeddings then delegate to those methods.
  • In asyncio code, avoid locks for in-memory state updates that do not await between read/modify/write; use locks only when a critical section spans await points.
  • Name returned summary/value objects as *Result; reserve *State for mutable shared/internal state.
  • Keep internal helper type naming consistent within a module; avoid mixing underscored and non-underscored helper class names without a clear API-boundary reason.
  • Prefer variable names that reflect role rather than lifecycle; for accumulators like message assemblies, use neutral names (e.g., assembly) instead of state-qualified names (e.g., existing).
  • Avoid potential import cycles between conversation orchestration and pipeline modules by using neutral payload protocols/arguments instead of importing concrete pipeline result classes across modules.
  • Prefer ordinal type aliases (e.g., MessageOrdinal, ChunkOrdinal) over raw int in pipeline code for readability.
  • When the user asks to "fix the test only", update tests/mocks first and avoid adding production compatibility fallbacks unless explicitly requested.
  • For date/time range handling, use the half-open interval convention [start, stop) (stop is exclusive), as agreed in PR #198 — this avoids the ambiguity of an inclusive end (e.g. does "end of day" mean 00:00:00 or 23:59:59.999999?). Prefer this over inclusive-end ranges even when padding the end to end-of-day would also work.

Package Management with uv

  • Use uv add <package> to add new dependencies
  • Use uv add <package> --upgrade to upgrade existing packages
  • Important: uv automatically updates pyproject.toml when adding/upgrading packages
  • Do NOT manually edit pyproject.toml dependency versions after running uv commands
  • uv maintains consistency between pyproject.toml, uv.lock, and installed packages
  • Trust uv's automatic version resolution and file management
  • Never raise the lower bounds in [project.dependencies] or [project.optional-dependencies] as part of a dependency update. Those bounds ship in the wheel metadata and constrain every project that depends on typeagent; a high floor on a shared dependency is a common cause of unsolvable resolutions for downstream users. Raise a floor only when our code actually needs the newer version, and add an upper bound only for a known incompatibility (with a comment saying what breaks and what it would take to lift the cap).
  • Bumping versions in [dependency-groups] dev is fine -- that only selects which versions the dev tools run with here and in CI, and never reaches the published wheel. Same for uv.lock, which is where routine "get the latest versions" updates belong.

IMPORTANT! YOU ARE NOT DONE UNTIL make format check test PASSES

Code generation

When generating Python code (e.g. when translating TypeScript to Python), please follow these guidelines:

  • When creating a new file, add a copyright header to the top:
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
  • Assume Python 3.12
  • from __future__ import annotations is not allowed.
  • Always strip trailing spaces
  • Keep docstrings in sync with code when changing implementation.
  • Keep class and type names in PascalCase
  • Use python_case for variable/field and function/method names
  • Use Literal for unions of string literals
  • Keep union notation (X | Y) for other unions
  • Use Protocol for interfaces whose name starts with I followed by a capital letter
  • Use dataclass for other classes and structured types
  • Use type for type aliases (PascalCase again)
  • Use list, tuple, dict, set etc., not List etc.
  • Translate foo?: string to foo: str | None = None
  • When writing tests:
    • don't mock; use the regular implementation (maybe introduce a fixture to create it)
    • assume pytest; use assert statements
    • match the type annotations of the tested functions
    • read the code of the tested functions to understand their behavior
    • When using fixtures:
      • Fully type-annotate the fixture definitions (including return type)
      • Fully type-annotate fixture usages
  • Don't put imports inside functions. Put them at the top of the file with the other imports. Exception: imports in a if __name__ == "__main__": block or a main() function. Another exception: pydantic and logfire. Final exception: to avoid circular import errors.
  • Import Architecture Rules:
    • Never import a symbol from a module that just re-exports it
    • Always import directly from the module that defines the symbol
    • Exception: Package __init__.py files that explicitly re-export with __all__
    • Exception: Explicit re-export patterns like from ... import X as X or marked with "# For export"
    • This prevents circular imports and makes dependencies clear

Python Import Style Guidelines

  • Default to Module-Qualified Imports: Prefer importing whole modules and using qualified calls (e.g., import math; math.sqrt(16) or import pandas as pd; pd.DataFrame()) to prevent namespace pollution, avoid name clashes, and provide immediate context for where functions or objects originate.
  • Use Direct Symbol Imports Cautiously: Restrict direct imports (from module import symbol) to specific scenarios where they genuinely improve readability or adhere to standard conventions:
    • Importing classes, exceptions, or constants (e.g., from my_project.models import User).
    • Avoiding severe, repetitive visual clutter in heavy mathematical or algorithmic code.
    • Standard library patterns (e.g., from collections import defaultdict, Counter).
    • Exception: In tests/, importing functions directly to call them in assertions is idiomatic pytest style and is not held to this restriction (see #298).
  • Prohibit Wildcard Imports: Never use wildcard imports (from module import *) in normal code. Exception: the same explicit re-export aggregator pattern allowed by the Import Architecture Rules above (e.g. interfaces.py re-exporting interfaces_core, interfaces_indexes, etc. with __all__) — enforced by make ruff (see Makefile), with that file listed in [tool.ruff.lint.per-file-ignores].
  • Order imports alphabetically after lowercasing; group them as follows (with a blank line between groups):
    1. standard library imports
    2. established third-party libraries
    3. experimental third-party libraries (e.g. typechat)
    4. local imports (e.g. from typeagent.knowpro import ...)
  • Error Handling: Don't use try/except Exception to catch errors broadly. Let errors bubble up naturally for proper error handling and debugging at higher levels.
  • Code Validation: Don't use py_compile for syntax checking. Use pyright or make check instead for proper type checking and validation.
  • Deprecations: Don't deprecate things -- just delete them and fix the usage sites. Don't create backward compatibility APIs or exports or whatever. Fix the usage sites.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.