flask

GitHub

提供Flask Web应用开发的最佳实践,涵盖路由、蓝图、扩展初始化和测试策略,旨在构建结构清晰、易于测试且安全的后端服务。

.claude/skills/flask/SKILL.md microsoft/debugpy

触发场景

使用Flask框架开发Web应用或API 配置Flask路由和蓝图结构 编写Flask单元测试或集成测试

安装

npx skills add microsoft/debugpy --skill flask -g -y
更多选项

非标准路径

npx skills add https://github.com/microsoft/debugpy/tree/main/.claude/skills/flask -g -y

不安装直接使用

npx skills use microsoft/debugpy@flask

指定 Agent (Claude Code)

npx skills add microsoft/debugpy --skill flask -a claude-code -g -y

安装 repo 全部 skill

npx skills add microsoft/debugpy --all -g -y

预览 repo 内 skill

npx skills add microsoft/debugpy --list

SKILL.md

Frontmatter
{
    "name": "flask",
    "description": "Best practices for Flask web development including routing, blueprints, and testing."
}

Skill: Flask

Best practices for Flask web development including routing, blueprints, and testing.

When to Use

Apply this skill when building Flask web applications or APIs — routing, blueprints, extensions, and testing.

Project Structure

  • Use the application factory pattern (create_app()) to avoid global state and enable testing.
  • Organize features into Blueprints; register them in the factory.
  • Keep configuration in a config.py with classes like DevelopmentConfig, ProductionConfig.

Routing and Views

  • Prefer explicit HTTP method decorators (@app.get, @app.post) over generic @app.route with methods=[...].
  • Validate request data early; return 400 errors for malformed input before processing.
  • Use flask.abort() with appropriate HTTP codes rather than returning error responses manually.

Extensions

  • Initialize extensions lazily with ext.init_app(app) inside the factory, not at module level.
  • Common extensions: Flask-SQLAlchemy, Flask-Migrate, Flask-Login, Flask-WTF, Flask-CORS.

Testing

  • Use app.test_client() for HTTP-level tests and app.test_request_context() for unit tests.
  • Use pytest fixtures to create the app and client; scope appropriately (session for the app, function for the client).
  • Set TESTING=True and use a separate test database.

Pitfalls

  • Never use the development server (app.run()) in production — use Gunicorn or uWSGI.
  • Avoid storing mutable state on the app object; use g for request-scoped data.
  • Never hardcode SECRET_KEY — load from environment variables.

版本历史

  • e5743d3 当前 2026-08-20 17:01

同 Skill 集合

.claude/skills/click/SKILL.md
.claude/skills/django/SKILL.md
.claude/skills/jinja2/SKILL.md
.claude/skills/numpy/SKILL.md
.claude/skills/pytest/SKILL.md
.claude/skills/requests/SKILL.md

元信息

文件数
0
版本
e5743d3
Hash
9efc59cb
收录时间
2026-08-20 17:01

首页 - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-28 23:44
浙ICP备14020137号-1 $访客地图$