memory-load-check
Skill1 starsChanged 2 months agoApache-2.0View on GitHub
Review PRs and diffs for unbounded memory loading, concurrency explosions, oversized payload materialization, and missing pagination or byte caps. Use when reviewing cleanup jobs, background jobs, data imports/exports, file parsing, API fan-out, workflow execution payloads, large arrays/files, or any change that reads many rows, files, responses, logs, or external API pages into process memory.
We split this skill into the rules it gives an agent
16 rules. About 0 are common, 10 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈10
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Use this skill when a PR or diff could load unbounded data into a Node/Bun process, especially in cron routes, background tasks, API …
- Distinctive: line 18
If any bound depends only on current production size or "probably small" data, treat it as a finding.
- Distinctive: line 22
Read these when doing a deeper pass:
- Distinctive: line 46
prefer Trigger.dev queue/concurrency keys when available
- Distinctive: line 51
never read untrusted response bodies without a byte cap
- Distinctive: line 59
prefer durable references/manifests over inlining large arrays or files
- Very specific: line 66
Use the pattern when the connector downloads file content via a stream/download_url where the user controls the size:
- Very specific: line 73
never drop/truncate silently — oversized files become content-less failed rows carrying skippedReason, so they stay visible in the KB UI …
- Distinctive: line 96
Check concurrency separately from memory:
- Distinctive: line 98
use chunks, sequential loops, queue concurrency, or a concurrency limiter
- Very specific: line 101
every bulk query has LIMIT
- Very specific: line 106
check Content-Length when available
- Distinctive: line 136
Add per-batch and per-run row caps so long backlogs drain across repeated jobs.
- Very specific: line 138
Use chunkedBatchDelete for cleanup loops with row side effects.
- Very specific: line 139
Use stream-limit helpers for file/HTTP/body reads.
- Distinctive: line 164
Only say "good to go" when every changed source has explicit row, byte, and concurrency bounds or the boundedness is proven by a stable …
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Memory Load Check
Use this skill when a PR or diff could load unbounded data into a Node/Bun process, especially in cron routes, background tasks, API routes, workflow execution, file parsing, cleanup jobs, migrations, import/export flows, and external API integrations.
Review Goal
Prove each changed path has explicit bounds for:
- rows held in memory
- bytes held in memory
- concurrent promises, DB queries, HTTP calls, storage operations, and jobs
- number of pages, batches, chunks, retries, and retained intermediate objects
If any bound depends only on current production size or "probably small" data, treat it as a finding.
References
Read these when doing a deeper pass:
- Node.js streams/backpressure: https://nodejs.org/learn/modules/backpressuring-in-streams
- Node.js stream usage: https://nodejs.org/en/learn/modules/how-to-use-streams
- Keyset/cursor pagination over offset scans: https://blog.sequinstream.com/keyset-cursors-not-offsets-for-postgres-pagination/
- Postgres pagination tradeoffs: https://www.citusdata.com/blog/2016/03/30/five-ways-to-paginate/
Sim Helpers To Prefer
apps/sim/lib/cleanup/batch-delete.tschunkedBatchDelete: bounded SELECT -> optional side effect -> DELETE loop.batchDeleteByWorkspaceAndTimestamp: common workspace/timestamp cleanup wrapper.selectRowsByIdChunks: chunks large ID sets and enforces an overall row cap.chunkArray: use only after the input set itself is already bounded.
apps/sim/lib/core/utils/stream-limits.tsPayloadSizeLimitErrorassertKnownSizeWithinLimitassertContentLengthWithinLimitreadStreamToBufferWithLimitreadNodeStreamToBufferWithLimitreadResponseToBufferWithLimitreadResponseTextWithLimit
- Cleanup dispatcher pattern in
apps/sim/lib/billing/cleanup-dispatcher.ts- page active workspaces with
WHERE id > afterId ORDER BY id LIMIT N - dispatch concrete chunks (
workspaceIds, retention, label) instead of one giant scope - prefer Trigger.dev queue/concurrency keys when available
- execute inline fallback chunks sequentially, not with unbounded
Promise.all
- page active workspaces with
- File parse route pattern in
apps/sim/app/api/files/parse/route.ts- cap downloads and parsed output separately
- preserve partial results when a later item exceeds the cap
- never read untrusted response bodies without a byte cap
- KB connector file downloads in
apps/sim/connectors/utils.tsCONNECTOR_MAX_FILE_BYTES: shared per-file cap (aligned with the manual KB upload limit)readBodyWithLimit: stream a download body to a Buffer with a hard byte cap (null on overflow)stubOrSkipBySize: listing-time skip when the reported size exceeds the capmarkSkipped/sizeLimitSkipReason: surface oversized files as failed (skipped) KB rowsConnectorFileTooLargeError: thrown mid-download when the listing under-reported size
- Large workflow value payloads
- prefer durable references/manifests over inlining large arrays or files
- materialize refs only behind an explicit byte budget
KB Connector File Size Handling
The connector size pattern in apps/sim/connectors/utils.ts (CONNECTOR_MAX_FILE_BYTES + readBodyWithLimit + stubOrSkipBySize/markSkipped) exists for one risk: a knowledge-base connector downloading arbitrary, user-controlled file bytes that the source does not hard-cap. Apply it by that risk, not by the connector's name.
Use the pattern when the connector downloads file content via a stream/download_url where the user controls the size:
- file-storage connectors: Dropbox, OneDrive, SharePoint, Google Drive, S3, GitHub, GitLab, Azure DevOps
- any connector that fetches a file via a download URL even if it is not a "storage" service (e.g. the Zoom transcript
.vtt)
For those, require all three:
- stream the body with
readBodyWithLimit(resp, CONNECTOR_MAX_FILE_BYTES)— never rawresponse.text()/response.arrayBuffer() - skip oversize at listing (
stubOrSkipBySizewith the reported size) and again at fetch time (overflow ->markSkipped), since the listing size can be missing or under-reported - never drop/truncate silently — oversized files become content-less failed rows carrying
skippedReason, so they stay visible in the KB UI instead of vanishing from the index
Skip the pattern when the source already bounds the payload:
- pure API/structured-data connectors (Jira, Linear, Notion, Confluence, Sentry, Slack, Zendesk, Gmail, ...) — paginated JSON/text; apply normal pagination + concurrency bounds instead of a per-file byte cap
- native-document connectors capped by the platform (Google Docs ~50 MB, Google Sheets via
MAX_ROWS, Evernote ~25 MB/note) — a 100 MB cap can never fire, and wrapping aresponse.json()/Thrift parse inreadBodyWithLimitis cargo-culting
Litmus test: "Can a user make this one fetch arbitrarily large, with nothing upstream stopping it?" Yes -> use the pattern. No (platform hard-cap, or already paginated) -> a per-file byte cap adds noise, not safety. Borderline: a user-configured/self-hosted endpoint with no platform cap (e.g. Obsidian) — bound it only if the content is genuinely unbounded.
Review Workflow
- Identify every changed data source:
- database queries
- storage lists/downloads/uploads
- external API pagination
- file reads and HTTP responses
- workflow logs, snapshots, payloads, arrays, and manifests
- queues, cron routes, and background jobs
- For each source, write down the maximum cardinality and maximum bytes. If the code does not enforce one, it is unbounded.
- Trace whether data is processed incrementally or accumulated:
- arrays from
select,findMany,Promise.all,map,filter,flatMap - maps/sets keyed by all users, workspaces, executions, files, or rows
Buffer.concat,response.arrayBuffer(),response.text(),JSON.stringify,JSON.parse- queues of promises or job payloads built before dispatch
- arrays from
- Check concurrency separately from memory:
- no
Promise.all(items.map(...))unlessitemsis already small and bounded - use chunks, sequential loops, queue concurrency, or a concurrency limiter
- align concurrency with DB pool size, storage/API limits, and task queue semantics
- no
- Verify SQL shape:
- every bulk query has
LIMIT - large pagination uses cursor/keyset style (
id > afterId, timestamps plus unique ID), not deepOFFSET IN (...)lists are chunked- side-effect rows selected before delete have per-batch and per-run caps
- every bulk query has
- Verify byte safety:
- check
Content-Lengthwhen available - stream with cumulative byte accounting
- cap both input bytes and expanded output bytes
- reject or reference oversized values before serializing large JSON responses
- check
- Confirm failure behavior:
- exceeding a cap should stop before loading more data
- partial successful work should be preserved when the API contract expects it
- retries should not duplicate huge in-memory state
- cleanup jobs should make progress over future runs instead of widening one run
Red Flags
- loads all active workspaces, users, executions, logs, files, messages, or subscriptions before filtering
- builds a full
MaporSetfor a platform-wide scope - uses
Promise.allover rows from an unbounded query - fetches all pages from an external API before processing
- reads an entire file, HTTP response, or stream without a max byte budget
- checks size only after
Buffer.concat,arrayBuffer,text,JSON.parse, or parse expansion - a KB connector silently drops or truncates an oversized file instead of recording it as a failed (skipped) row
- chunks only after loading the complete dataset
- paginates with unbounded/deep
OFFSETon a mutable or large table - creates one queue job per row without batching or a queue-level concurrency key
- accumulates per-row errors/results with no maximum
- adds a cache, singleton, or module-level collection without eviction or size limits
Preferred Fixes
- Move filters into SQL/API requests and select only needed columns.
- Replace full-table loads with cursor/keyset pagination and a deterministic order.
- Process one page/batch at a time; do not keep previous pages unless needed.
- Add per-batch and per-run row caps so long backlogs drain across repeated jobs.
- Split large ID lists with
selectRowsByIdChunksorchunkArrayafter bounding the source. - Use
chunkedBatchDeletefor cleanup loops with row side effects. - Use stream-limit helpers for file/HTTP/body reads.
- Store large workflow values as refs/manifests and materialize only within a caller budget.
- Replace unbounded
Promise.allwith sequential chunk loops, queue concurrency, or a small limiter. - Include tests that prove caps stop work early and partial results or progress are preserved.
Findings Format
Lead with concrete findings, ordered by risk:
## Findings
- **P1 Unbounded workspace load in cleanup dispatch** (`path/to/file.ts`)
The new path calls `select().from(workspace)` without a limit, then builds maps for every row before dispatch. In production this scales with all active workspaces and can exhaust the app process. Page by `workspace.id` with a fixed limit and dispatch bounded chunks.
## Good Signals
- Uses `readResponseToBufferWithLimit` for external downloads.
- Inline fallback processes chunks sequentially.
## Residual Risk
- The row cap is explicit, but no test currently proves the loop stops at the cap.Only say "good to go" when every changed source has explicit row, byte, and concurrency bounds or the boundedness is proven by a stable invariant.
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 1
- simstudioai/sim★ 30k94% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository54 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/constitution.mdcCursor rule
- .cursor/rules/emcn-components.mdcCursor rule
- .cursor/rules/global.mdcCursor rule
- .cursor/rules/landing-seo-geo.mdcCursor rule
- .cursor/rules/sim-architecture.mdcCursor rule
- .cursor/rules/sim-components.mdcCursor rule
- .cursor/rules/sim-hooks.mdcCursor rule
- .cursor/rules/sim-imports.mdcCursor rule
- .cursor/rules/sim-integrations.mdcCursor rule
- .cursor/rules/sim-queries.mdcCursor rule
- .cursor/rules/sim-sandbox.mdcCursor rule
- .cursor/rules/sim-stores.mdcCursor rule
- .cursor/rules/sim-styling.mdcCursor rule
- .cursor/rules/sim-testing.mdcCursor rule
- .cursor/rules/sim-typescript.mdcCursor rule
- .cursor/rules/sim-ui-copy.mdcCursor rule
- add-block-previewSkill
- add-blockSkill
- add-column-typeSkill
- add-connectorSkill
- add-enrichmentSkill
- add-feature-flagSkill
- add-hosted-keySkill
- add-integrationSkill
- add-managed-cliSkill
- add-modelSkill
- add-toolsSkill
- add-triggerSkill
- babysitSkill
- cleanupSkill
- councilSkill
- db-migrateSkill
- design-taste-frontendSkill
- emcn-design-reviewSkill
- emil-design-engSkill
- make-interfaces-feel-betterSkill
- migrate-application-operationSkill
- react-query-best-practicesSkill
- shipSkill
- tool-registry-boundarySkill
- v2-api-conventionsSkill
- validate-connectorSkill
- validate-integrationSkill
- validate-modelSkill
- validate-triggerSkill
- you-might-not-need-a-callbackSkill
- you-might-not-need-a-commentSkill
- you-might-not-need-a-memoSkill
- you-might-not-need-an-effectSkill
- you-might-not-need-stateSkill
- you-might-not-need-url-stateSkill
- add-settings-pageSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

