Install the skill above, then run this in your AI tool:
/gravitas-perf <your description>
About
Performance analysis mode. Load in addition to `skills/gravitas/SKILL.md`.
All perf claims require **measured before/after numbers**. No guessing.
Source
What gets added to your project
Preview every file this package writes on install before you run the command above.
Summary
>
Skill instructions
GRAVITAS — Performance Extension
Performance analysis mode. Load in addition to skills/gravitas/SKILL.md.
All perf claims require measured before/after numbers. No guessing.
Core Rule: Measure Before Optimizing
Never optimize without a baseline measurement. "This is slow" is not a baseline.
code
Baseline required:
- What is the current latency/throughput? (measured, not estimated)
- What is the target? (user's goal or SLA)
- What is the profiler saying is hot? (not intuition)
Performance Recon Additions
bash
# Database — N+1 queries
grep -rn "\.find\|\.findOne\|\.select" src/ --include="*.ts" | grep -v "include\|join"# Missing indexes
grep -rn "WHERE.*email\|WHERE.*username\|WHERE.*userId" src/ --include="*.ts"# → check if these columns have DB indexes# Unoptimized loops
grep -rn "for.*await\|forEach.*await" src/ --include="*.ts"# → sequential async where parallel would work# Missing memoization
grep -rn "\.map\|\.filter\|\.reduce" src/ --include="*.ts" -A 2 | grep "expensive\|compute\|calculate"# Bundle size (frontend)
npx bundlesize 2>/dev/null || du -sh dist/ 2>/dev/null
# Memory leaks
grep -rn "setInterval\|addEventListener" src/ --include="*.ts" | grep -v "clearInterval\|removeEventListener"
Measurement Protocol
Before any optimization
bash
# API latency (using autocannon, wrk, or k6)
autocannon -c 10 -d 10 http://localhost:3000/api/users
# Record: req/sec, latency p50/p95/p99# Function benchmark (using vitest bench)
import { bench, describe } from 'vitest';
describe('processUsers', () => {
bench('current', () => processUsers(testData));
});
# Memory
node --inspect src/server.js &
# heap snapshot before and after load
BAD:
const users = await db.query('SELECT * FROM users');
for (const user of users) {
user.posts = await db.query('SELECT * FROM posts WHERE userId = $1', [user.id]);
// N queries for N users → N+1 total
}
GOOD:
const users = await db.query(`
SELECT u.*, json_agg(p.*) as posts
FROM users u
LEFT JOIN posts p ON p.userId = u.id
GROUP BY u.id
`);
// 1 query total
Sequential Async Where Parallel Works
typescript
BAD:
const user = awaitfetchUser(id);
const posts = awaitfetchPosts(id); // waits for user unnecessarilyconst comments = awaitfetchComments(id); // waits for postsGOOD:
const [user, posts, comments] = awaitPromise.all([
fetchUser(id),
fetchPosts(id),
fetchComments(id), // all start simultaneously
]);
Missing Cache for Expensive Computation
typescript
BAD: functiongetPermissions(userId: string) {
return db.query('SELECT * FROM permissions WHERE userId = $1', [userId]);
// called on every request
}
GOOD: const cache = newMap<string, Permission[]>();
functiongetPermissions(userId: string) {
if (cache.has(userId)) return cache.get(userId)!;
const perms = await db.query(...);
cache.set(userId, perms);
setTimeout(() => cache.delete(userId), 60_000); // 1min TTLreturn perms;
}
Missing Database Indexes
sql
-- Check slow queries
EXPLAIN ANALYZE SELECT*FROM users WHERE email ='user@example.com';
-- If: Seq Scan → MISSING INDEX-- FixCREATE INDEX idx_users_email ON users(email);
-- After: Index Scan → fast
Algorithmic Complexity Analysis
For any new algorithm, document complexity:
typescript
/**
* Finds duplicate usernames in O(n) time.
* @complexity O(n) time, O(n) space
*
* BAD alternative: O(n²) nested loops
*/functionfindDuplicates(usernames: string[]): string[] {
const seen = newSet<string>();
return usernames.filter(name => {
if (seen.has(name)) returntrue;
seen.add(name);
returnfalse;
});
}
Add this badge to a GitHub README so readers can open the package page and install the same version.
[](https://www.aipm-registry.com/skills/udaysharmadev/gravitas-perf/1.0.0?utm_source=github&utm_medium=readme&utm_campaign=package_badge)
This imported publisher has not claimed its AIPM account. A connected account confirms account control, but it does not guarantee that a package is safe.
AI assistant context
What this skill is for
@udaysharmadev/gravitas-perf@1.0.0 is an AIPM skill package for All tools. Use it when a project needs the reusable AI behavior described as: >
Run aipm add @udaysharmadev/gravitas-perf@1.0.0 in a project that has AIPM initialized.
Supported tools
@udaysharmadev/gravitas-perf@1.0.0 supports All tools.
Before installing
AIPM skills can add files to your project. Review the package name, target, description, license, and publisher before installing. Use a clean branch when trying a new skill.