Guidelines for agent-assisted development. Python 3.12+, managed with uv.
- Living Doc: Update this file with new findings/notes.
- Scope: Work only in this repo.
- Approvals: ALWAYS ask before fetching external resources or installing packages.
- Secrets: Store in
.env, load withpython-dotenv. Never hardcode or commit secrets. - Assumptions: Surface inconsistencies, unclear intent, or ambiguous requirements—ask for clarification before proceeding. Push back on bad ideas. Present trade-offs when relevant.
- Simplicity: Favor simple, explicit, maintainable solutions. No over-engineering. Always prefer the simplest solution that meets requirements.
- Scope Discipline: Only modify code directly related to the current task. Never change, move, or remove code, comments, or logic that is orthogonal to your task—even if it seems "wrong" or you don't fully understand it. If you spot issues elsewhere, flag them separately.
- Cleanup: Remove dead code, temporary files, and dev artifacts after each step. Release resources (files, connections, temp dirs) using
withcontext managers oratexitfor global cleanup. - Self-Check Before Finishing: Before presenting a solution, verify: (1) Did I make assumptions I should have clarified? (2) Is this the simplest solution? (3) Did I change unrelated code as a side effect? (4) What alternatives/tradeoffs should I mention?
Manage env with uv. Re-run uv sync after changes.
uv sync # Lock/Sync
uv add [--dev] <pkg> # Add dependency
uv run <cmd> # Run in env- Types: Modern syntax (
list[str],X | None,Self). Notyping.List. - Data: Use
dataclassesorTypedDict. - Paths:
pathlib.Pathonly. - Errors: Specific exceptions with messages. No bare
except:. - Formatting: f-strings. Use debug format
f"{var=}"→ outputsvar=value.
- Settings: Store in
config.yaml, load withpyyaml. - Secrets: Store in
.env, load withpython-dotenv. Never commit to git. - No magic values: All configurable parameters belong in config files.
Use logging module with JSON output for structured logs:
import logging
import json
class JSONFormatter(logging.Formatter):
def format(self, record):
return json.dumps({"level": record.levelname, "message": record.getMessage(), "module": record.module})
handler = logging.StreamHandler()
handler.setFormatter(JSONFormatter())
logging.basicConfig(level=logging.INFO, handlers=[handler])- Flat Architecture: Explicit, linear control flow. No metaclasses,
exec, or dynamic attribute generation. - Predictable: Consistent layout, standard patterns, deterministic tests.
- Modular: Decoupled modules, config-driven behavior.
- Quality: Descriptive names, structured logging.
- Comments/Docstrings: Explain why. Follow PEP 257.
- README: Concise usage/examples. No fluff.
- Files: Avoid extra docs. Update README/AGENTS.md instead.
- Location:
tests/directory, mirroring source structure. - Naming:
test_<module>.py, functionstest_<behavior>(). - Fixtures: Use
conftest.pyfor shared fixtures. - Run:
uv run pytest -v(verbose) oruv run pytest -x(stop on first failure).
- Commits: Use conventional commits:
type(scope): message- Types:
feat,fix,docs,refactor,test,chore - Example:
feat(auth): add OAuth2 login flow
- Types:
- Branches:
feature/<name>,fix/<name>,refactor/<name> - Keep clean: Commit small, logical changes. No WIP commits on main.
uv run ruff format . # Format
uv run ruff check . [--fix] # Lint
uv run pytest # Test
uv run ruff format . && uv run ruff check . && uv run pytest # All checks- Config:
pyyamlfor YAML,python-dotenvfor env vars. - CLI:
typer(notargparse). Type hints,typer.Argument(),typer.Option(). Use Enum for fixed choices. - HTTP:
httpxfor async requests. - Output:
rich(Console,Table) for terminal output.
- FastAPI: Pydantic validation,
app/routers/modules, dependency injection,asyncI/O. - Streamlit:
st.sidebarfor controls,st.session_state,@st.cache_data. - LLM: OpenRouter via OpenAI-compatible client. Load API key from
.env. Config inconfig.yaml(model, temp, tokens). Concurrent:ThreadPoolExecutor. - Embeddings:
sentence-transformers(local, e.g.,intfloat/multilingual-e5-small). - Scraping:
playwright— async, headless, built-in selectors (role,text). - Data Science: Jupyter, pandas (vectorized), pyarrow/parquet, scikit-learn, seaborn.
- Document Parsing:
docling— parse docs to MD (export_to_markdown).
- (Agent: Add project-specific notes/stack decisions here)
- Embedded Weaviate may inherit
DEBUG=releasefrom the notebook/app environment and emit very verbose Go router traces. Useenvironment_variables={"DEBUG": "false", "LOG_LEVEL": "error"}inweaviate.connect_to_embedded(...)to suppress them.