-
Notifications
You must be signed in to change notification settings - Fork 66
docs: add AGENTS.md guide #2997
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
yaugenst-flex
merged 2 commits into
develop
from
FXC-4077-agents-md-for-tidy-3-d-python-client-root
Nov 14, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # Repository Guidelines | ||
|
|
||
| ## Project Structure & Documentation | ||
| - See the root `README.md` → “Project Overview” for a map of directories, and consult subdirectory READMEs for local nuances; follow those layouts when adding code. | ||
| - Keep all README files, `docs/`, and this AGENTS.md in sync whenever tooling or behavior changes. | ||
| - Prefer extending existing utilities in `scripts/` before adding new helper modules. | ||
|
|
||
| ## Workflow & Tooling | ||
| - Make sure your local environment is bootstrapped with `poetry install --extras dev` and `poetry run pre-commit install`; once that’s done on a machine, you shouldn’t need to repeat it unless dependencies change. | ||
| - Prefix every repo command with `poetry run` to match CI. | ||
| - Re-run `poetry run pytest` locally as part of your development loop; `pyproject.toml` already wires markers, doctests, coverage, and env vars. | ||
| - The pre-commit hooks you enabled during onboarding run automatically; still run `poetry run pre-commit run --all-files` before opening a PR or when new hooks land so your tree matches `.pre-commit-config.yaml` and the checks in `.github/workflows/tidy3d-python-client-tests.yml` (covers `ruff format`, `ruff check`, doc hooks). | ||
|
|
||
| ### Do / Don't | ||
| - **Do** run `poetry run pre-commit run --all-files` before opening a PR; **don't** skip it even if individual hooks passed earlier. | ||
| - **Do** stick to `poetry run …` commands; **don't** invoke tools outside Poetry, since that drifts from CI environments. | ||
| - **Do** reuse `scripts/` utilities; **don't** add new helper modules without checking for an existing script first. | ||
|
|
||
| ## Coding Style & Naming | ||
| - Favor descriptive `snake_case` functions and `PascalCase` classes tied to the physics domain. | ||
| - Most simulation and monitor classes subclass `Tidy3dBaseModel`; reserve `pydantic.BaseModel` for lightweight helpers (see `tidy3d/updater.py`), and rely on `.updated_copy(...)` plus shared validators in `tidy3d/components/validators.py`. | ||
| - Public APIs covered in `docs/` should use the existing Numpy-inspired block pattern rendered by our Sphinx Book Theme; lean on current API examples or the theme reference at https://sphinx-book-theme.readthedocs.io/en/stable/reference/api-numpy.html. Internal helpers may keep short docstrings but match local tone. | ||
| - Prefer `tidy3d.log.log` and `tidy3d.exceptions` for contributor-facing messages; touch stdlib `logging` only when muting external libraries such as `pyroots`. | ||
| - Reuse types from `tidy3d/components/types`, domain constants from `tidy3d/constants`, and runtime defaults from `tidy3d/config`. | ||
|
|
||
| ## Testing Guidelines | ||
| - Mirror the source tree with `test_<feature>.py`, add a short module docstring, and import `tidy3d as td`; keep single-use fixtures local but upstream broadly useful helpers into `tests/conftest.py`. | ||
| - Lean on `tests/conftest.py` for RNG seeding, matplotlib cleanup, logger reset, and autograd helpers, and use pytest’s `tmp_path` for artifacts. | ||
| - `poetry run pytest` is the canonical entry point; the `pyproject` config already selects markers, doctests, coverage, xdist, and env vars, so reproduce CI locally before opening a PR. | ||
| - Prefer pytest primitives (`pytest.raises`, `pytest.approx`, `@pytest.mark.parametrize`) for coverage, and add doctest snippets for new public APIs to keep docs and runtime behavior aligned. | ||
| - Mock all external/web APIs in tests (e.g., `web.run`, HTTP clients) and assert the contract instead of hitting live services; CI must stay hermetic. | ||
| - Numerical tests require explicit maintainer confirmation. They run real simulations and are excluded by default (`-m 'not numerical'`). When approved, run selectively via `poetry run pytest -m numerical path/to/test.py -k specific_case`. | ||
| - Scope tests by path: `poetry run pytest -q tests/test_web/` or `poetry run pytest -q tidy3d/components/geometry/`. | ||
| - Scope tests by keyword: `poetry run pytest -q -k "feature_name or module_name"`. | ||
| - Keep repo defaults (incl. xdist); for speed disable coverage and mute warnings: `poetry run pytest -q --no-cov -W ignore tests/... --maxfail=1`. | ||
| - Doctest a single module quickly: `poetry run pytest -q --no-cov -W ignore tidy3d/components/foo.py`. | ||
|
|
||
| ## Schema Assets | ||
| - Files under `schemas/` are generated artifacts; never edit them manually. | ||
| - Run `poetry run python scripts/regenerate_schema.py` after model/serialization changes, and commit the output alongside the code. | ||
| - CI reruns the script and fails the PR whenever checked-in schemas drift from regenerated results. | ||
|
|
||
| ## Commit & Pull Request Guidelines | ||
| - Follow Conventional Commits per `.commitlintrc.json`. | ||
| - Branch names must use an allowed prefix (`chore`, `hotfix`, `daily-chore`) or include a Jira key to satisfy CI. | ||
| - PRs should link issues, summarize behavior changes, list the `poetry run …` checks you executed, and call out docs/schema updates. | ||
|
|
||
| _Reminder: update this AGENTS.md whenever workflow, tooling, or review expectations change so agents stay in sync with the repo._ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.