

Also from Kynth Studios


Also from Kynth Studios


Also from Kynth Studios
1# LLM Context Guide for Apache Superset23Apache Superset is a data visualization platform with Flask/Python backend and React/TypeScript frontend.45## Run Pre-commit Before Pushing67Always run pre-commit against the files changed by the current branch before8pushing. This matches CI and keeps unrelated failures already present on9`master` from blocking otherwise independent work.1011```bash12# Stage your changes first13git add .1415# Run pre-commit on staged files16pre-commit run1718# If there are auto-fixes, stage them and commit19git add .20git commit --amend # or new commit21```2223Use `pre-commit run --all-files` when auditing or repairing the repository-wide24baseline. If that check finds failures in files untouched by the current branch,25fix them in a separate branch rather than adding unrelated changes to the26current pull request.2728Common pre-commit failures:29- **Formatting** - black, oxfmt, eslint will auto-fix30- **Type errors** - mypy failures need manual fixes31- **Linting** - ruff, pylint issues need manual fixes3233## ⚠️ CRITICAL: Ongoing Refactors (What NOT to Do)3435**These migrations are actively happening - avoid deprecated patterns:**3637### Frontend Modernization38- **NO `any` types** - Use proper TypeScript types39- **NO JavaScript files** - Convert to TypeScript (.ts/.tsx)40- **Use @superset-ui/core** - Don't import Ant Design directly, prefer Ant Design component wrappers from @superset-ui/core/components41- **Use antd theming tokens** - Prefer antd tokens over legacy theming tokens42- **Avoid custom css and styles** - Follow antd best practices and avoid styling and custom CSS whenever possible4344### Testing Strategy Migration45- **Prefer unit tests** over integration tests46- **Prefer integration tests** over end-to-end tests47- **Use Playwright for E2E tests** - Migrating from Cypress48- **Cypress is deprecated** - Will be removed once migration is completed49- **Use Jest + React Testing Library** for component testing50- **Use `test()` instead of `describe()`** - Follow [avoid nesting when testing](https://kentcdodds.com/blog/avoid-nesting-when-youre-testing) principles5152### Backend Type Safety53- **Add type hints** - All new Python code needs proper typing54- **MyPy compliance** - Run `pre-commit run mypy` to validate55- **SQLAlchemy typing** - Use proper model annotations5657### UUID Migration58- **Prefer UUIDs over auto-incrementing IDs** - New models should use UUID primary keys59- **External API exposure** - Use UUIDs in public APIs instead of internal integer IDs60- **Existing models** - Add UUID fields alongside integer IDs for gradual migration6162## Security and Threat Model6364Before evaluating any code path for security issues, read [`SECURITY.md`](SECURITY.md). It is the canonical, authoritative source for Apache Superset's security model and is referenced by both human reporters and automated scanners.6566In short, the test for whether a finding is in scope is one question:6768> *Does it let a principal perform an action the role and capability matrix in `SECURITY.md` does not entitle them to?*6970If yes, it is in scope. If no, it is not.7172The three trust boundaries are:73741. **The Admin role** is a fully trusted operational principal. Anything an Admin can do through documented configuration, API, or UI is an intended capability, not a vulnerability.752. **The operator** owns deployment-time decisions (secrets, network exposure, feature-flag selection, connector and codec choices, notification destinations, third-party plugins). Misconfiguration at this layer is a deployment defect, not a Superset vulnerability.763. **The codebase** is responsible for enforcing the role and capability matrix wherever it exposes functionality to a principal: API routes, command and DAO layers, UI handlers, background jobs, and any other entry point. A missing or incorrect enforcement check is in scope no matter where it lives.7778The security model assumes that operator-controlled infrastructure, including the metadata database, cache backends, message brokers, secret stores, and deployment environment, remains within the operator's trust boundary. Vulnerabilities must demonstrate a security boundary violation by an attacker who does not already control those systems.7980Route-level authorization in this codebase uses one of three Flask-AppBuilder decorators depending on the route type:8182- `@protect()` for REST API routes (`ModelRestApi` / `BaseApi`)83- `@has_access_api` for legacy view routes84- `@has_access` for legacy HTML view routes8586Object-level authorization via `security_manager.raise_for_access(...)` applies to data-bearing resources: dashboards, charts, datasets and datasources, queries, database and table access, and query contexts. Other resources (annotations, tags, CSS templates, reports, RLS rules, and similar) rely on the route-level decorator plus DAO `base_filters` for ownership scoping; the absence of `raise_for_access` on these resources is by design, not a finding. Code that omits the per-object gate on a route that returns or mutates a specific data-bearing object is in scope; code that follows the correct pattern for its resource class can still contain injection, SSRF, XSS, or other classes of finding unrelated to authorization, which are evaluated separately.8788The full role and capability matrix, in-scope and out-of-scope class lists, and CVE aggregation rules are in [`SECURITY.md`](SECURITY.md). Defer to that document for any specifics.8990**Requirements for findings filed by automated tooling**9192Automated scanners (LLM-based code scanners, static analyzers, dependency tools) that file findings against this codebase must, in each finding, name:93941. The specific role and capability matrix row in [`SECURITY.md`](SECURITY.md) the finding believes is violated.952. The principal the finding assumes the attacker holds (Public, Gamma, sql_lab, Alpha, Admin, Embedded guest token, or a custom role with explicit capability grants).9697Findings that cannot identify both should be filed as questions, not vulnerabilities. This requirement exists to ensure every reported issue is testable against the published security model and to keep speculative or pattern-match-only reports out of the triage queue.9899## Key Directories100101```102superset/103├── superset/ # Python backend (Flask, SQLAlchemy)104│ ├── views/api/ # REST API endpoints105│ ├── models/ # Database models106│ └── connectors/ # Database connections107├── superset-frontend/src/ # React TypeScript frontend108│ ├── components/ # Reusable components109│ ├── explore/ # Chart builder110│ ├── dashboard/ # Dashboard interface111│ └── SqlLab/ # SQL editor112├── superset-frontend/packages/113│ └── superset-ui-core/ # UI component library (USE THIS)114├── tests/ # Python/integration tests115├── docs/ # Documentation (UPDATE FOR CHANGES)116└── UPDATING.md # Breaking changes log117```118119## Code Standards120121### TypeScript Frontend122- **Avoid `any` types** - Use proper TypeScript, reuse existing types123- **Functional components** with hooks124- **@superset-ui/core** for UI components (not direct antd)125- **Jest** for testing (NO Enzyme)126- **Redux** for global state where it exists, hooks for local127128### Python Backend129- **Type hints required** for all new code130- **MyPy compliant** - run `pre-commit run mypy`131- **SQLAlchemy models** with proper typing132- **pytest** for testing133134### Apache License Headers135- **New files require ASF license headers** - When creating new code files, include the standard Apache Software Foundation license header136- **LLM instruction files are excluded** - Files like AGENTS.md, CLAUDE.md, etc. are in `.rat-excludes` to avoid header token overhead137138### Code Comments139- **Avoid time-specific language** - Don't use words like "now", "currently", "today" in code comments as they become outdated140- **Write timeless comments** - Comments should remain accurate regardless of when they're read141142## Documentation Requirements143144- **docs/**: Update for any user-facing changes145- **UPDATING.md**: Add breaking changes here146- **Docstrings**: Required for new functions/classes147148## Developer Portal: Storybook-to-MDX Documentation149150The Developer Portal auto-generates MDX documentation from Storybook stories. **Stories are the single source of truth.**151152### Core Philosophy153- **Fix issues in the STORY, not the generator** - When something doesn't render correctly, update the story file first154- **Generator should be lightweight** - It extracts and passes through data; avoid special cases155- **Stories define everything** - Props, controls, galleries, examples all come from story metadata156157### Story Requirements for Docs Generation158- Use `export default { title: '...' }` (inline), not `const meta = ...; export default meta;`159- Name interactive stories `Interactive${ComponentName}` (e.g., `InteractiveButton`)160- Define `args` for default prop values161- Define `argTypes` at the story level (not meta level) with control types and descriptions162- Use `parameters.docs.gallery` for size×style variant grids163- Use `parameters.docs.sampleChildren` for components that need children164- Use `parameters.docs.liveExample` for custom live code blocks165- Use `parameters.docs.staticProps` for complex object props that can't be parsed inline166167### Generator Location168- Script: `docs/scripts/generate-superset-components.mjs`169- Wrapper: `docs/src/components/StorybookWrapper.jsx`170- Output: `docs/developer_docs/components/`171172## Architecture Patterns173174### Security & Features175- **Security model**: see the top-level [Security and Threat Model](#security-and-threat-model) section and [`SECURITY.md`](SECURITY.md)176- **RBAC**: Role-based access via Flask-AppBuilder177- **Feature flags**: Control feature rollouts178- **Row-level security**: SQL-based data access control179180## Test Utilities181182### Python Test Helpers183- **`SupersetTestCase`** - Base class in `tests/integration_tests/base_tests.py`184- **`@with_config`** - Config mocking decorator185- **`@with_feature_flags`** - Feature flag testing186- **`login_as()`, `login_as_admin()`** - Authentication helpers187- **`create_dashboard()`, `create_slice()`** - Data setup utilities188189### TypeScript Test Helpers190- **`superset-frontend/spec/helpers/testing-library.tsx`** - Custom render() with providers191- **`createWrapper()`** - Redux/Router/Theme wrapper192- **`selectOption()`** - Select component helper193- **React Testing Library** - NO Enzyme (removed)194195### Test Database Patterns196- **Mock patterns**: Use `MagicMock()` for config objects, avoid `AsyncMock` for synchronous code197- **API tests**: Update expected columns when adding new model fields198199### Running Tests200```bash201# Frontend202npm run test # All tests203npm run test -- filename.test.tsx # Single file204205# E2E Tests (Playwright - NEW)206npm run playwright:test # All Playwright tests207npm run playwright:ui # Interactive UI mode208npm run playwright:headed # See browser during tests209npx playwright test tests/auth/login.spec.ts # Single file210npm run playwright:debug tests/auth/login.spec.ts # Debug specific file211212# E2E Tests (Cypress - DEPRECATED)213cd superset-frontend/cypress-base214npm run cypress-run-chrome # All Cypress tests (headless)215npm run cypress-debug # Interactive Cypress UI216217# Backend218pytest # All tests219pytest tests/unit_tests/specific_test.py # Single file220pytest tests/unit_tests/ # Directory221222# If pytest fails with database/setup issues, ask the user to run test environment setup223```224225## Environment Validation226227**Quick Setup Check (run this first):**228229```bash230# Verify Superset is running231curl -f http://localhost:8088/health || echo "❌ Setup required - see https://superset.apache.org/docs/contributing/development#working-with-llms"232```233234**If health checks fail:**235"It appears you aren't set up properly. Please refer to the [Working with LLMs](https://superset.apache.org/docs/contributing/development#working-with-llms) section in the development docs for setup instructions."236237**Key Project Files:**238- `superset-frontend/package.json` - Frontend build scripts (`npm run dev` on port 9000, `npm run test`, `npm run lint`)239- `pyproject.toml` - Python tooling (ruff, mypy configs)240- `requirements/` folder - Python dependencies (base.txt, development.txt)241242## SQLAlchemy Query Best Practices243- **Use negation operator**: `~Model.field` instead of `== False` to avoid ruff E712 errors244- **Example**: `~Model.is_active` instead of `Model.is_active == False`245246## Pull Request Guidelines247248**When creating pull requests:**2492501. **Read the current PR template**: Always check `.github/PULL_REQUEST_TEMPLATE.md` for the latest format2512. **Use the template sections**: Include all sections from the template (SUMMARY, BEFORE/AFTER, TESTING INSTRUCTIONS, ADDITIONAL INFORMATION)2523. **Follow PR title conventions**: Use [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)253 - Format: `type(scope): description`254 - Example: `fix(dashboard): load charts correctly`255 - Types: `fix`, `feat`, `docs`, `style`, `refactor`, `perf`, `test`, `chore`256257**Important**: Always reference the actual template file at `.github/PULL_REQUEST_TEMPLATE.md` instead of using cached content, as the template may be updated over time.258259## Pre-commit Validation260261**Use pre-commit hooks for quality validation:**262263```bash264# Install hooks265pre-commit install266267# IMPORTANT: Stage your changes first!268git add . # Pre-commit only checks staged files269270# Quick validation (faster than --all-files)271pre-commit run # Staged files only272pre-commit run mypy # Python type checking273pre-commit run format # Code formatting274pre-commit run eslint # Frontend linting275```276277**Important pre-commit usage notes:**278- **Stage files first**: Run `git add .` before `pre-commit run` to check only changed files (much faster)279- **Virtual environment**: Activate your Python virtual environment before running pre-commit280```bash281 # Common virtual environment locations (yours may differ):282 source .venv/bin/activate # if using .venv283 source venv/bin/activate # if using venv284 source ~/venvs/superset/bin/activate # if using a central location285```286 If you get a "command not found" error, ask the user which virtual environment to activate287- **Auto-fixes**: Some hooks auto-fix issues (e.g., trailing whitespace). Re-run after fixes are applied288289## Common File Patterns290291### API Structure292- **`/api.py`** - REST endpoints with decorators and OpenAPI docstrings293- **`/schemas.py`** - Marshmallow validation schemas for OpenAPI spec294- **`/commands/`** - Business logic classes with @transaction() decorators295- **`/models/`** - SQLAlchemy database models296- **OpenAPI docs**: Auto-generated at `/swagger/v1` from docstrings and schemas297298### Migration Files299- **Location**: `superset/migrations/versions/`300- **Naming**: `YYYY-MM-DD_HH-MM_hash_description.py`301- **Utilities**: Use helpers from `superset.migrations.shared.utils` for database compatibility302- **Pattern**: Import utilities instead of raw SQLAlchemy operations303304## Platform-Specific Instructions305306- **[CLAUDE.md](CLAUDE.md)** - For Claude/Anthropic tools307- **[.github/copilot-instructions.md](.github/copilot-instructions.md)** - For GitHub Copilot308- **[GEMINI.md](GEMINI.md)** - For Google Gemini tools309- **[GPT.md](GPT.md)** - For OpenAI/ChatGPT tools310- **[.cursor/rules/dev-standard.mdc](.cursor/rules/dev-standard.mdc)** - For Cursor editor311312---313314**LLM Note**: This codebase is actively modernizing toward full TypeScript and type safety. Always run `pre-commit run` to validate changes. Follow the ongoing refactors section to avoid deprecated patterns.315
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 |
|---|---|---|---|---|---|
| apache/superset.cursor/rules/dev-standard.mdc · 74k | Cursor rules | setuptestlint-formatstyle+7 | 77/100 | 11 days ago | |
| apache/supersetsuperset/mcp_service/CLAUDE.md · 74k | CLAUDE.md | buildteststylearch+7 | 64/100 | 13 days ago |
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| 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 | |
| code-yeongyu/oh-my-openagentpackages/web/AGENTS.md · 68k | AGENTS.md | setupbuildtestlint-format+6 | 100/100 | 13 days ago | |
| TryGhost/Ghoste2e/AGENTS.md · 55k | AGENTS.md | setupteststylearch+2 | 100/100 | today | |
| vllm-project/vllmAGENTS.md · 89k | AGENTS.md | setuptestlint-formatstyle+5 | 100/100 | 14 days ago | |
| mui/material-uiAGENTS.md · 99k | AGENTS.md | setupbuildtestlint-format+9 | 100/100 | 14 days ago | |
| unoplat/unoplat-code-confluenceunoplat-code-confluence-frontend/AGENTS.md · 95 | AGENTS.md | setupbuildtestlint-format+6 | 100/100 | 13 days ago | |
| OnlyTerp/prompt-cache-skillsAGENTS.md · 113 | AGENTS.md | setupbuildtestlint-format+5 | 100/100 | 14 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/apache-superset-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.