typescript
What it does
This guide teaches how to write more efficient and clear TypeScript/JavaScript code. It shows examples of how to avoid common practices that can make code more complicated or slower, suggesting simpler and faster alternatives.
When to use it
- βWhen writing TypeScript or JavaScript code.
- βWhen you want to make your code more readable.
- βTo optimize your code's performance.
Skill link
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/super-code/typescript/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βHow can I rewrite this loop to be more efficient in JavaScript?β
5 new skills a week. 1 minute to read.
How it works
The guide compares the 'old way' (less efficient) with the 'new way' (more efficient) using code examples. It covers array and object operations, functions, and the use of types in TypeScript.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
TypeScript / JavaScript: Idiomatic Efficiency Reference
When to Use
- Use this skill when the task matches this description: Language-specific super-code guidelines for typescript.
Table of Contents
- Array & Object Operations
- Destructuring & Spread
- Async / Promises
- Functions & Closures
- TypeScript Types
- React (if applicable)
- Anti-patterns specific to TS/JS
1. Array & Object Operations {#arrays}
// β Imperative push loop
const result: string[] = []
for (const item of items) {
if (item.active) result.push(item.name.toUpperCase())
}
// β
const result = items.filter(i => i.active).map(i => i.name.toUpperCase())
// β Manual reduce for sum
let total = 0
for (const o of orders) total += o.amount
// β
const total = orders.reduce((sum, o) => sum + o.amount, 0)
// β Manual object copy + override
const updated = Object.assign({}, user)
updated.name = "Alice"
// β
const updated = { ...user, name: "Alice" }
// β Existence check before property access
const city = user.address ? user.address.city : undefined
// β
const city = user.address?.city
2. Destructuring & Spread {#destructuring}
// β Separate variable assignments
const name = user.name
const age = user.age
// β
const { name, age } = user
// β Index access for array elements
const first = arr[0]
const second = arr[1]
// β
const [first, second] = arr
// β Merging arrays with concat
const merged = a.concat(b).concat(c)
// β
const merged = [...a, ...b, ...c]
// β Omitting a key by delete (mutates)
const copy = { ...obj }
delete copy.password
// β
β destructure to omit
const { password, ...safe } = obj
3. Async / Promises {#async}
// β Promise chain when async/await is cleaner
fetchUser(id)
.then(user => fetchOrders(user.id))
.then(orders => process(orders))
.catch(handleError)
// β
try {
const user = await fetchUser(id)
const orders = await fetchOrders(user.id)
process(orders)
} catch (e) {
handleError(e)
}
// β Sequential awaits for independent operations
const user = await fetchUser(id)
const config = await fetchConfig()
// β
β run in parallel
const [user, config] = await Promise.all([fetchUser(id), fetchConfig()])
// β Wrapping already-async function in new Promise
const result = await new Promise((resolve) => {
someAsyncFn().then(resolve)
})
// β
const result = await someAsyncFn()
Don't await inside a .map() without Promise.all β it sequences what should be parallel.
4. Functions & Closures {#functions}
// β Arrow function with unnecessary block body
const double = (x: number) => { return x * 2 }
// β
const double = (x: number) => x * 2
// β Default parameter with if-guard
function greet(name?: string) {
if (!name) name = "World"
return `Hello, ${name}`
}
// β
function greet(name = "World") {
return `Hello, ${name}`
}
// β IIFE for no reason in module scope
;(function() {
const x = compute()
doSomething(x)
})()
// β
β just top-level statements in a module
const x = compute()
doSomething(x)
5. TypeScript Types {#types}
// β Explicit return type when inference is obvious
function add(a: number, b: number): number {
return a + b
}
// β
β let TS infer simple return types
function add(a: number, b: number) {
return a + b
}
// β any
function process(data: any) { ... }
// β
β use unknown + type guard, or a proper type/generic
function process<T extends Record<string, unknown>>(data: T) { ... }
// β Redundant interface for single-use inline shape
interface UserNameProps { name: string }
function UserName({ name }: UserNameProps) { ... }
// β
β inline for single-use
function UserName({ name }: { name: string }) { ... }
// Extract interface when reused in 2+ places
// β Type assertion (as) to silence a real type error
const el = document.getElementById("app") as HTMLDivElement
el.innerText = "hi" // crashes if el is null
// β
const el = document.getElementById("app")
if (!(el instanceof HTMLDivElement)) throw new Error("Missing #app")
el.innerText = "hi"
Prefer type for unions/intersections/aliases; interface for extensible object shapes.
6. React (if applicable) {#react}
// β Effect for derived state
β¦
FAQ
What is 'Destructuring & Spread'?
It's a way to extract values from arrays or objects into separate variables (destructuring) or to spread elements of an array or properties of an object into another, making code more concise.
Why use `async/await` instead of `.then()`?
`async/await` makes asynchronous code (dealing with time-consuming operations) look more like synchronous code (executing line by line), making it easier to read and manage errors.
What is 'Type Assertion'?
It's when you tell TypeScript that you are sure a value is of a certain type, even if it can't prove it. It's generally better to avoid it and let TypeScript infer types or use type checks.
Details
Original description by the author
Language-specific super-code guidelines for typescript.
Popularity
- GitHub stars
- 48k
- Ranking position
- #5901
- License
- MIT
- Updated
- 10/15/2026
Comments
- β¦
More skills from this repository
00-andruia-consultant
48kHelps your agent start or improve AI projects. It analyzes code, suggests tools, and creates action plans in Spanish.
007
48kLets your agent perform security audits and threat modeling. It's useful for protecting projects against attacks and vulnerabilities.
10-andruia-skill-smith
48kHelps your agent create or improve AI tools. It defines how tools work, writes documentation, and validates the structure.
20-andruia-niche-intelligence
48kLets your agent create a summary about a specific industry. It's useful for understanding the context, rules, usage patterns, and risks of a project, using reliable sources.
Similar skills
diffs
394kLets your agent produce a real, shareable diff of edits as a viewer link or image file, instead of a hand-written summary.
coding-agent
394kHelps your agent hand a larger coding job to Codex, Claude Code, or OpenCode as a background worker, then check on its progress.
gh-issues
394kHelps your agent find GitHub issues, pick the ones to work on, and open pull requests with fixes, including follow-up on review comments.