skills/data-context/SKILL.md
This skill should be used when the user asks to 'set up data analysis for our database', 'extract tribal knowledge about dataset', 'generate data skill', 'document this dataset', 'what does this column mean', 'create data dictionary', 'help me understand this data schema', 'capture domain knowledge about our data', or needs to create a reusable data context skill from dataset expertise.
npx skillsauth add edwinhu/workflows data-contextInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Extract tribal knowledge about a dataset or database and generate a reusable data context skill.
<EXTREMELY-IMPORTANT> ## The Iron Law of Data ContextYOU MUST interview the user before generating ANY skill content. This is not negotiable.
You MUST NOT:
If you're about to write a skill based on your assumptions, STOP. Interview first. </EXTREMELY-IMPORTANT>
Trigger: No existing data context skill for this project/dataset.
Create a new data context skill from scratch by interviewing the user about their data.
Trigger: Existing data context skill exists, user wants to add a new domain or update.
Read existing skill, identify gaps, interview for the new domain, merge into existing skill.
Before interviewing, check for existing data access skills that already encode tribal knowledge:
1. READ existing skills: /wrds, /lseg-data, or any project-local data skills
2. IDENTIFY what they already cover (table names, filters, field mappings, gotchas)
3. DO NOT re-document what existing skills handle
4. FOCUS the interview on the project-specific layer:
- Which specific tables/fields from WRDS or LSEG does THIS study use?
- How are identifiers linked across sources? (permno ↔ gvkey, RIC ↔ ISIN ↔ cusip)
- What sample filters define the study universe? (date range, exchange, firm type)
- What derived variables or transformations are project-specific?
The generated data context skill should reference existing skills rather than duplicate them:
## Data Sources
| Source | Skill | Tables/Fields Used |
|--------|-------|--------------------|
| WRDS | `/wrds` | comp.funda (at, lt, ceq), crsp.msf (ret, prc) |
| LSEG | `/lseg-data` | TR.F.TotRevenue, TR.GICSSector |
| Local | DuckDB | data/processed/merged_panel.parquet |
For connection details and critical filters, see the referenced skills.
1. DISCOVER data sources
→ What databases/files/APIs? Connection details?
→ For each: what dialect? (PostgreSQL, DuckDB, SQLite, Snowflake, etc.)
→ IMPORTANT: If user mentions WRDS or LSEG, read the corresponding skill first
and ask only about project-specific usage, not general access patterns
2. MAP entities
→ What are the core entities? (users, transactions, products, etc.)
→ How do they relate? (foreign keys, join paths)
→ CRITICAL: Disambiguate entity names
- "user" vs "account" vs "customer" — are these the same?
- "order" vs "transaction" vs "purchase" — clarify overlaps
- Document the canonical name and any aliases
3. DEFINE key metrics
→ What are the business-critical metrics?
→ For each metric:
- Exact definition (SQL or formula)
- Known edge cases
- Common misinterpretations
- Time grain (daily, monthly, etc.)
4. DOCUMENT data hygiene
→ Known data quality issues
→ Fields that lie (e.g., "created_at" that's actually "imported_at")
→ Nulls that mean something specific
→ Enums/codes that need translation
→ Date ranges with reliable data vs backfill periods
5. CAPTURE common gotchas
→ Joins that explode (many-to-many lurking as one-to-many)
→ Filters that are always needed (e.g., "WHERE is_deleted = false")
→ Time zones and their traps
→ Slowly changing dimensions
→ Tables that look useful but aren't (deprecated, partial, test data)
6. COLLECT common query patterns
→ Frequently needed aggregations
→ Standard date filters or cohort definitions
→ Boilerplate CTEs that everyone copies
Ask questions in batches of 3-5. Don't overwhelm with everything at once.
Round 1: Data Sources
Round 2: Core Entities (after Round 1 answers)
Round 3: Metrics & Definitions (after Round 2 answers)
Round 4: Data Quality & Gotchas (after Round 3 answers)
Round 5: Common Patterns (after Round 4 answers)
After the interview, generate a skill with this structure:
project-name/
├── .claude/
│ └── skills/
│ └── data-context/
│ ├── SKILL.md # Main skill file
│ └── references/
│ ├── entities.md # Entity definitions and relationships
│ ├── metrics.md # Metric definitions with SQL/formulas
│ └── gotchas.md # Data quality issues and common pitfalls
---
name: [project]-data-context
description: "Data context for [project]. Entity definitions, metric calculations, data quality notes, and common patterns for [data domain]."
---
# [Project] Data Context
## Data Sources
| Source | Skill/Dialect | Tables/Fields Used |
|--------|---------------|--------------------|
| [WRDS] | `/wrds` | [specific tables and fields for this project] |
| [LSEG] | `/lseg-data` | [specific fields for this project] |
| [Local] | [DuckDB/CSV/Parquet] | [file paths or database] |
For connection details and critical filters, see the referenced skill. This context covers only project-specific usage.
## Entity Map
[Entity relationship summary — which entities exist, how they connect]
See `references/entities.md` for full definitions.
## Key Metrics
[Top 3-5 metrics with brief definitions]
See `references/metrics.md` for exact calculations and edge cases.
## Critical Gotchas
[Top 3-5 gotchas that catch analysts]
See `references/gotchas.md` for full list.
## Common Patterns
[Frequently used query snippets or data access patterns]
For each reference file, include:
Before writing skill files, execute this gate:
Skipping this gate produces a skill based on your assumptions, not the user's knowledge. That skill will mislead every future analysis.
Before finalizing the skill:
When adding to an existing data context skill:
.claude/skills/data-context/ in the project rootds-delegate will have access to it automaticallyrevenue may be gross, net, or recognized; a user_id foreign key does not say whether users can hold multiple active accounts. A metric definition or relationship cardinality inferred from names is an unverified claim presented as fact — every downstream analysis that loads the generated skill inherits the error. The interview takes 10 minutes; weeks of wrong analysis is what it prevents./wrds, and LSEG field prefixes by /lseg-data. Re-documenting them here duplicates and drifts; document only the project-specific tables, fields, and filters THIS project uses.development
Build the meeting-level proxy-voting × ownership panel on the WRDS SGE grid — ISS N-PX fund votes reduced to (item × block) direction cells, joined to institutional and mutual-fund ownership. Use when working with risk.voteanalysis_npx, N-PX fund-level votes, ISS→CRSP fund linking, index/passive/active voting blocks, or a proxy-voting panel that needs ownership attached.
development
Use when "CRSP CIZ", "CRSP v2", "CRSP flat file format 2.0", "crsp.dsf_v2 / msf_v2", "StkDlySecurityData", "StkMthSecurityData", "StkSecurityInfoHist", "stocknames_v2", "DlyRet / MthRet / DlyPrc / MthPrc", "SHRCD or EXCHCD equivalent in new CRSP", "SIZ to CIZ migration", "CRSP data after 2024", "CRSP delisting returns", "CRSP cumulative adjustment factors", "CRSP index INDNO / INDFAM", or any CRSP stock/index query where the legacy SIZ column names no longer exist.
development
Use when linking or deduping datasets by entity name rather than a shared key — 'fuzzy match', 'fuzzy name matching', 'entity resolution', 'record linkage', 'match company/person names', 'dedupe entity names', 'name-based join', 'bridge identifiers' (CIK ↔ permno ↔ gvkey ↔ wficn ↔ EIN ↔ personid), or any use of char n-gram TF-IDF, cosine similarity on names, `sparse_dot_topn`, or RapidFuzz at scale.
development
Use when building a publication-quality table in Python — 'regression table', 'results table', 'summary statistics table', 'etable', 'coefplot', 'great_tables', 'GT', 'gt table', 'format a table for the paper', 'export table to LaTeX/HTML', significance stars, spanners, or column formatting for a table headed into a paper, slide deck, or notebook.