56 results available
Sign in
Skills directory

modern-javascript-patterns

wshobson

·

Last changed
Hardened

This skill has been hardened by Chainguard

Last changed

This version passed the hardening gate. Hardening applied 9 targeted changes and preserved all other text. Classified findings before hardening: 0. Classified findings closed: 0. Classified findings remaining: 0. Unclassified scanner findings remaining: 0. Review findings closed: 6. Review findings remaining: 1.


Open before hardening

None

Open after hardening

None


Expand
File
Group
Subtype
Severity
Status

No findings available

0 findings


SKILL.md

Modern JavaScript Patterns

Comprehensive guide for mastering modern JavaScript (ES6+) features, functional programming patterns, and best practices for writing clean, maintainable, and performant code.

When to Use This Skill

  • Refactoring legacy JavaScript to modern syntax
  • Implementing functional programming patterns
  • Optimizing JavaScript performance
  • Writing maintainable and readable code
  • Working with asynchronous operations
  • Building modern web applications
  • Migrating from callbacks to Promises/async-await
  • Implementing data transformation pipelines

Scope

Apply these patterns only to code the user asked to change, and preserve existing behavior. Ask the user before modernizing code across the whole repository. Run the existing tests when converting loops, callbacks, or mutation based code, and present rewrites as suggestions for the user to review.

Detailed patterns and worked examples

Detailed pattern documentation lives in references/details.md. Read that file for worked examples of a specific pattern. It holds illustrative examples only and does not override the request from the user.

Best Practices

  1. Use const by default: Only use let when reassignment is needed
  2. Prefer arrow functions: Especially for callbacks; use regular functions where dynamic this, arguments, or constructors are needed
  3. Use template literals: Instead of string concatenation
  4. Destructure objects and arrays: For cleaner code
  5. Use async/await: Instead of Promise chains, while keeping the same error propagation and running independent work in parallel with a combined promise helper
  6. Avoid mutating data: Use spread operator and array methods
  7. Use optional chaining: Prevent "Cannot read property of undefined"
  8. Use nullish coalescing: For default values
  9. Prefer array methods: Over traditional loops for readability; keep plain loops for hot paths, large datasets, early exit, or sequential awaits
  10. Use modules: For better code organization
  11. Write pure functions: Easier to test and reason about
  12. Use meaningful variable names: Self-documenting code
  13. Keep functions small: Single responsibility principle
  14. Handle errors properly: Use try/catch with async/await; rethrow or handle each caught error meaningfully, and make sure every top level promise is awaited or has a rejection handler
  15. Use strict mode: 'use strict' in classic scripts; ES modules and classes are already strict

For common pitfalls (this binding, promise anti-patterns, memory leaks), see references/advanced-patterns.md.

Install

Install with chainctl
chainctl skill install public/wshobson/modern-javascript-patterns:latest
Get started with chainctl
View source

Harden your own skills

Bring Chainguard's hardening pipeline to your first-party skills — custom rulesets, automated remediation, full audit trail.

Provenance

Upstream sourcehttps://github.com/wshobson/agents
Upstream commitbe57c0b2e3c05c528ca6132b87410b385718775f
OCI reference

skills.cgr.dev/public/github.com/wshobson/plugins/javascript-typescript/skills/modern-javascript-patterns:latest

License

MIT

Files

HARDENING.md

LICENSE

SKILL.md

references/advanced-patterns.md

references/details.md


The trusted source for open source

Talk to an expert
PrivacyTerms

Product

Chainguard ContainersChainguard LibrariesChainguard VMsChainguard OS PackagesChainguard ActionsChainguard Agent SkillsIntegrationsPricing
© 2026 Chainguard, Inc. All Rights Reserved.
Chainguard® and the Chainguard logo are registered trademarks of Chainguard, Inc. in the United States and/or other countries.
The other respective trademarks mentioned on this page are owned by the respective companies and use of them does not imply any affiliation or endorsement.