Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: create-astrodb
description: Create an empty SQLite AstroDB database from a Felis-validated schema.yaml, following the astrodb-template-db file structure. Use this skill whenever the user wants to create a database, initialize a SQLite database, build an AstroDB, or has just finished generating a Felis schema and wants to turn it into a working database. Always trigger after generate-felis-schema completes, or when the user says "create database", "make database", "initialize database", "create sqlite", "make sqlite", "build the database", "create astrodb", "initialize astrodb", or "set up the database". Do NOT skip this skill just because a schema.yaml already exists — this skill is exactly what handles that case.
name: astrodb-create-database
description: Create an empty SQLite AstroDB database from a Felis-validated schema.yaml, following the astrodb-template-db file structure. Use this skill whenever the user wants to create a database, initialize a SQLite database, build an AstroDB, or has just finished generating a Felis schema and wants to turn it into a working database. Always trigger after astrodb-generate-schema completes, or when the user says "create database", "make database", "initialize database", "create sqlite", "make sqlite", "build the database", "create astrodb", "initialize astrodb", or "set up the database". Do NOT skip this skill just because a schema.yaml already exists — this skill is exactly what handles that case.
compatibility: python, astrodbkit, felis
---

Expand All @@ -12,15 +12,15 @@ using `astrodbkit`.

## Prerequisites

This skill requires a schema.yaml that has **passed** `felis validate`. The generate-felis-schema
This skill requires a schema.yaml that has **passed** `felis validate`. The astrodb-generate-schema
skill always runs this validation as its final step, so if the user just completed that workflow
the schema is already validated. If there is any doubt, validate before proceeding.

## Step 1: Locate the schema.yaml

Check (in order):
1. A path the user explicitly stated in the conversation
2. `tmp/<schema-name>-schema.yaml` — the default output of generate-felis-schema
2. `tmp/<schema-name>-schema.yaml` — the default output of astrodb-generate-schema
3. `schema.yaml` in the current working directory

If you cannot find the file, ask the user for the path before continuing.
Expand All @@ -36,7 +36,7 @@ felis validate <schema-path>
```

**If validation fails:** show the error to the user and stop — do not create the database from
a broken schema. Offer to go back to generate-felis-schema to fix the issue.
a broken schema. Offer to go back to astrodb-generate-schema to fix the issue.

**If validation passes:** proceed.

Expand Down Expand Up @@ -122,7 +122,7 @@ python <skill-dir>/scripts/create_db.py --schema ... --db-path ...
```

**If the script fails**, read the traceback carefully:
- `felis.datamodel` errors → schema is not valid Felis; offer to re-run generate-felis-schema
- `felis.datamodel` errors → schema is not valid Felis; offer to re-run astrodb-generate-schema
- `sqlite3` errors → check that the db path is writable
- `ImportError` for astrodbkit → astrodbkit is not installed; run `uv add astrodbkit`

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"skill_name": "create-astrodb",
"skill_name": "astrodb-create-db",
"evals": [
{
"id": 0,
"prompt": "I just ran the generate-felis-schema skill and it wrote my schema to /tmp/BrownDwarfSurvey-schema.yaml — felis validate passed. Now I want to set up the actual database. Please create it for me in /tmp/bdsurvey-project/.",
"prompt": "I just ran the astrodb-generate-schema skill and it wrote my schema to /tmp/BrownDwarfSurvey-schema.yaml — felis validate passed. Now I want to set up the actual database. Please create it for me in /tmp/bdsurvey-project/.",
"expected_output": "The skill runs felis validate on the schema, creates /tmp/bdsurvey-project/ with data/reference/ and data/source/ subdirectories, copies schema.yaml, creates database.toml, runs create_db.py to produce BrownDwarfSurvey.sqlite, runs generate_tests.py to create a tests/ directory with adapted test files (including test_contents_spectraltypes.py for the non-template SpectralTypes table), runs pytest to confirm all tests pass, and reports all file paths.",
"files": ["/tmp/BrownDwarfSurvey-schema.yaml"],
"assertions": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: generate-felis-schema
description: Generate a Felis YAML schema for a user-provided astronomical data file, using the output of the match-schema and validate-schema-mapping skills. Produces a standards-compliant schema.yaml covering each mapped table and column, with proper Felis syntax (@id references, datatypes, nullable flags, units, and foreign key constraints). Always use this skill when the user has completed a schema mapping (with or without validation) and wants to produce a Felis YAML, create a schema file for their data, generate schema.yaml, export their mapping as a schema, or document their database tables. Also trigger when the user says "generate schema", "create felis yaml", "make a schema file", or "turn this mapping into a schema".
name: astrodb-generate-schema
description: Generate a Felis YAML schema for a user-provided astronomical data file, using the output of the astrodb-match-schema and astrodb-validate-schema-mapping skills. Produces a standards-compliant schema.yaml covering each mapped table and column, with proper Felis syntax (@id references, datatypes, nullable flags, units, and foreign key constraints). Always use this skill when the user has completed a schema mapping (with or without validation) and wants to produce a Felis YAML, create a schema file for their data, generate schema.yaml, export their mapping as a schema, or document their database tables. Also trigger when the user says "generate schema", "create felis yaml", "make a schema file", or "turn this mapping into a schema".
compatibility: python, pyyaml
metadata:
authors: ["Claude"]
Expand All @@ -24,20 +24,20 @@ Read `references/felis-syntax.md` for the exact syntax rules and examples before

You need at minimum:

1. **The mapping table** from `match-schema` — rows like:
1. **The mapping table** from `astrodb-match-schema` — rows like:
`Input Column | Description | Units | Type | DB Table | DB Field | Confidence | Notes`

2. **Schema name** — what to call the new schema (e.g. the dataset name or survey name).
If not provided, derive it from the data file name or ask the user.

Optionally also accept:

3. **The validation report** from `validate-schema-mapping` — identifies nullable violations
3. **The validation report** from `astrodb-validate-schema-mapping` — identifies nullable violations
and type mismatches. If provided, use it to set `nullable` flags and resolve type conflicts.

4. **The data file path** — used to infer datatypes for any columns that need them.

If the user hasn't run `validate-schema-mapping` yet, note that the schema will be generated
If the user hasn't run `astrodb-validate-schema-mapping` yet, note that the schema will be generated
without null/type checks, and suggest they validate before ingesting.

## Step 1: Identify unmatched and problematic columns
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"skill_name": "generate-felis-schema",
"skill_name": "astrodb-generate-schema",
"evals": [
{
"id": 1,
"prompt": "I've just run match-schema on my nearby brown dwarf astrometry catalog and everything matched cleanly. Here's the mapping:\n\n| Input Column | Description | Units | Type | DB Table | DB Field | Confidence | Notes |\n|---|---|---|---|---|---|---|---|\n| source_id | Primary source identifier | — | str | Sources | source | High | Name pattern maps to primary identifier |\n| ra | Right ascension (J2000) | deg | float64 | Sources | ra_deg | High | Name + units match |\n| dec | Declination (J2000) | deg | float64 | Sources | dec_deg | High | Name + units match |\n| plx | Parallax | mas | float64 | Parallaxes | parallax_mas | High | Name + units match |\n| e_plx | Parallax uncertainty | mas | float64 | Parallaxes | parallax_error | High | Error prefix variant |\n| pmRA | Proper motion in RA | mas/yr | float64 | ProperMotions | pm_ra | High | Name + units match |\n| e_pmRA | Uncertainty in pmRA | mas/yr | float64 | ProperMotions | pm_ra_error | High | Error prefix |\n| pmDE | Proper motion in Dec | mas/yr | float64 | ProperMotions | pm_dec | High | Name + units match |\n| e_pmDE | Uncertainty in pmDE | mas/yr | float64 | ProperMotions | pm_dec_error | High | Error prefix |\n| ref | Publication reference | — | str | Publications | reference | High | Name + description match |\n\nThe validation report came back clean — no nullable violations, no type mismatches. Can you generate the Felis YAML schema for this? Call it 'BrownDwarfAstrometry'.",
"prompt": "I've just run astrodb-match-schema on my nearby brown dwarf astrometry catalog and everything matched cleanly. Here's the mapping:\n\n| Input Column | Description | Units | Type | DB Table | DB Field | Confidence | Notes |\n|---|---|---|---|---|---|---|---|\n| source_id | Primary source identifier | — | str | Sources | source | High | Name pattern maps to primary identifier |\n| ra | Right ascension (J2000) | deg | float64 | Sources | ra_deg | High | Name + units match |\n| dec | Declination (J2000) | deg | float64 | Sources | dec_deg | High | Name + units match |\n| plx | Parallax | mas | float64 | Parallaxes | parallax_mas | High | Name + units match |\n| e_plx | Parallax uncertainty | mas | float64 | Parallaxes | parallax_error | High | Error prefix variant |\n| pmRA | Proper motion in RA | mas/yr | float64 | ProperMotions | pm_ra | High | Name + units match |\n| e_pmRA | Uncertainty in pmRA | mas/yr | float64 | ProperMotions | pm_ra_error | High | Error prefix |\n| pmDE | Proper motion in Dec | mas/yr | float64 | ProperMotions | pm_dec | High | Name + units match |\n| e_pmDE | Uncertainty in pmDE | mas/yr | float64 | ProperMotions | pm_dec_error | High | Error prefix |\n| ref | Publication reference | — | str | Publications | reference | High | Name + description match |\n\nThe validation report came back clean — no nullable violations, no type mismatches. Can you generate the Felis YAML schema for this? Call it 'BrownDwarfAstrometry'.",
"expected_output": "A valid Felis YAML schema file saved to /tmp/BrownDwarfAstrometry-schema.yaml. The schema should: (1) have name: BrownDwarfAstrometry at the top level; (2) include tables for Sources, Parallaxes, ProperMotions, and Publications; (3) use correct Felis syntax including @id references in the format #TableName.columnName; (4) set nullable: false for primary key columns (source, reference); (5) include fits:tunit for columns with units (deg, mas, mas/yr); (6) include foreign key constraints linking source and reference fields to their parent tables; (7) run felis validate on the generated file and report that it passed; (8) NOT reproduce the full YAML inline in the chat — just reference the file path.",
"files": [],
"assertions": [
Expand Down Expand Up @@ -43,7 +43,7 @@
},
{
"id": 2,
"prompt": "Here's the match-schema output for my radial velocity survey of M dwarfs. Most columns matched, but a few didn't:\n\n| Input Column | Description | Units | Type | DB Table | DB Field | Confidence | Notes |\n|---|---|---|---|---|---|---|---|\n| designation | 2MASS designation | — | str | Sources | source | High | Primary identifier |\n| rv | Heliocentric radial velocity | km/s | float64 | RadialVelocities | rv_kms | High | Name + units match |\n| e_rv | RV uncertainty | km/s | float64 | RadialVelocities | rv_error | High | Error prefix |\n| sn_ratio | Signal-to-noise ratio of the spectrum | — | float32 | — | — | — | Unmatched: no SN ratio field in schema |\n| obs_date | Date of observation (MJD) | d | float64 | — | — | — | Unmatched: observation date not in schema |\n| instrument | Instrument used | — | str | — | — | — | Unmatched: no direct instrument field on RadialVelocities |\n| ref | Publication reference | — | str | Publications | reference | High | Standard reference field |\n\nFor the unmatched columns: add sn_ratio and obs_date as new fields in the RadialVelocities table, and skip the instrument column entirely. Please generate the Felis YAML schema for this — name it 'MDwarfRV'.",
"prompt": "Here's the astrodb-match-schema output for my radial velocity survey of M dwarfs. Most columns matched, but a few didn't:\n\n| Input Column | Description | Units | Type | DB Table | DB Field | Confidence | Notes |\n|---|---|---|---|---|---|---|---|\n| designation | 2MASS designation | — | str | Sources | source | High | Primary identifier |\n| rv | Heliocentric radial velocity | km/s | float64 | RadialVelocities | rv_kms | High | Name + units match |\n| e_rv | RV uncertainty | km/s | float64 | RadialVelocities | rv_error | High | Error prefix |\n| sn_ratio | Signal-to-noise ratio of the spectrum | — | float32 | — | — | — | Unmatched: no SN ratio field in schema |\n| obs_date | Date of observation (MJD) | d | float64 | — | — | — | Unmatched: observation date not in schema |\n| instrument | Instrument used | — | str | — | — | — | Unmatched: no direct instrument field on RadialVelocities |\n| ref | Publication reference | — | str | Publications | reference | High | Standard reference field |\n\nFor the unmatched columns: add sn_ratio and obs_date as new fields in the RadialVelocities table, and skip the instrument column entirely. Please generate the Felis YAML schema for this — name it 'MDwarfRV'.",
"expected_output": "A valid Felis YAML schema file saved to /tmp/MDwarfRV-schema.yaml. The schema should: (1) include the RadialVelocities table with all matched columns (rv_kms, rv_error, source, reference) PLUS the two new user-requested fields (sn_ratio as float or double, obs_date as double with fits:tunit: d); (2) NOT include the instrument column; (3) include the Sources and Publications tables with appropriate columns; (4) use correct @id syntax throughout; (5) include foreign key constraints for source and reference; (6) summarize which columns were added vs skipped in the chat; (7) run felis validate and report it passed; (8) NOT reproduce the full YAML inline in the chat.",
"files": [],
"assertions": [
Expand Down Expand Up @@ -83,7 +83,7 @@
},
{
"id": 3,
"prompt": "I ran both match-schema and validate-schema-mapping on my photometry catalog. Here's what I've got:\n\n**Mapping:**\n| Input Column | Description | Units | Type | DB Table | DB Field | Confidence | Notes |\n|---|---|---|---|---|---|---|---|\n| source | Source name | — | str | Sources | source | High | Primary identifier |\n| Jmag | J-band magnitude | mag | float32 | Photometry | magnitude | High | Band = 2MASS.J |\n| eJmag | J-band uncertainty | mag | float32 | Photometry | magnitude_error | High | Error on Jmag |\n| band | Filter identifier | — | str | Photometry | band | High | Maps to PhotometryFilters.band |\n| ref | Reference | — | str | Publications | reference | High | Standard reference |\n\n**Validation report:**\n## Schema Mapping Validation Report\n\n### Nullable Violations (1 issue)\n| Data Column | Maps To | Null Count | Total Rows | % Null |\n|---|---|---|---|---|\n| eJmag | Photometry.magnitude_error | 23 | 500 | 4.6% |\n\n### Type Mismatches (0 issues)\n\n### Summary\n- 1 nullable violation: eJmag has nulls but magnitude_error is non-nullable in the template schema\n- 0 type mismatches\n- 4 columns passed cleanly\n\nFor the nullable violation: please mark magnitude_error as nullable in the new schema (some objects don't have error estimates). Generate the Felis YAML — name it 'Photometry2MASSJ'.",
"prompt": "I ran both astrodb-match-schema and astrodb-validate-schema-mapping on my photometry catalog. Here's what I've got:\n\n**Mapping:**\n| Input Column | Description | Units | Type | DB Table | DB Field | Confidence | Notes |\n|---|---|---|---|---|---|---|---|\n| source | Source name | — | str | Sources | source | High | Primary identifier |\n| Jmag | J-band magnitude | mag | float32 | Photometry | magnitude | High | Band = 2MASS.J |\n| eJmag | J-band uncertainty | mag | float32 | Photometry | magnitude_error | High | Error on Jmag |\n| band | Filter identifier | — | str | Photometry | band | High | Maps to PhotometryFilters.band |\n| ref | Reference | — | str | Publications | reference | High | Standard reference |\n\n**Validation report:**\n## Schema Mapping Validation Report\n\n### Nullable Violations (1 issue)\n| Data Column | Maps To | Null Count | Total Rows | % Null |\n|---|---|---|---|---|\n| eJmag | Photometry.magnitude_error | 23 | 500 | 4.6% |\n\n### Type Mismatches (0 issues)\n\n### Summary\n- 1 nullable violation: eJmag has nulls but magnitude_error is non-nullable in the template schema\n- 0 type mismatches\n- 4 columns passed cleanly\n\nFor the nullable violation: please mark magnitude_error as nullable in the new schema (some objects don't have error estimates). Generate the Felis YAML — name it 'Photometry2MASSJ'.",
"expected_output": "A valid Felis YAML schema file saved to /tmp/Photometry2MASSJ-schema.yaml. The schema should: (1) include Sources, Photometry, PhotometryFilters, and Publications tables (all referenced by FK constraints must be defined); (2) critically, the magnitude_error column in Photometry must have nullable: true (or omit nullable entirely) — NOT nullable: false; (3) use float or double for magnitude and magnitude_error columns; (4) include foreign key constraints; (5) note in the chat that magnitude_error was made nullable per user request; (6) run felis validate and report it passed; (7) NOT reproduce the full YAML inline in the chat.",
"files": [],
"assertions": [
Expand Down
Loading