Skip to content

docs: add CLAUDE.md and Claude Code skill for new sub-API authoring#2612

Draft
andersfylling wants to merge 2 commits into
masterfrom
docs/claude-md-and-add-resource-skill
Draft

docs: add CLAUDE.md and Claude Code skill for new sub-API authoring#2612
andersfylling wants to merge 2 commits into
masterfrom
docs/claude-md-and-add-resource-skill

Conversation

@andersfylling
Copy link
Copy Markdown
Contributor

@andersfylling andersfylling commented May 8, 2026

Summary

Adds two pieces of authored context that AI coding assistants pick up automatically when working in this repo:

  • CLAUDE.md at repo root — repo-wide conventions in one place.
  • .claude/skills/cognite-sdk-python-add-resource/ — a Claude Code skill that triggers when adding a new resource group / sub-API.

Eval results

To validate that the authored context actually moves the needle, I ran a small eval suite based on different scenarios in PR reviews in the past. This is just 23 scenarios, a smaller test suite to check if this contribution is actually helpful.

The three configs:

  • claude.md + skill — both files present, skill triggered
  • claude.mdCLAUDE.md only (skill dir absent, so it can't trigger)
  • none — neither file present (raw baseline)
Config Sonnet (low) Sonnet (med) Sonnet (high) Haiku 4.5 Opus 4.7 (low)
claude.md + skill 96% ±3% 100% 94% 91% ±6% 100%
claude.md 90% ±5% 88% 88% 77% ±3% 88%
none 69% ±10% 66% 79% 75% ±3% 91%

(Sonnet low N=5 batches, Haiku N=4 batches, others N=1; ± is sample std dev.)

Takeaways:

  • The skill takes every model from baseline 66–91% to 91–100% on this task family.
  • CLAUDE.md alone closes about half the gap, even when no skill triggers.
  • This also keeps cost down for models like haiku and sonnet 4.6

Adds two pieces of authored context for AI assistants (Claude Code in
particular, but the markdown is readable by any agent that loads files):

- CLAUDE.md at repo root — repo-wide conventions, the 10 hard rules
  (sync codegen, doctest registration, no dict[str, Any], read/write
  split, APIClient helpers, @overload, FeaturePreviewWarning, etc.)
  and BAD/GOOD anti-pattern pairs from PR #2534 review feedback.

- .claude/skills/cognite-sdk-python-add-resource/ — an opt-in Claude
  Code skill triggered when adding a new resource group / sub-API.
  16-step boilerplate checklist, decision tree (flat vs nested,
  alpha vs GA, chunking), and per-topic references covering the
  streams PR walkthrough, DTO design, wiring, alpha warnings,
  tests/doctests.

Also gitignores .claude/settings.local.json (Claude Code per-user state).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.01%. Comparing base (ed1ce44) to head (ea34325).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2612      +/-   ##
==========================================
- Coverage   93.02%   93.01%   -0.01%     
==========================================
  Files         486      486              
  Lines       49462    49462              
==========================================
- Hits        46010    46007       -3     
- Misses       3452     3455       +3     

see 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@andersfylling andersfylling marked this pull request as ready for review May 8, 2026 09:28
@andersfylling andersfylling requested review from a team as code owners May 8, 2026 09:28
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a comprehensive Claude skill and supporting reference documentation to guide developers through the process of adding new sub-APIs or resource groups to the SDK. The documentation covers DTO design, wiring touchpoints, testing requirements, and alpha/beta gating strategies, using the streams implementation as a canonical reference. Additionally, the PR updates the project's .gitignore and CLAUDE.md to formalize repo-wide conventions and provide context for AI-assisted development. I have no feedback to provide.

@andersfylling
Copy link
Copy Markdown
Contributor Author

Testing this out with sonnet 4.6 on high effort I asked it to implement records API with the following prompt:

 we will add a new api resource to build the records API. the documentation for the endpoint is a bit messy, so please spin up a sonnet subagent that can clean up data from the following before we start our plan 
   and figure out scope:                                                                                                                                                                                             
                                                                                                                                                                                                                     
   - # Records                                                                                                                                                                                                       
                                                                                                                                                                                                                     
  > Manage records in Cognite Data Fusion (CDF).                                                                                                                                                                     
                                                                                                                                                                                                                     
  Records are immutable or mutable data objects, depending on the stream template, that are stored in a stream. You create records by ingesting data into a stream.                                                  
                                                                                                                                                                                                                     
  For a comprehensive guide on records, including detailed behavior, uniqueness constraints, and how they relate to streams, see [About records and streams](/cdf/dm/records/concepts/records_and_streams).          
                                                                                                                                                                                                                     
  Records have a similar shape to instances in the Data Modeling service, and their schema is defined by the [containers](/cdf/dm/dm_concepts/dm_containers_views_datamodels#containers) referenced as sources. Each 
   record also links to the [space](/cdf/dm/dm_concepts/dm_spaces_instances#space) it belongs to, enabling space-based access control.                                                                               
                                                                                                                                                                                                                     
  <Note>                                                                                                                                                                                                             
    Every `record` has a required top-level `externalId` property, which you can use in some queries to retrieve or aggregate records.                                                                               
                                                                                                                                                                                                                     
    * **Mutable records**: The `externalId` and `space` properties uniquely identify records for write operations (create/upsert/delete).                                                                            
    * **Immutable records**: The uniqueness of the `space` + `externalId` pair is not enforced, allowing multiple records with the same identifier to exist.                                                         
  </Note>                                                                                                                                                                                                            
                                                                                                                                                                                                                     
  ## Rate and concurrency limits                                                                                                                                                                                     
                                                                                                                                                                                                                     
  For Records rate and concurrency limits, including mutable vs immutable stream budgets, see [API rate limits](/api-reference/concepts/20230101/rate-limits#records).                                               
   - resource markdown file can be fetched from the following which gives us several endpoints: https://docs.cognite.com/20230101/records/aggregate-records-data-from-a-stream.md                                    
   - - aggregate endpoint                                                                                                                                                                                            
   - - delete records endpoint                                                                                                                                                                                       
   - - ingest records into a stream endpoint                                                                                                                                                                         
   - - retrieve records from a stream endpoint                                                                                                                                                                       
   - - sync records from a stream endpoint                                                                                                                                                                           
   - - upsert records into a stream endpoint                                                                                                                                                                         
                                                                                                                                                                                                                     
  you can skip reading changelog since this is a completely new api resource for the python sdk. Please cleanup the data in a subagent, and then write me a plan for implementation and grill me with questions till 
   you have a clear scope of the task.

Here is the result from the first try: #2616

@andersfylling andersfylling marked this pull request as draft May 11, 2026 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant