A
affaan-m
@mayurrathi
⭐ 5 GitHub stars

Cc Skill Backend Patterns

Backend architecture patterns, API design, database optimization, and server-side best practices for Node.js, Express, and Next.js API routes.

mkdir -p ./skills/cc-skill-backend-patterns && curl -sfL https://raw.githubusercontent.com/mayurrathi/awesome-agent-skills/main/skills/cc-skill-backend-patterns/SKILL.md -o ./skills/cc-skill-backend-patterns/SKILL.md

Run in terminal / PowerShell. Requires curl (Unix) or PowerShell 5+ (Windows).

Skill Content

# Backend Development Patterns


Backend architecture patterns and best practices for scalable server-side applications.


API Design Patterns


RESTful API Structure


```typescript

// ✅ Resource-based URLs

GET /api/markets # List resources

GET /api/markets/:id # Get single resource

POST /api/markets # Create resource

PUT /api/markets/:id # Replace resource

PATCH /api/markets/:id # Update resource

DELETE /api/markets/:id # Delete resource


// ✅ Query parameters for filtering, sorting, pagination

GET /api/markets?status=active&sort=volume&limit=20&offset=0

```


Repository Pattern


```typescript

// Abstract data access logic

interface MarketRepository {

findAll(filters?: MarketFilters): Promise<Market[]>

findById(id: string): Promise<Market | null>

create(data: CreateMarketDto): Promise<Market>

update(id: string, data: UpdateMarketDto): Promise<Market>

delete(id: string): Promise<void>

}


class SupabaseMarketRepository implements MarketRepository {

async findAll(filters?: MarketFilters): Promise<Market[]> {

let query = supabase.from('markets').select('*')


if (filters?.status) {

query = query.eq('status', filters.status)

}


if (filters?.limit) {

query = query.limit(filters.limit)

}


const { data, error } = await query


if (error) throw new Error(error.message)

return data

}


// Other methods...

}

```


Service Layer Pattern


```typescript

// Business logic separated from data access

class MarketService {

constructor(private marketRepo: MarketRepository) {}


async searchMarkets(query: string, limit: number = 10): Promise<Market[]> {

// Business logic

const embedding = await generateEmbedding(query)

const results = await this.vectorSearch(embedding, limit)


// Fetch full data

const markets = await this.marketRepo.findByIds(results.map(r => r.id))


// Sort by similarity

return markets.sort((a, b) => {

const scoreA = results.find(r => r.id === a.id)?.score || 0

const scoreB = results.find(r => r.id === b.id)?.score || 0

return scoreA - scoreB

})

}


private async vectorSearch(embedding: number[], limit: number) {

// Vector search implementation

}

}

```


Middleware Pattern


```typescript

// Request/response processing pipeline

export function withAuth(handler: NextApiHandler): NextApiHandler {

return async (req, res) => {

const token = req.headers.authorization?.replace('Bearer ', '')


if (!token) {

return res.status(401).json({ error: 'Unauthorized' })

}


try {

const user = await verifyToken(token)

req.user = user

return handler(req, res)

} catch (error) {

return res.status(401).json({ error: 'Invalid token' })

}

}

}


// Usage

export default withAuth(async (req, res) => {

// Handler has access to req.user

})

```


Database Patterns


Query Optimization


```typescript

// ✅ GOOD: Select only needed columns

const { data } = await supabase

.from('markets')

.select('id, name, status, volume')

.eq('status', 'active')

.order('volume', { ascending: false })

.limit(10)


// ❌ BAD: Select everything

const { data } = await supabase

.from('markets')

.select('*')

```


N+1 Query Prevention


```typescript

// ❌ BAD: N+1 query problem

const markets = await getMarkets()

for (const market of markets) {

market.creator = await getUser(market.creator_id) // N queries

}


// ✅ GOOD: Batch fetch

const markets = await getMarkets()

const creatorIds = markets.map(m => m.creator_id)

const creators = await getUsers(creatorIds) // 1 query

const creatorMap = new Map(creators.map(c => [c.id, c]))


markets.forEach(market => {

market.creator = creatorMap.get(market.creator_id)

})

```


Transaction Pattern


```typescript

async function createMarketWithPosition(

marketData: CreateMarketDto,

positionData: CreatePositionDto

) {

// Use Supabase transa

🎯 Best For

  • Claude users
  • Software engineers
  • Development teams
  • Tech leads

💡 Use Cases

  • Code quality improvement
  • Best practice enforcement

📖 How to Use This Skill

  1. 1

    Install the Skill

    Copy the install command from the Terminal tab and run it. The SKILL.md file downloads to your local skills directory.

  2. 2

    Load into Your AI Assistant

    Open Claude and reference the skill. Paste the SKILL.md content or use the system prompt tab.

  3. 3

    Apply Cc Skill Backend Patterns to Your Work

    Open your project in the AI assistant and ask it to apply the skill. Start with a small module to verify the output quality.

  4. 4

    Review and Refine

    Review AI suggestions before committing. Run tests, check for regressions, and iterate on the skill output.

❓ Frequently Asked Questions

Is Cc Skill Backend Patterns compatible with Cursor and VS Code?

Yes — this skill works with any AI coding assistant including Cursor, VS Code with Copilot, and JetBrains IDEs.

Do I need specific dependencies for Cc Skill Backend Patterns?

Check the install command and Works With section. Most code skills only require the AI assistant and your codebase.

How do I install Cc Skill Backend Patterns?

Copy the install command from the Terminal tab and run it. The skill downloads to ./skills/cc-skill-backend-patterns/SKILL.md, ready to use.

Can I customize this skill for my team?

Absolutely. Edit the SKILL.md file to add team-specific instructions, examples, or workflows.

⚠️ Common Mistakes to Avoid

Skipping validation

Always test AI-generated code changes, even for simple refactors.

Missing dependency updates

Check if the skill requires updated dependencies or new packages.

🔗 Related Skills