Skip to content

Commit 3755be9

Browse files
gromdimongreg-agent[bot]cursoragent
committed
feat: refresh template observability and agent defaults
Remove Logfire, add optional Sentry and base app exceptions, and update the template docs and config defaults to match the current startup flow. Co-Authored-By: greg-agent[bot] <305014151+greg-agent[bot]@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent b276f88 commit 3755be9

16 files changed

Lines changed: 538 additions & 872 deletions

‎.env.dev‎

Lines changed: 0 additions & 3 deletions
This file was deleted.

‎.env.example‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ENVIRONMENT=development
2+
3+
# Optional: leave empty to disable Sentry
4+
SENTRY_DSN=
5+
SENTRY_TRACES_SAMPLE_RATE=0.1

‎.github/dependabot.yml‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Dependabot keeps base images and dependencies current so the Trivy CVE gate
2+
# stays actionable (the fix for a flagged CVE is almost always a version bump).
3+
version: 2
4+
updates:
5+
- package-ecosystem: "pip"
6+
directory: "/"
7+
schedule:
8+
interval: "weekly"
9+
target-branch: "dev"
10+
open-pull-requests-limit: 5
11+
groups:
12+
python-minor-patch:
13+
update-types:
14+
- "minor"
15+
- "patch"
16+
17+
- package-ecosystem: "docker"
18+
directory: "/"
19+
schedule:
20+
interval: "weekly"
21+
target-branch: "dev"
22+
open-pull-requests-limit: 3
23+
24+
- package-ecosystem: "github-actions"
25+
directory: "/"
26+
schedule:
27+
interval: "weekly"
28+
target-branch: "dev"
29+
open-pull-requests-limit: 3

‎AGENTS.md‎

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
This file provides guidance to AI coding agents working with this repository.
2+
3+
## Project Overview
4+
5+
This repository is a reusable Python project template. It is intentionally small
6+
and generic, so changes should prefer simple, composable patterns over
7+
project-specific architecture.
8+
9+
The current template includes:
10+
11+
- Poetry for dependency management
12+
- Pydantic Settings for configuration
13+
- Loguru for logging
14+
- Optional Sentry initialization
15+
- Custom application exceptions
16+
- pytest, Ruff, isort, and mypy
17+
- Docker and GitHub Actions
18+
19+
When adapting this template for a real project, preserve the clean foundation
20+
and add framework- or domain-specific code incrementally.
21+
22+
## Common Development Commands
23+
24+
```bash
25+
make deps # Install dependencies
26+
make format # Format code
27+
make lint # Run Ruff, isort, and mypy
28+
make test # Run tests
29+
make ci-test # Run tests with coverage
30+
make dev # Run the example entrypoint
31+
```
32+
33+
## Core Principles
34+
35+
### Keep the template generic
36+
37+
- Do not introduce business-specific naming, copy, or architecture into the
38+
template.
39+
- Prefer framework-agnostic utilities in `src/core/` unless the repository has
40+
clearly become tied to a framework.
41+
- New defaults should be broadly useful to future projects, not tailored to one
42+
app.
43+
44+
### Favor minimal, explicit patterns
45+
46+
- Prefer small modules with obvious responsibilities.
47+
- Avoid clever abstractions unless they clearly reduce repeated complexity.
48+
- Keep startup wiring easy to trace from `src/main.py`.
49+
- Make optional integrations truly optional by gating them with settings.
50+
51+
### Preserve clean layering
52+
53+
- `src/core/` is for reusable foundation code: config, logging, observability,
54+
exceptions, enums, and similar cross-cutting concerns.
55+
- `src/main.py` is the composition root for startup wiring and top-level error
56+
handling.
57+
- `tests/` should verify behavior, not implementation details.
58+
59+
## Configuration Conventions
60+
61+
- All configuration should live in `src/core/config.py`.
62+
- Environment variables should be documented in `.env.example`.
63+
- Copy `.env.example` to `.env` for local development; never commit secrets.
64+
- Optional services must degrade cleanly when their config is absent.
65+
66+
Examples in this template:
67+
68+
- Sentry is disabled when `SENTRY_DSN` is empty.
69+
- Logging configuration is environment-aware via `ENVIRONMENT`.
70+
71+
## Logging, Observability, and Errors
72+
73+
- Use `src/core/logging.py` for Loguru setup.
74+
- Keep observability integrations minimal in the template. Add advanced routing,
75+
filtering, or framework-specific integrations only in downstream projects.
76+
- Use custom exceptions from `src/core/exceptions/` for intentional app-level
77+
failures.
78+
- Catch custom app exceptions at the top level in `src/main.py` or the
79+
framework-specific entrypoint, log them consistently, and exit or translate
80+
them there.
81+
82+
## Dependencies
83+
84+
- Use Poetry for all dependency changes.
85+
- Keep runtime dependencies minimal.
86+
- Add a dependency to the template only if it is broadly useful across many new
87+
projects.
88+
- Remove stale dependencies when their integration is removed from the codebase.
89+
90+
## Testing and Verification
91+
92+
- Add or update focused tests for behavior changes.
93+
- Prefer test-first changes for new features and bug fixes.
94+
- After substantive edits, run:
95+
96+
```bash
97+
make test
98+
make lint
99+
```
100+
101+
- If config, startup wiring, or dependency behavior changes, add tests for the
102+
new edge cases.
103+
104+
## Code Style
105+
106+
- Python 3.13 target.
107+
- Line length: 100.
108+
- Type hints are required for public function signatures.
109+
- Keep comments focused on why, not what.
110+
- Public modules and public classes should have useful docstrings.
111+
- Avoid commented-out code.
112+
113+
## Template-Specific Change Guidelines
114+
115+
- If you add a new core capability, wire it through all relevant template entry
116+
points:
117+
- dependencies in `pyproject.toml`
118+
- environment variables in `.env.example`
119+
- startup/config code in `src/core/` or `src/main.py`
120+
- tests in `tests/`
121+
- docs in `README.md` if the capability affects setup or usage
122+
123+
- If you rename or remove a template feature, clean up:
124+
- stale tests
125+
- stale README references
126+
- stale environment variables
127+
- stale dependencies and lockfile entries
128+
129+
## What Not to Do
130+
131+
- Do not hardcode secrets or commit real credentials.
132+
- Do not add service-specific architecture to the template without a clear need.
133+
- Do not leave dead examples, mismatched tests, or outdated docs behind.
134+
- Do not couple the template to a framework unless that is an intentional
135+
direction change for the repository.
136+
137+
## Keeping This File in Sync
138+
139+
Update this file whenever the template's development workflow, architectural
140+
expectations, or core building blocks change.

‎CLAUDE.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
AGENTS.md

‎README.md‎

Lines changed: 55 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Template for python repositories.
2-
[![Lint](https://github.com/axioma-ai-labs/python-template/actions/workflows/ci-lint.yml/badge.svg)](https://github.com/axioma-ai-labs/python-template/actions/workflows/ci-lint.yml)
3-
[![Docker](https://github.com/axioma-ai-labs/python-template/actions/workflows/docker.yml/badge.svg)](https://github.com/axioma-ai-labs/python-template/actions/workflows/docker.yml)
1+
# Template for Python repositories
2+
[![CI](https://github.com/axioma-ai-labs/python-template/actions/workflows/main.yml/badge.svg)](https://github.com/axioma-ai-labs/python-template/actions/workflows/main.yml)
3+
[![Docker](https://github.com/axioma-ai-labs/python-template/actions/workflows/docker-latest.yml/badge.svg)](https://github.com/axioma-ai-labs/python-template/actions/workflows/docker-latest.yml)
44

55
## Table of Contents
66

@@ -10,11 +10,11 @@
1010

1111
## Overview
1212

13-
This project is a template for Python repositories. It includes a Makefile with commands for
14-
formatting, linting, and installing dependencies. It also includes a pre-configured Github Actions
13+
This project is a template for Python repositories. It includes a Makefile with commands for
14+
formatting, linting, and installing dependencies. It also includes pre-configured GitHub Actions
1515
workflow for CI/CD.
1616

17-
Let the following note be in your project-specific Readme file:
17+
You can add the following note to a project-specific README:
1818

1919
> [!NOTE]
2020
> This project uses the [python-template](https://github.com/axioma-ai-labs/python-template)
@@ -26,24 +26,30 @@ Let the following note be in your project-specific Readme file:
2626
The project uses Pyenv for managing Python versions and Poetry for managing dependencies. Find more
2727
details in the [Development](#development) section.
2828

29-
### 2. Pydantic
29+
### 2. Pydantic, Loguru, and optional Sentry
3030

31-
The project uses `Pydantic` for data validation and settings management.
31+
The project uses `Pydantic` for data validation and settings management, `Loguru` for logging,
32+
and optional `Sentry` initialization for error tracking and performance monitoring.
3233

33-
### 3. Ruff, Isort, Mypy
34+
### 3. Custom application exceptions
3435

35-
The project uses `Ruff` for formatting, `Isort` for sorting imports, and `Mypy` for static typing.
36-
Recommended to use with `Makefile` commands. For more information look at the
36+
The template includes reusable application exceptions in `src/core/exceptions/` and a top-level
37+
entrypoint wrapper in `src/main.py` for consistent error handling.
38+
39+
### 4. Ruff, isort, mypy, and pytest
40+
41+
The project uses `Ruff` for formatting, `isort` for sorting imports, `mypy` for static typing,
42+
and `pytest` for testing. Recommended to use with `Makefile` commands. For more information look at the
3743
[Makefile](./Makefile).
3844

39-
### 4. Github Actions
45+
### 5. GitHub Actions and Dependabot
4046

41-
The project uses Github Actions for CI/CD. Look at the [.github/workflows](.github/workflows) for
42-
more information. The package includes the linting workflow per default.
47+
The project uses GitHub Actions for CI/CD and includes Dependabot configuration for Python,
48+
Docker, and GitHub Actions updates.
4349

44-
### 5. Makefile
50+
### 6. Makefile
4551

46-
The project uses Makefile for automating tasks. Look at the [Makefile](./Makefile) for more
52+
The project uses Makefile for automating tasks. Look at the [Makefile](./Makefile) for more
4753
information.
4854

4955
The provided Makefile includes the following commands:
@@ -52,6 +58,7 @@ The provided Makefile includes the following commands:
5258
make deps # Install dependencies
5359
make format # Format code
5460
make lint # Lint code
61+
make test # Run tests
5562
```
5663

5764
## Development
@@ -60,13 +67,13 @@ make lint # Lint code
6067

6168
#### Overview
6269

63-
You will need to have Python 3.13 and Poetry installed. The next step is to checkout the repository
64-
and install the Python dependencies. Then, you will be able to utilize the CLI and run the tests.
70+
You will need to have Python 3.13 and Poetry installed. The next step is to checkout the repository
71+
and install the Python dependencies. Then, you will be able to run the example entrypoint and tests.
6572
The following assumes a Debian/Ubuntu machine; your mileage may vary.
6673

6774
#### Prerequisites
6875

69-
You can use pyenv for getting a specific python version. Once you have pyenv installed, you can
76+
You can use pyenv for getting a specific Python version. Once you have pyenv installed, you can
7077
install a specific python version:
7178

7279
```
@@ -101,12 +108,20 @@ poetry add --group dev <package>
101108

102109
#### Setup Environment Variables
103110

104-
You can use the provided `.env.example` file to setup the environment variables.
111+
You can use the provided `.env.example` file to set up the environment variables.
105112

106113
```
107114
cp .env.example .env
108115
```
109116

117+
The default template variables are:
118+
119+
```env
120+
ENVIRONMENT=development
121+
SENTRY_DSN=
122+
SENTRY_TRACES_SAMPLE_RATE=0.1
123+
```
124+
110125
### 6. Docker
111126

112127
The project uses Docker for building the image. Look at the [Dockerfile](./Dockerfile) for more
@@ -116,15 +131,31 @@ information.
116131
docker build -t python-template .
117132
```
118133

119-
### 7. Testing
134+
### 7. Running the template
135+
136+
Run the example entrypoint:
137+
138+
```bash
139+
make dev
140+
```
141+
142+
The startup sequence configures logging, initializes Sentry when `SENTRY_DSN` is set, and then
143+
runs the example application entrypoint.
144+
145+
### 8. Testing
120146

121147
The project uses pytest for testing. Look at the [Makefile](./Makefile) for more information.
122148

123149
```
124150
make test
125151
```
126152

127-
### 8. CI/CD
153+
### 9. AI agent guidance
154+
155+
This repository includes `AGENTS.md` for coding-agent instructions. `CLAUDE.md` points to the same
156+
content so both entry points stay in sync.
157+
158+
### 10. CI/CD
128159

129-
The project uses Github Actions for CI/CD. Look at the [.github/workflows](.github/workflows) for
130-
more information. The package includes the linting and docker build workflows per default.
160+
The project uses GitHub Actions for CI/CD. Look at the [.github/workflows](.github/workflows) for
161+
more information. The package includes test/lint and Docker workflows by default.

0 commit comments

Comments
 (0)