agentleFS
tejastn10tejastn10/workbench/skills/queues/sqs-consumer/SKILL.md

sqs-consumer

Skill1 starsChanged 2 months agoMITView on GitHub

Build and review an AWS SQS consumer correctly — classify every error terminal vs retryable, delete only after the downstream write succeeds, match visibility timeout to handler runtime, confirm the redrive policy and DLQ, handle partial batch failures, and make handlers idempotent. Use when building an SQS consumer, reviewing one, or when messages redeliver forever / land in the DLQ unexpectedly.

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Must be > the max handler runtime (incl.

    line 36

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

SQS consumer

The review corpus's #1 queue rule: every error path must be classified terminal vs retryable. An error that is neither deleted nor DLQ'd redelivers forever.

Message lifecycle

  1. Receive (long-poll: WaitTimeSeconds=20, not busy-poll).
  2. Process the message.
  3. On success — DeleteMessage. Never delete before the downstream write succeeds — delete-then-write means a crash loses the message.
  4. On retryable failure (transient 5xx, throttle, lock timeout) — do not delete; let the visibility timeout expire and SQS redelivers. Optionally ChangeMessageVisibility to add backoff.
  5. On terminal failure (bad payload, validation, a 4xx that won't change) — don't retry. Either delete + record the failure, or let it go to the DLQ via maxReceiveCount. Decide which per message type.

Redrive & DLQ

  • Confirm the deployed queue has the redrive policy the code assumes. The code relying on "it'll go to the DLQ after 5 tries" is wrong if the queue's RedrivePolicy / maxReceiveCount isn't actually set. Check the infra.
  • DLQ retention ≥ source retention. Alarm on ApproximateNumberOfMessagesVisible on the DLQ (observability/define-alerts).
  • Have a documented DLQ redrive path (re-process after a fix) — SQS supports redrive-from-DLQ.

Visibility timeout

  • Must be > the max handler runtime (incl. retries/backoff inside the handler). If the handler can run 90s and visibility is 30s, the message reappears and is processed concurrently → duplicates.
  • For long jobs, extend visibility with a heartbeat (ChangeMessageVisibility) rather than one huge timeout.

Batches

  • ReceiveMessage returns up to 10. If you process a batch and one fails, the whole batch redelivers unless you use ReportBatchItemFailures (Lambda event source) / delete the successful ones individually and leave the failed.
  • Per-item try/catch + continue — one bad message must not fail the batch.

Idempotency

  • SQS standard queues are at-least-once — handlers must be idempotent (dedup on a message/business id, or naturally idempotent writes).
  • FIFO queues give exactly-once processing within the dedup window + ordering per MessageGroupId — but still design idempotent.

Anti-patterns

  • ❌ An error path that's neither deleted nor DLQ'd.
  • ❌ DeleteMessage before the write succeeds.
  • ❌ Visibility timeout shorter than the handler can run.
  • ❌ Assuming a DLQ exists without checking the queue's redrive policy.
  • ❌ One bad message failing the whole batch.
  • ❌ A non-idempotent handler on a standard queue.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.