# RuntimeError: Working outside of application context.

This typically means that you attempted to use functionality that needed
the current application.

- **ID:** `python/flask-cli-context-missing`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

A Flask CLI command or script accesses current_app/db without pushing an app context; @app.cli.command does not push one automatically in all cases.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.x | active | — | — |

## Workarounds

1. **** (92% success)
   ```
   Use @with_appcontext decorator on CLI commands
   ```
2. **** (93% success)
   ```
   with app.app_context(): db.create_all() in scripts
   ```

## Dead Ends

- **** — Breaks application factory pattern and multi-app tests. (60% fail)
- **** — Circular imports and stale config. (65% fail)
