agentleFS
harrissohail6harrissohail6/claude-code-config/skills/microservices/SKILL.md

microservices

Skill1 starsChanged 11 months agoMITView on GitHub

Microservices architecture patterns. Auto-activates when designing distributed systems or service communication.

Files
SKILL.md

Microservices Architecture

Service Design Principles

Single Responsibility

Each service owns one business capability:

  • User Service - Authentication, profiles
  • Order Service - Orders, checkout
  • Inventory Service - Stock management
  • Payment Service - Payments, refunds

Database per Service

┌──────────────┐    ┌──────────────┐
│ User Service │    │ Order Service│
└──────┬───────┘    └──────┬───────┘
       │                   │
   ┌───┴───┐           ┌───┴───┐
   │User DB│           │Order DB│
   └───────┘           └────────┘

Communication Patterns

Synchronous (REST/gRPC)

// REST call
const user = await fetch(`${USER_SERVICE}/users/${userId}`);

// gRPC (faster, typed)
const user = await userClient.getUser({ userId });

Asynchronous (Events)

// Publisher
await messageQueue.publish('order.created', {
  orderId: order.id,
  userId: order.userId,
  items: order.items
});

// Subscriber (Inventory Service)
messageQueue.subscribe('order.created', async (event) => {
  await reserveInventory(event.items);
});

API Gateway

Client → API Gateway → Services
              │
              ├── Authentication
              ├── Rate Limiting
              ├── Load Balancing
              └── Request Routing

Service Discovery

// Kubernetes - DNS-based
const userService = 'http://user-service.default.svc.cluster.local';

// Consul/Eureka - Registry-based
const userService = await serviceRegistry.getService('user-service');

Resilience Patterns

Circuit Breaker

const breaker = new CircuitBreaker(fetchUser, {
  failureThreshold: 5,
  resetTimeout: 30000
});

const user = await breaker.fire(userId);

Retry with Backoff

async function withRetry<T>(fn: () => Promise<T>, maxRetries = 3): Promise<T> {
  for (let i = 0; i < maxRetries; i++) {
    try {
      return await fn();
    } catch (error) {
      if (i === maxRetries - 1) throw error;
      await sleep(Math.pow(2, i) * 1000);
    }
  }
}

Data Consistency

Saga Pattern

1. Create Order (Order Service)
2. Reserve Inventory (Inventory Service)
3. Process Payment (Payment Service)
4. Confirm Order (Order Service)

If step fails → Compensating transactions

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.