Skip to content

Commit 88001c6

Browse files
committed
api-sync prompt: structural rule + auto-fix lint order
Folds in the same two lessons from blindpay-node #51: 1. Nested API endpoints become methods on the existing resource class, not new files / new resource classes. Added a 'Decide: new resource, or method on an existing one?' section in CLAUDE.md (section 3) with the RFI worked example, and a corresponding step in the workflow prompt. PR #46 created src/blindpay/resources/receivers/rfi.py with its own RfiResource class for two endpoints. The existing pattern for nested-under-receivers endpoints (get_limits, get_limit_increase_requests, request_limit_increase) is direct methods on ReceiversResource. New rule pins that. 2. The lint step in the prompt now runs the auto-fix forms (ruff format, ruff check --fix) BEFORE the validate forms. Same lesson as #51 in the Node SDK — running only the read-only check leaves formatter diffs unresolved. 3. Step also reminds the agent to grep for fixtures of any type that gains a new required field, otherwise type-check will fail somewhere far from the original edit.
1 parent 2d4bf9d commit 88001c6

2 files changed

Lines changed: 80 additions & 7 deletions

File tree

.github/workflows/api-sync.yml

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,41 @@ jobs:
6262
INSTRUCTIONS:
6363
1. Read CLAUDE.md thoroughly for this SDK's patterns and conventions.
6464
2. Read /tmp/api-sync/changelog.md — it lists every enum type with every value, every field to add, and every change to make.
65-
3. Implement ALL changes. Go through the changelog section by section:
65+
3. Before implementing any new endpoint, decide where it
66+
lives. Read the "Decide: new resource, or method on an
67+
existing one?" section in CLAUDE.md (section 3). For
68+
each new endpoint:
69+
a. Find sibling endpoints — other endpoints whose URL
70+
path shares a prefix (e.g. POST /receivers/{id}/rfi
71+
is a sibling of /receivers/{id}/limit-increase).
72+
b. Match how those siblings are modeled. If they are
73+
direct methods on an existing resource class (e.g.
74+
receivers.get_limit_increase_requests), add the
75+
new endpoint as a method on the SAME class.
76+
c. Do NOT create a new RfiResource class or a new
77+
file under receivers/rfi.py for 1–3 child
78+
endpoints. Do NOT put a child of an existing
79+
resource at the top level of src/blindpay/resources/.
80+
d. After adding a required field to an existing
81+
TypedDict, grep the repo for fixtures and
82+
constructors of that type and add the field to
83+
each. mypy/pyright will fail otherwise.
84+
4. Implement ALL changes. Go through the changelog section by section:
6685
- Section 1 (Enum Types): For each enum listed, check if the SDK has it. If missing, create it. If it exists, add any missing values. The changelog lists ALL values — add the ones that don't exist yet.
6786
- Section 2 (Receiver Fields): Add each listed field to the receiver input/output types.
6887
- Section 3 (Version): Minor bump.
69-
4. Do not skip ANY enum or field. Every item in the changelog must be addressed.
70-
5. Follow CLAUDE.md patterns exactly for naming, typing, and file organization.
71-
6. MINOR version bump only.
72-
7. Run lint and type check commands (see CLAUDE.md). Fix any errors until clean.
73-
8. Do NOT create commits — just modify the files.
88+
5. Do not skip ANY enum or field. Every item in the changelog must be addressed.
89+
6. Follow CLAUDE.md patterns exactly for naming, typing, and file organization.
90+
7. MINOR version bump only.
91+
8. Run, in this order:
92+
ruff format src/ # auto-format
93+
ruff check src/ --fix # auto-fix lint issues
94+
ruff check src/ # validate (must report 0 errors)
95+
mypy src/ # type-check
96+
Fix any errors until all four are clean. Running only
97+
the check forms surfaces formatter diffs as failures —
98+
always run the auto-fix forms first.
99+
9. Do NOT create commits — just modify the files.
74100
75101
- name: Commit and push
76102
id: commit

CLAUDE.md

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,54 @@ Resource-specific Literal types and TypedDicts are defined in the same file as t
114114

115115
---
116116

117-
## 3. How to add a new resource
117+
## 3. Decide: new resource, or method on an existing one?
118+
119+
Before adding files, decide whether a new endpoint deserves its own
120+
resource directory and class pair, or whether it belongs as a method
121+
on an existing one. Default to the second — methods on an existing
122+
resource are the right choice for most new endpoints.
123+
124+
**Look at sibling endpoints first.** Find other endpoints whose URL
125+
path shares a prefix with the new one (e.g. `POST /receivers/{id}/rfi`
126+
is a sibling of `GET /receivers/{id}/limit-increase`, which is
127+
modeled as `client.receivers.get_limit_increase_requests(id)`, not as
128+
`client.receivers.limit_increase.list()`). Match how those siblings
129+
are modeled.
130+
131+
**Heuristics:**
132+
133+
- 1–3 endpoints under an existing parent path → add as direct methods
134+
on the parent's resource class. Naming: `<verb>_<subresource>`
135+
e.g. `client.receivers.get_rfi(receiver_id)` and
136+
`client.receivers.submit_rfi(receiver_id=..., data=...)`. **Do not**
137+
create a new `Rfi`/`RfiResource` class or a new file under
138+
`src/blindpay/resources/receivers/rfi.py`.
139+
- 4+ endpoints with a distinct ID space, or a clearly separate
140+
conceptual resource (`bank_accounts`, `blockchain_wallets`,
141+
`virtual_accounts`) → its own directory + class pair, wired under
142+
the parent via the namespace pattern (Section 7). Confirm there is
143+
precedent in the existing codebase before doing this.
144+
- Never put a child of an existing resource at the **top level** of
145+
`src/blindpay/resources/` (e.g. `src/blindpay/resources/rfi/`). If
146+
it's nested in the API URL, it's nested in the SDK.
147+
148+
### Worked example: RFI
149+
150+
`GET /receivers/{id}/rfi` and `POST /receivers/{id}/rfi` are two
151+
endpoints nested under `receivers`. Add them as methods on
152+
`ReceiversResource` / `ReceiversResourceSync` in
153+
`src/blindpay/resources/receivers/receivers.py`, alongside
154+
`get_limits`, `get_limit_increase_requests`, and
155+
`request_limit_increase`. NOT as a new `RfiResource` class in
156+
`receivers/rfi.py`.
157+
158+
---
159+
160+
## 4. How to add a new resource
161+
162+
(Use this section only when the heuristics above say the endpoint is
163+
a genuinely new top-level resource — not just a 1–3-endpoint
164+
extension of an existing one.)
118165

119166
### Step 1: Create the resource directory and files
120167

0 commit comments

Comments
 (0)