Common Documentation
ASecurityAssuming a TypeScript/JavaScript retry function: ```ts /** * Retries an operation using exponential backoff with jitter. * * JSDoc documents the public API, while inline comments explain why * each retry decision exists. * * @param operation Operation that may temporarily fail. * @param maxRetries Maximum number of retries after the initial attempt. * @param baseDelayMs Initial backoff duration in milliseconds. * @param maxDelayMs Upper bound for the calculated delay. * @returns The successfu...
- 584 stars
- 0 votes
- 0 copies
- 0 views
- Added September 5, 2026
Works with
Security analysis
100/100Pro scans all 11 files and shows the line behind each finding
npx -y skills add HoangNguyen0403/agent-skills-standard --skill common-documentation --agent claude-codeAre you the author of Common Documentation?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/hoangnguyen0403-common-documentation-f713dbe5)Assuming a TypeScript/JavaScript retry function:
```ts
/**
* Retries an operation using exponential backoff with jitter.
*
* JSDoc documents the public API, while inline comments explain why
* each retry decision exists.
*
* @param operation Operation that may temporarily fail.
* @param maxRetries Maximum number of retries after the initial attempt.
* @param baseDelayMs Initial backoff duration in milliseconds.
* @param maxDelayMs Upper bound for the calculated delay.
* @returns The successful operation result.
*
* @example
* // Usage
* const result = await retryWithBackoff(() => fetchData(), 5, 100, 10_000);
*/
async function retryWithBackoff<T>(
operation: () => Promise<T>,
maxRetries: number,
baseDelayMs: number,
maxDelayMs: number,
): Promise<T> {
for (let attempt = 0; ; attempt++) {
try {
return await operation();
} catch (error) {
// Stop retrying once the failure is no longer considered transient.
if (attempt >= maxRetries) {
throw error;
}
// Exponential growth gives a recovering dependency time to stabilize.
const exponentialDelay = Math.min(
maxDelayMs,
baseDelayMs * 2 ** attempt,
);
// Jitter prevents many clients from retrying simultaneously—the
// thundering herd problem—after a shared failure.
const delay = Math.random() * exponentialDelay;
await new Promise((resolve) => setTimeout(resolve, delay));
}
}
}
```
Files in this skill
- eval-1.baseline.md
- eval-1.with-skill.md
- eval-2.baseline.md
- eval-2.with-skill.md
- eval-3.baseline.md
- eval-3.with-skill.md
- trigger-1.md
- trigger-2.md
- trigger-3.md
- trigger-4.md
Attribution
Related skills
View all in development →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.