Skip to content

Commit 17df90e

Browse files
committed
chore: add Fern regen workflow docs and skills
Add AGENTS.md documenting the SDK regeneration workflow, CLAUDE.md stub, and Claude Code skills for prepare-regen and review-regen.
1 parent 5008103 commit 17df90e

File tree

4 files changed

+104
-0
lines changed

4 files changed

+104
-0
lines changed

.claude/skills/prepare-regen.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Prepare Repo for Fern SDK Regeneration
2+
3+
Triggers: prepare regen, prepare for regeneration, prep for fern, new sdk gen, prepare sdk gen
4+
5+
## Steps
6+
7+
Read AGENTS.md for full context on the regeneration workflow.
8+
9+
1. Fetch latest `main` and create a new branch: `lo/sdk-gen-<YYYY-MM-DD>` (use today's date).
10+
2. Push the branch to origin.
11+
3. Create an empty commit (`chore: initialize SDK regeneration branch`) if needed, then create a PR titled `chore: SDK regeneration <YYYY-MM-DD>` with body `## Summary\n- Fern SDK regeneration`.
12+
4. Read `.fernignore` and identify all frozen generated files (Client & Socket Clients, Type Fixes, Redact type, Listen Clients, Tests & WireMock). Do NOT unfreeze the "always frozen" files listed in AGENTS.md.
13+
5. Back up each identified file as `<filename>.bak` alongside the original.
14+
6. Remove their entries and associated comments from `.fernignore`.
15+
7. Stage the updated `.fernignore` and all `.bak` files.
16+
8. Commit as `chore: unfreeze files pending regen` and push.
17+
9. Report the PR URL and confirm the branch is ready for generator output.

.claude/skills/review-regen.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Review Fern SDK Regeneration
2+
3+
Triggers: review regen, review regeneration, diff regen, compare regen, post regen review
4+
5+
## Steps
6+
7+
Read AGENTS.md for full context on the regeneration workflow.
8+
9+
1. Find all `.bak` files in the repo — these are the pre-regen manually-patched versions.
10+
2. For each `.bak` file, diff it against the corresponding newly generated file to show what changed.
11+
3. Identify which manual patches are still needed (the `.bak` has changes the generator doesn't produce).
12+
4. Present a summary of findings to the user, grouped by category:
13+
- Patches no longer needed (generator now handles it)
14+
- Patches still needed (must be re-applied)
15+
- New changes from the generator worth noting
16+
5. Wait for user direction on which patches to re-apply.
17+
6. Re-apply confirmed patches to the generated files.
18+
7. Re-add entries to `.fernignore` for files that still carry manual patches.
19+
8. Delete all `.bak` files.
20+
9. Run `ruff check --fix`, `mypy --ignore-missing-imports src/deepgram/`, and `pytest` to verify.
21+
10. Commit as `chore: re-apply manual patches after regen` and push.

AGENTS.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Agents
2+
3+
## Fern SDK Regeneration
4+
5+
### Overview
6+
7+
This SDK is generated by [Fern](https://buildwithfern.com/). Most files under `src/deepgram/` are auto-generated and should not be edited directly. Some files have manual patches (custom auth, type fixes, WebSocket defaults, etc.) and are listed in `.fernignore` to prevent the generator from overwriting them.
8+
9+
When a new Fern generator release is available, we prepare the repo so the generator can overwrite previously-frozen files, then re-apply manual patches after reviewing the diff.
10+
11+
### Files that may be frozen in `.fernignore`
12+
13+
These are the files that typically carry manual patches and get frozen between regenerations:
14+
15+
**Client & Socket Clients:**
16+
- `src/deepgram/client.py` — Bearer token auth + session ID injection
17+
- `src/deepgram/speak/v1/socket_client.py` — optional message param defaults, broad exception catch
18+
- `src/deepgram/listen/v1/socket_client.py` — same as above + `construct_type` for unknown WS messages
19+
- `src/deepgram/listen/v2/socket_client.py` — same as above
20+
- `src/deepgram/agent/v1/socket_client.py` — same as above + `_sanitize_numeric_types`
21+
22+
**Type Fixes (Fern generates float where API returns int):**
23+
- `src/deepgram/types/listen_v1response_results_utterances_item.py`
24+
- `src/deepgram/types/listen_v1response_results_utterances_item_words_item.py`
25+
- `src/deepgram/types/listen_v1response_results_channels_item_alternatives_item_paragraphs_paragraphs_item.py`
26+
27+
**Redact type (Union[str, Sequence[str]] support):**
28+
- `src/deepgram/types/listen_v1redact.py`
29+
30+
**Listen Clients (array param support):**
31+
- `src/deepgram/listen/v1/client.py`
32+
- `src/deepgram/listen/v2/client.py`
33+
34+
**Tests & WireMock:**
35+
- `tests/wire/test_listen_v1_media.py` — manual fix for `transcribe_file()` bytes param
36+
- `wiremock/wiremock-mappings.json` — removed duplicate stub causing non-deterministic matching
37+
38+
**Always frozen (never unfreeze for regen):**
39+
- `tests/custom/test_text_builder.py`, `tests/custom/test_transport.py` — hand-written tests
40+
- `tests/manual/` — manual standalone tests
41+
- `README.md`, `CHANGELOG.md`, `CONTRIBUTING.md`, `reference.md` — docs
42+
- `src/deepgram/helpers/` — TextBuilder helpers
43+
- `src/deepgram/transport_interface.py`, `src/deepgram/transport.py`, `src/deepgram/transports/` — custom transport support
44+
- `.github/`, `docs/`, `examples/` — folders
45+
46+
### Prepare repo for regeneration
47+
48+
1. **Create a new branch** off `main` named `lo/sdk-gen-<YYYY-MM-DD>`.
49+
2. **Push the branch** and create a PR titled `chore: SDK regeneration <YYYY-MM-DD>` with an empty commit if needed.
50+
3. **Identify frozen generated files** in `.fernignore` (the files listed above under Client, Type Fixes, Redact, Listen Clients, Tests & WireMock — NOT the "always frozen" files).
51+
4. **Back up each file** as `<filename>.bak` alongside the original.
52+
5. **Remove their entries** (and associated comments) from `.fernignore`.
53+
6. **Commit** as `chore: unfreeze files pending regen` and push.
54+
7. The branch is now ready for the Fern generator to push changes.
55+
56+
### After regeneration
57+
58+
The `.bak` files are our manually-patched versions. The newly generated files replace them. By comparing the two, we can see what the generator now produces vs what we had patched.
59+
60+
1. **Diff each `.bak` file against the new generated version** (e.g., `diff src/deepgram/client.py.bak src/deepgram/client.py`) to understand what changed and whether our patches are still needed.
61+
2. **Re-apply any patches** that are still necessary to the newly generated files.
62+
3. **Re-add entries to `.fernignore`** for any files that still need manual patches.
63+
4. **Delete `.bak` files** once review is complete.
64+
5. **Run tests** (`pytest`) and linting (`ruff check`, `mypy`) to verify.
65+
6. **Commit** as `chore: re-apply manual patches after regen` and push.

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@AGENTS.md

0 commit comments

Comments
 (0)