Skip to content

Commit 4d6d56d

Browse files
committed
feat: Add comprehensive AI agent skills library
1 parent d9e3b70 commit 4d6d56d

15 files changed

Lines changed: 983 additions & 0 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
name: backend-development
3+
description: Comprehensive backend development skill for building scalable backend systems using Python (FastAPI), Postgres, Redis, and more. Includes API design, database optimization, security implementation, and performance tuning.
4+
---
5+
6+
# Backend Development
7+
8+
This skill provides expert guidance for building robust, scalable, and secure backend systems, primarily focusing on the Python/FastAPI ecosystem used in this project.
9+
10+
## Core Capabilities
11+
12+
### 1. API Design & Implementation
13+
- **RESTful Design**: Resource-oriented URLs, proper HTTP methods, and status codes.
14+
- **FastAPI Best Practices**: Validation with Pydantic, dependency injection, and async handlers.
15+
- **Documentation**: Automatic OpenAPI generation, clear descriptions, and examples.
16+
17+
### 2. Database Management
18+
- **Schema Design**: Normalized relationships, indexing strategies, and migration management (Alembic).
19+
- **ORM Usage**: SQLAlchemy async session management, repository pattern.
20+
- **Optimization**: N+1 problem avoidance, query analysis, connection pooling.
21+
22+
### 3. Security
23+
- **Authentication**: JWT/OAuth2 implementation, password hashing (bcrypt/argon2).
24+
- **Authorization**: Role-Based Access Control (RBAC), scopes.
25+
- **Data Protection**: Input sanitization, SQL injection prevention (via ORM), secure headers.
26+
27+
### 4. Performance Tuning
28+
- **Caching**: Redis implementation for specific endpoints or data.
29+
- **Async I/O**: Non-blocking database and API calls.
30+
- **Background Tasks**: Offloading heavy processing (Celery/Cloud Tasks).
31+
32+
## Design Patterns
33+
34+
- **Repository Pattern**: Decouple business logic from data access.
35+
- **Dependency Injection**: Manage dependencies (DB sessions, config) cleanly.
36+
- **Service Layer**: Encapsulate complex business rules.
37+
38+
## When to Use
39+
40+
- Designing new API endpoints or microservices.
41+
- Optimizing slow database queries.
42+
- Implementing complex business logic.
43+
- Reviewing backend code for security and performance.
44+
- Setting up authentication and authorization flows.
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
---
2+
name: cache-components
3+
description: Expert guidance for Next.js Cache Components and Partial Prerendering (PPR). PROACTIVE ACTIVATION when cacheComponents config is detected.
4+
---
5+
6+
Expert guidance for Next.js Cache Components and Partial Prerendering (PPR).
7+
8+
**PROACTIVE ACTIVATION**: Use this skill automatically when working in Next.js projects that have `cacheComponents: true` in their `next.config.ts` or `next.config.js`.
9+
10+
**DETECTION**: At the start of a session in a Next.js project, check for `cacheComponents: true` in `next.config`. If enabled, this skill's patterns should guide all component authoring, data fetching, and caching decisions.
11+
12+
**USE CASES**:
13+
- Implementing `'use cache'` directive
14+
- Configuring cache lifetimes with `cacheLife()`
15+
- Tagging cached data with `cacheTag()`
16+
- Invalidating caches with `updateTag()` / `revalidateTag()`
17+
- Optimizing static vs dynamic content boundaries
18+
- Debugging cache issues
19+
- Reviewing Cache Component implementations
20+
21+
## Project Detection
22+
23+
When starting work in a Next.js project, check if Cache Components are enabled:
24+
25+
```bash
26+
# Check next.config.ts or next.config.js for cacheComponents
27+
grep -r "cacheComponents" next.config.* 2>/dev/null
28+
```
29+
30+
If `cacheComponents: true` is found, apply this skill's patterns proactively when:
31+
- Writing React Server Components
32+
- Implementing data fetching
33+
- Creating Server Actions with mutations
34+
- Optimizing page performance
35+
- Reviewing existing component code
36+
37+
## Core Concept: The Caching Decision Tree
38+
39+
When writing a **React Server Component**, ask:
40+
41+
1. **Does it depend on request context?** (cookies, headers, searchParams)
42+
2. **Can this be cached?** (Is the output the same for all users?)
43+
- **YES** -> `'use cache'` + `cacheTag()` + `cacheLife()`
44+
- **NO** -> Wrap in `<Suspense>` (dynamic streaming)
45+
46+
## Philosophy: Code Over Configuration
47+
48+
Cache Components represents a shift from segment-based configuration to compositional code:
49+
50+
- **Before (Deprecated)**: `export const revalidate = 3600`
51+
- **After**: `cacheLife('hours')` inside `'use cache'`
52+
53+
- **Before (Deprecated)**: `export const dynamic = 'force-static'`
54+
- **After**: Use `'use cache'` and Suspense boundaries
55+
56+
## Quick Start
57+
58+
### 1. Enable Configuration
59+
```typescript
60+
// next.config.ts
61+
import type { NextConfig } from "next";
62+
63+
const nextConfig: NextConfig = {
64+
experimental: {
65+
ppr: true,
66+
dynamicIO: true, // often correlated features
67+
},
68+
// Ensure basic cache components flag if required by your version
69+
};
70+
71+
export default nextConfig;
72+
```
73+
74+
### 2. Basic Usage
75+
76+
```typescript
77+
import { cacheLife } from 'next/cache';
78+
79+
async function CachedPosts() {
80+
'use cache'
81+
cacheLife('hours'); // Cache for hours
82+
83+
const posts = await db.posts.findMany();
84+
return <PostList posts={posts} />;
85+
}
86+
```
87+
88+
## Core APIs
89+
90+
### `'use cache'`
91+
Marks a function, component, or file as cacheable. The return value is cached and shared across requests.
92+
93+
### `cacheLife(profile)`
94+
Control cache duration using semantic profiles:
95+
- `'seconds'`: Short-lived
96+
- `'minutes'`: Medium-lived
97+
- `'hours'`: Long-lived
98+
- `'days'`: Very long-lived
99+
- `'weeks'`: Static-like content
100+
- `'max'`: Permanent cache
101+
102+
### `cacheTag(...tags)`
103+
Tag cached data for on-demand invalidation.
104+
105+
```typescript
106+
import { cacheTag } from 'next/cache';
107+
108+
async function getUserProfile(id: string) {
109+
'use cache'
110+
cacheTag('user-profile', `user-${id}`);
111+
// ... fetch logic
112+
}
113+
```
114+
115+
### `revalidateTag(tag)` / `expireTag(tag)`
116+
Invalidate cached data in background or immediately.
117+
118+
```typescript
119+
'use server'
120+
import { expireTag } from 'next/cache';
121+
122+
export async function updateUser(id: string, data: any) {
123+
await db.user.update({ where: { id }, data });
124+
expireTag(`user-${id}`); // Invalidate specific cache
125+
}
126+
```
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
---
2+
name: component-refactoring
3+
description: Refactor high-complexity React components. Use when complexity metrics are high or to split monolithic UI.
4+
---
5+
6+
# Component Refactoring Skill
7+
8+
Refactor high-complexity React components with proven patterns and workflows.
9+
10+
**Complexity Threshold**: Components with **cyclomatic complexity > 50** or **line count > 300** should be candidates for refactoring.
11+
12+
**Use When**:
13+
- `pnpm analyze-component` shows high complexity.
14+
- Users ask for "code splitting", "hook extraction", or "cleanup".
15+
- A component file exceeds 300 lines of code.
16+
17+
## Core Refactoring Patterns
18+
19+
### 1. Extract Custom Hooks
20+
**Goal**: Separate UI from State/Logic.
21+
22+
**Before**:
23+
```tsx
24+
function UserList() {
25+
const [users, setUsers] = useState([]);
26+
const [loading, setLoading] = useState(false);
27+
28+
useEffect(() => {
29+
setLoading(true);
30+
fetch('/api/users').then(data => {
31+
setUsers(data);
32+
setLoading(false);
33+
});
34+
}, []);
35+
36+
if (loading) return <Spinner />;
37+
return <ul>{users.map(u => <li key={u.id}>{u.name}</li>)}</ul>;
38+
}
39+
```
40+
41+
**After**:
42+
```tsx
43+
// hooks/useUsers.ts
44+
function useUsers() {
45+
return useQuery({ queryKey: ['users'], queryFn: fetchUsers });
46+
}
47+
48+
// UserList.tsx
49+
function UserList() {
50+
const { data: users, isLoading } = useUsers();
51+
if (isLoading) return <Spinner />;
52+
return <UserListView users={users} />;
53+
}
54+
```
55+
56+
### 2. Extract Sub-Components
57+
**Goal**: Break down monolithic JSX.
58+
59+
**Before**:
60+
```tsx
61+
function Dashboard() {
62+
return (
63+
<div>
64+
<header>...</header>
65+
<aside>...</aside>
66+
<main>
67+
<section className="stats">...</section>
68+
<section className="feed">...</section>
69+
</main>
70+
</div>
71+
);
72+
}
73+
```
74+
75+
**After**:
76+
```tsx
77+
function Dashboard() {
78+
return (
79+
<Layout>
80+
<DashboardHeader />
81+
<DashboardSidebar />
82+
<DashboardContent>
83+
<StatsWidget />
84+
<ActivityFeed />
85+
</DashboardContent>
86+
</Layout>
87+
);
88+
}
89+
```
90+
91+
### 3. Simplify Conditional Logic
92+
**Goal**: Reduce nesting and `if/else` checks implementation details.
93+
94+
- Use **Lookup Tables** (Maps/Objects) instead of Switch/If-Else chains.
95+
- Use **Guard Clauses** (Early Returns) to avoid deep nesting.
96+
97+
### 4. Extract Modal Management
98+
**Goal**: Centralize modal state and logic.
99+
100+
- Move modal definitions to a generic `<ModalManager />` or context if reused globally.
101+
- Keep the `isOpen` state locally if specific to a single component, but extract the Modal content to a separate file.
102+
103+
## Workflow
104+
105+
1. **Analyze**: Run complexity analysis or review the file manually.
106+
2. **Plan**: Identify seam lines (Logic vs UI, Section vs Section).
107+
3. **Extract**: Create new files for hooks or components.
108+
4. **Integrate**: Replace original code with imports.
109+
5. **Verify**: Ensure functionality remains identical and tests pass.

.agent/skills/create-pr/SKILL.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
name: create-pr
3+
description: Automates the creation of detailed, well-formatted Pull Requests using the GitHub CLI. Parses conventional commits to generate titles and descriptions.
4+
---
5+
6+
# Create PR
7+
8+
This skill streamlines the Pull Request process, ensuring consistent and high-quality PR descriptions.
9+
10+
## Prerequisites
11+
12+
- `gh` (GitHub CLI) must be installed and authenticated.
13+
- The current branch must have commits that are not yet on the remote (or a corresponding remote branch).
14+
15+
## Workflow
16+
17+
1. **Analyze Context**: Checks the git log to understand the changes (`feat`, `fix`, `chore`).
18+
2. **Generate Metadata**:
19+
- **Title**: Uses the conventional commit format (e.g., `feat: Implement user login`).
20+
- **Body**: Summarizes the changes, links to issues, and provides verification steps.
21+
3. **Execute**: Runs `gh pr create`.
22+
23+
## Usage
24+
25+
```bash
26+
# Standard usage (interactive)
27+
gh pr create
28+
29+
# Fully automated with flags
30+
gh pr create --title "feat: Add user profile" --body "Implements user profile page..."
31+
```
32+
33+
## Best Practices for PRs
34+
35+
- **Small & Focused**: Keep PRs limited to a single logical change.
36+
- **Linked Issues**: Always link to the task/issue (e.g., `Closes #123`).
37+
- **Self-Review**: Review your own diff before creating the PR.
38+
- **Verification**: Explicitly state how you verified the change (screenshots, test output).
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
name: devops-iac-engineer
3+
description: Expert guidance for designing, implementing, and maintaining cloud infrastructure using Experience in Infrastructure as Code (IaC) principles. Use this skill for architecting cloud solutions, setting up CI/CD pipelines, implementing observability, and following SRE best practices.
4+
---
5+
6+
# DevOps IaC Engineer
7+
8+
This skill provides expertise in designing and managing cloud infrastructure using Infrastructure as Code (IaC) and DevOps/SRE best practices.
9+
10+
## When to Use
11+
12+
- Designing cloud architecture (AWS, GCP, Azure)
13+
- Implementing or refactoring CI/CD pipelines
14+
- Setting up observability (logging, metrics, tracing)
15+
- Creating Kubernetes clusters and container orchestration strategies
16+
- Implementing security controls and compliance checks
17+
- Improving system reliability (SLO/SLA, Disaster Recovery)
18+
19+
## Infrastructure as Code (IaC) Principles
20+
21+
- **Declarative Code**: Use Terraform/OpenTofu to define the desired state.
22+
- **GitOps**: Code repository is the single source of truth. Changes are applied via PRs and automated pipelines.
23+
- **Immutable Infrastructure**: Replace servers/containers rather than patching them in place.
24+
25+
## Core Domains
26+
27+
### 1. Terraform & IaC
28+
- Use modules for reusability.
29+
- Separate state by environment (dev, stage, prod) and region.
30+
- Automate `plan` and `apply` in CI/CD.
31+
32+
### 2. Kubernetes & Containers
33+
- Build small, stateless containers.
34+
- Use Helm or Kustomize for resource management.
35+
- Implement resource limits and requests.
36+
- Use namespaces for isolation.
37+
38+
### 3. CI/CD Pipelines
39+
- **CI**: Lint, test, build, and scan (security) on every commit.
40+
- **CD**: Automated deployment to lower environments; manual approval for production.
41+
- Use tools like GitHub Actions, Cloud Build, or ArgoCD.
42+
43+
### 4. Observability
44+
- **Logs**: Centralized logging (e.g., Cloud Logging, ELK).
45+
- **Metrics**: Prometheus/Grafana or Cloud Monitoring.
46+
- **Tracing**: OpenTelemetry for distributed tracing.
47+
48+
### 5. Security (DevSecOps)
49+
- Scan IaC for misconfigurations (e.g., Checkov, Trivy).
50+
- Manage secrets utilizing Secret Manager or Vault (never in code).
51+
- Least privilege IAM roles.
52+
53+
## SRE Practices
54+
55+
- **SLI/SLO**: Define Service Level Indicators and Objectives for critical user journeys.
56+
- **Error Budgets**: Use error budgets to balance innovation and reliability.
57+
- **Post-Mortems**: Conduct blameless post-mortems for incidents.

0 commit comments

Comments
 (0)