-
Notifications
You must be signed in to change notification settings - Fork 15
docs: Add coding agent docs, SKILL.md
#290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Andreas Albert (AndreasAlbertQC)
wants to merge
5
commits into
main
Choose a base branch
from
2026-03-02_agent
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+228
−1
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| --- | ||
| name: dataframely | ||
| description: A declarative, Polars-native data frame validation library. Use when implementing data processing logic in polars. | ||
| license: BSD-3-Clause | ||
| --- | ||
|
|
||
| # Dataframely skill | ||
|
|
||
| `dataframely` provides `dy.Schema` and `dy.Collection` to document and enforce the structure of single or multiple | ||
| related data frames. | ||
|
|
||
| ## `dy.Schema` example | ||
|
|
||
| A `dy.Schema` describes the structure of a single dataframe. | ||
|
|
||
| ```python | ||
| class MyHouseSchema(dy.Schema): | ||
| """A schema for a dataframe describing houses.""" | ||
|
|
||
| street = dy.String(primary_key=True) | ||
| number = dy.UInt16(primary_key=True) | ||
| # Number of rooms | ||
| rooms = dy.UInt8() | ||
| # Area in square meters | ||
| area = dy.UInt16() | ||
| ``` | ||
|
|
||
| ## `dy.Collection` example | ||
|
|
||
| A `dy.Collection` describes a set of related dataframes, each described by a `dy.Schema`. Dataframes in a collection | ||
| should share at least a subset of their primary key. | ||
|
|
||
| ```python | ||
| class MyStreetSchema(dy.Schema): | ||
| """A schema for a dataframe describing streets.""" | ||
|
|
||
| # Shared primary key component with MyHouseSchema | ||
| street = dy.String(primary_key=True) | ||
| city = dy.String() | ||
|
|
||
|
|
||
| class MyCollection(dy.Collection): | ||
| """A collection of related dataframes.""" | ||
|
|
||
| houses: dy.LazyFrame[MyHouseSchema] | ||
| streets: dy.LazyFrame[MyStreetSchema] | ||
| ``` | ||
|
|
||
| # Usage conventions | ||
|
|
||
| ## Use clear interfaces | ||
|
|
||
| Structure data processing code with clear interfaces documented using `dataframely` type hints: | ||
|
|
||
| ```python | ||
| def preprocess(raw: dy.LazyFrame[MyRawSchema]) -> dy.DataFrame[MyPreprocessedSchema]: | ||
| # Internal dataframes do not require schemas | ||
| df: pl.LazyFrame = ... | ||
| return MyPreprocessedSchema.validate(df, cast=True) | ||
| ``` | ||
|
|
||
| Use schemas for all input, output, and intermediate dataframes. Schemas may be omitted for short-lived temporary | ||
| dataframes and private helper functions (prefixed with `_`). | ||
|
|
||
| ## `filter` vs `validate` | ||
|
|
||
| Both `.validate` and `.filter` enforce the schema at runtime. Pass `cast=True` for safe type-casting. | ||
|
|
||
| - **`Schema.validate`** — raises on failure. Use when failures are unexpected (e.g. transforming already-validated | ||
| data). | ||
| - **`Schema.filter`** — returns valid rows plus a `FailureInfo` describing filtered-out rows. Use when failures are | ||
| possible and should be handled gracefully (e.g. logging and skipping invalid rows). | ||
|
|
||
| ## Testing | ||
|
|
||
| Every data transformation must have unit tests. Test each branch of the transformation logic. Do not test properties | ||
| already guaranteed by the schema. | ||
|
|
||
| ### Test structure | ||
|
|
||
| 1. Create synthetic input data | ||
| 2. Define the expected output | ||
| 3. Execute the transformation | ||
| 4. Compare using `assert_frame_equal` from `polars.testing` (or `diffly.testing` if installed) | ||
|
|
||
| ```python | ||
| from polars.testing import assert_frame_equal | ||
|
|
||
|
|
||
| def test_grouped_sum(): | ||
| df = pl.DataFrame({ | ||
| "col1": [1, 2, 3], | ||
| "col2": ["a", "a", "b"], | ||
| }).pipe(MyInputSchema.validate, cast=True) | ||
|
|
||
| expected = pl.DataFrame({ | ||
| "col1": ["a", "b"], | ||
| "col2": [3, 3], | ||
| }) | ||
|
|
||
| result = my_code(df) | ||
|
|
||
| assert_frame_equal(expected, result) | ||
| ``` | ||
|
|
||
| ### Generating synthetic input data | ||
|
|
||
| For complex schemas where only some columns are relevant to the test, use `dataframely`'s synthetic data generation: | ||
|
|
||
| ```python | ||
| # Random data meeting all schema constraints | ||
| random_data = MyInputSchema.sample(num_rows=100) | ||
| ``` | ||
|
|
||
| Use fully random data for property tests where exact contents don't matter. Use overrides to pin specific columns while | ||
| randomly sampling the rest: | ||
|
|
||
| ```python | ||
| random_data_with_overrides = HouseSchema.sample( | ||
| overrides={ | ||
| "street": ["Main St.", "Main St.", "Main St.", "Second St.", "Second St."], | ||
| } | ||
| ) | ||
| ``` | ||
|
|
||
| # Getting more information | ||
|
|
||
| `dataframely` relies on clear function signatures, type hints and doc strings. If you need more information, check the | ||
| locally installed code. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,71 @@ | ||||||
| # Using `dataframely` with coding agents | ||||||
|
|
||||||
| Coding agents are particularly powerful when two criteria are met: | ||||||
|
|
||||||
| 1. The agent can know all required information and does not need to guess. | ||||||
| 2. The results of the agent's work can be easily verified. | ||||||
|
|
||||||
| `dataframely` helps you fulfill these criteria. | ||||||
|
|
||||||
| To help your coding agent write good `dataframely` code, we provide a | ||||||
| `dataframely` [skill](https://raw.githubusercontent.com/Quantco/dataframely/refs/heads/main/SKILL.md) | ||||||
| following the [ | ||||||
| `agentskills.io` spec](https://agentskills.io/specification). You can install | ||||||
| it by placing it where your agent can find it. For example, if you are using `claude`: | ||||||
|
|
||||||
| ```bash | ||||||
| mkdir -p .claude/skills/dataframely/ | ||||||
| curl -o .claude/skills/dataframely/SKILL.md https://raw.githubusercontent.com/Quantco/dataframely/refs/heads/main/SKILL.md | ||||||
| ``` | ||||||
|
|
||||||
| or if you are using skills.sh: | ||||||
|
|
||||||
| ```bash | ||||||
| npx skills add Quantco/dataframely | ||||||
| ``` | ||||||
|
|
||||||
| Refer to the documentation of your coding agent for instructions on how to add custom skills. | ||||||
|
|
||||||
| ## Tell the agent about your data with `dataframely` schemas | ||||||
|
|
||||||
| `dataframely` schemas provide a clear format for documenting dataframe structure and contents, which helps coding | ||||||
| agents understand your code base. We recommend structuring your data processing code using clear interfaces that are | ||||||
| documented using | ||||||
| `dataframely` type hints. This streamlines your coding agent's ability to find the right schema at the right time. | ||||||
|
|
||||||
| For example: | ||||||
|
|
||||||
| ```python | ||||||
| def preprocess(raw: dy.LazyFrame[MyRawSchema]) -> dy.DataFrame[MyPreprocessedSchema]: | ||||||
| ... | ||||||
| ``` | ||||||
|
|
||||||
| gives a coding agent much more information than the schema-less alternative: | ||||||
|
|
||||||
| ```python | ||||||
| def load_data(raw: pl.LazyFrame) -> pl.DataFrame: | ||||||
| ... | ||||||
| ``` | ||||||
|
|
||||||
| This convention also makes your code more readable and maintainable for human developers. | ||||||
|
|
||||||
| If there is additional domain information that is not natively expressed through the structure of the schema, | ||||||
| we recommend documenting this as docstrings on the definition of the schema columns. One common example would be the | ||||||
| semantic meanings of enum values referring to conventions in the data: | ||||||
|
|
||||||
| ```python | ||||||
| class HospitalStaySchema(dy.Schema): | ||||||
| # Reason for admission to the hospital | ||||||
| # N = Emergency | ||||||
| # V = Transfer from another hospital | ||||||
| # ... | ||||||
| admission_reason = dy.Enum(["N", "V", ...]) | ||||||
| ``` | ||||||
|
|
||||||
| ## Verifying results | ||||||
|
|
||||||
| `dataframely` supports you and your coding agent in writing unit tests for individual pieces of logic. One significant | ||||||
| bottle neck is the generation of appropriate test data. Check | ||||||
|
||||||
| bottle neck is the generation of appropriate test data. Check | |
| bottleneck is the generation of appropriate test data. Check |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |
| quickstart | ||
| examples/index | ||
| features/index | ||
| coding-agents | ||
| development | ||
| migration/index | ||
| faq | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.