

Also from Kynth Studios


Also from Kynth Studios


Also from Kynth Studios
1# AGENTS.md — flask23## Code Style & Strict Rules45Code style is strictly enforced by `ruff`, and its rules are non-negotiable.67* **Linter Rules**: The following `ruff` rule sets are enforced. All code must comply with them.8 * `B`: `flake8-bugbear` (Finds potential bugs)9 * `E`: `pycodestyle` (Errors)10 * `F`: `pyflakes` (Undefined names, unused imports)11 * `I`: `isort` (Import sorting)12 * `UP`: `pyupgrade` (Modernizes Python syntax)13 * `W`: `pycodestyle` (Warnings)14* **Import Style**: Imports must be written one per line. Grouping imports on a single line is forbidden.15 * **Correct:**16```python17 from flask import Flask18 from flask import request19```20 * **Incorrect:**21```python22 from flask import Flask, request23```2425## Anti-Patterns & Restrictions2627The following patterns are strictly forbidden to maintain code quality, security, and performance.2829* **NEVER use `app.run()` in production.** This is a development-only server. For production, a proper WSGI server like Gunicorn or uWSGI must be used.30* **NEVER wrap the `app` object directly for middleware.** To apply middleware, you MUST assign it to the internal WSGI application.31 * **Correct:**32```python33 app.wsgi_app = MyMiddleware(app.wsgi_app)34```35 * **Incorrect:**36```python37 app = MyMiddleware(app)38```39* **NEVER use the session for caching or storing large data.** The session is a small, signed cookie intended only for small identifiers (e.g., `user_id`). Storing large objects will severely degrade performance.40* **NEVER use context-dependent functions outside of an active request or application context.** Functions like `url_for()` or the `request` object will fail if called at the global scope. If needed, they must be wrapped in an application context.41 * **Correct (within a view):**42```python43 @app.route('/profile')44 def profile():45 user_agent = request.headers.get('User-Agent')46 return f"Your user agent is: {user_agent}"47```48 * **Correct (outside a request, e.g., in a script):**49```python50 with app.app_context():51 # url_for() can be used here52 print(url_for('profile'))53```54 * **Incorrect (global scope):**55```python56 # This will raise a RuntimeError57 profile_url = url_for('profile')58```59* **NEVER call internal methods or attributes.** Anything prefixed with an underscore (e.g., `_find_error_handler`) is considered internal and subject to change without notice. Only use the public, documented API.6061## Security & Compliance6263All contributions must strictly adhere to the following security and compliance rules.6465* **License**: All code must be compatible with the **`BSD-3-Clause`** license.66* **NEVER set `debug=True` in production.** This is a critical vulnerability that can expose an interactive debugger and allow remote code execution. The `debug` flag must always be `False` in any production environment.67* **NEVER store sensitive data in the user session.** Session data is signed but **not encrypted**, meaning it can be decoded and read by the user. Do not store passwords, secrets, or any Personally Identifiable Information (PII) in the session.68* **`secret_key` must be secure**: The application's `secret_key` must be a long, random, and confidential string. A compromised `secret_key` allows attackers to forge sessions.69* **Always use `send_from_directory` to serve files.** This function is specifically designed to prevent path traversal attacks. Do not manually construct file paths with user-provided input to serve files.7071## Lessons Learned (Past Failures)7273The following principles are derived from past experience in maintaining and evolving the framework.7475* **Graceful API Evolution is Crucial**: Instead of making immediate breaking changes, the project uses compatibility wrappers and `DeprecationWarning`. This provides a smoother transition for downstream users and is the required pattern for evolving the public API.76* **Proactive Upstream Testing Prevents Breakages**: The `tests-dev` tox environment tests against the `main` branches of core dependencies (Werkzeug, Jinja2, etc.). This practice is essential for detecting and fixing compatibility issues *before* new versions of dependencies are released.77* **Separation of Concerns (Sans-IO) Improves Testability**: The core logic is "sans-IO" (agnostic to web protocols) and lives in `src/flask/sansio`. This architectural decision has proven effective for isolating and testing business logic independently from the web layer.7879## Repository Quirks & Gotchas8081These are non-obvious characteristics of the Flask repository that are essential to understand for effective development.8283* **"Global" Objects are Context-Locals**: The seemingly global objects like `request`, `g`, and `session` are not true globals. They are thread-safe (or task-safe) proxies that point to the object associated with the current, active request. This is a fundamental concept in Flask.84* **Middleware is Applied to `app.wsgi_app`**: You do not wrap the Flask `app` object to apply WSGI middleware. Instead, you wrap the internal `app.wsgi_app` attribute.85* **Signals are the Preferred Extension Mechanism**: The preferred way to hook into Flask's internal operations (like `request_started` or `app_context_pushed`) is by using Blinker signals. Avoid monkeypatching framework internals.86* **`uv` is used for Fast Dependency Management**: The project uses `uv` as a high-performance dependency resolver and `tox` runner (`tox-uv`). Be aware that this is the primary tool for managing environments, not standard `pip`.87* **Dual Architecture (Sans-IO vs. WSGI)**: The codebase is split into two distinct parts: the Sans-IO core in `src/flask/sansio` and the WSGI-specific application layer in `src/flask/app`. Understanding which layer you are working in is critical.8889## Execution Commands9091The agent is permitted to execute the following commands for development, testing, and maintenance.9293* **Run development server:**94```bash95 flask run96```97* **Run the full test suite:**98```bash99 tox100```101* **Run tests for a specific Python environment:**102```bash103 tox -e py3.12104```105* **Check for linting and style issues:**106```bash107 ruff check .108```109* **Automatically fix linting and style issues:**110```bash111 ruff check --fix .112```113* **Format code:**114```bash115 ruff format .116```117* **Build documentation:**118```bash119 tox -e docs120121```
One repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| originalankur/GenerateAgents.mdprojects/fastapi/AGENTS.md · 254 | AGENTS.md | setuptestlint-formatstyle+10 | 88/100 | 14 days ago | |
| originalankur/GenerateAgents.mdAGENTS.md · 254 | AGENTS.md | setupteststylearch+8 | 93/100 | 14 days ago | |
| originalankur/GenerateAgents.mdprojects/flagsmith/AGENTS.md · 254 | AGENTS.md | setuptestlint-formatstyle+9 | 88/100 | 14 days ago | |
| originalankur/GenerateAgents.mdprojects/dspy/AGENTS.md · 254 | AGENTS.md | setupbuildtestlint-format+11 | 96/100 | 14 days ago |
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| unoplat/unoplat-code-confluenceunoplat-code-confluence-frontend/AGENTS.md · 95 | AGENTS.md | setupbuildtestlint-format+6 | 100/100 | 13 days ago | |
| n8n-io/n8npackages/@n8n/agents/AGENTS.md · 201k | AGENTS.md | buildteststylearch+3 | 100/100 | 14 days ago | |
| deepseek-ai/deepseek-harnessnative/landlock-run/AGENTS.md · 104k | AGENTS.md | setupteststylearch+3 | 100/100 | today | |
| vllm-project/vllmAGENTS.md · 89k | AGENTS.md | setuptestlint-formatstyle+5 | 100/100 | 14 days ago | |
| SkeneTechnologies/skene-cookbookAGENTS.md · 52 | AGENTS.md | setupbuildtestlint-format+7 | 100/100 | 13 days ago | |
| OnlyTerp/prompt-cache-skillsAGENTS.md · 113 | AGENTS.md | setupbuildtestlint-format+5 | 100/100 | 14 days ago | |
| netdata/netdatasrc/go/plugin/ibm.d/AGENTS.md · 80k | AGENTS.md | buildtestlint-formatarch+3 | 99/100 | today | |
| unoplat/unoplat-code-confluenceunoplat-code-confluence-query-engine/AGENTS.md · 95 | AGENTS.md | setupbuildtestlint-format+5 | 98/100 | 13 days ago |
A badge carrying the measured quality of the strongest agent config file in this repository, out of 100. It reads from this index every time somebody loads your page, so it changes when the measurement changes and there is nothing to keep up to date. Free, no account, and the value is not something you or we can set by hand.
[](https://rulestack.kynth.studio/configs/originalankur-generateagents-md-projects-flask-agents)Would rather not hotlink us? Every badge is also served in shields.io’s endpoint schema, so shields renders the image and your readers never talk to our domain:
Published by Toolproof, the masthead over this index and eight others. The method behind the number is at toolproof.kynth.studio/methodology, and the whole thing is readable as JSON with no key at /api.