Use built-in web features to cut LLM coding token costs
LLMs often write older, longer code patterns even when modern built-in web features already solve the same job. That matters because can cost 3 to 5 times more than in many API price lists. The practical fix is to tell the model, at the start of the session, to use the built-in features available in the runtime, especially in environments such as Deno and .
For example, hand-written query parsing can take about 140 tokens, while URL and URLSearchParams can do it in about 12 tokens. Form handling can take 200 to 250 tokens when every field has its own state code, while FormData can collect the form in about 14 tokens. Request timeouts, parallel task handling, and basic interface elements can also be shorter and safer with AbortSignal.timeout, Promise.allSettled, and dialog.
A Deno request handler that uses older boilerplate may spend 400 to 600 before the real starts, while the same handler using built-in features may need only 60 to 90 tokens. Comments also affect model behavior: stale comments can mislead the model, while comments about design intent and constraints give it useful guidance.
Key points
- are often more expensive than , so long generated code directly raises cost.
- Built-in web features can replace long custom code for query parsing, forms, timeouts, parallel tasks, and dialogs.
- Shorter built-in patterns can also reduce bugs in edge cases, , cancellation, and repeated values.
- A useful prompt should name the desired tools, such as URLSearchParams, FormData, and Promise.allSettled.
- Comments should explain design intent and constraints, not repeat what the next line of code already says.