skills/doanchienthangdev/omgkit/coding-with-omega-leverage

coding-with-omega-leverage

SKILL.md

Coding with Omega Leverage

Master AI-first development patterns that multiply productivity 10-100x through specification-driven generation and systematic AI collaboration.

Quick Start

# 1. Write specification first
Spec:
  Component: "UserAuthService"
  Requirements: ["register", "login", "logout", "password-reset"]
  Interface: { input: "email, password", output: "Result<User, AuthError>" }

# 2. Generate with iterative refinement
Workflow:
  - Generate: "Implement UserAuthService from spec"
  - Test: "Run tests, check coverage"
  - Refine: "Fix issues, add edge cases"
  - Verify: "All tests pass, 80%+ coverage"

# 3. Apply leverage multiplication
Leverage:
  Manual: "4 hours/feature"
  AI-Assisted: "15 minutes/feature"
  Multiplier: "16x"

Features

Feature Description Guide
7 Omega Principles Core development philosophy Apply to every coding decision
Specification-Driven Requirements before code YAML/TypeScript specs
Prompt Engineering Effective AI prompts for code Templates for generation
Iterative Refinement Generate, test, improve loop Max 5 iterations to pass
Leverage Tactics 10x productivity techniques Batch, template, transform
Quality Patterns Self-documenting, testable code Types, pure functions, DI
Transform, Not Recreate Modify existing code with AI Refactor at scale

Common Patterns

The 7 Omega Principles in Code

1. LEVERAGE          - 1 developer + AI = 10-50 features/day
2. ABSTRACTION       - Solve classes of problems, not instances
3. AGENTIC           - Autonomous, specialist agent teams
4. AUTONOMOUS        - Self-correcting, self-healing code
5. ZERO-MARGINAL     - Build once, use infinitely
6. RECURSIVE         - Code that improves itself
7. EMERGENT          - Compose simple parts into powerful wholes

Specification Template

component:
  name: UserAuthService
  description: Authentication and session management

requirements:
  functional:
    - FR1: Register with email/password
    - FR2: Login with credentials
    - FR3: Logout and invalidate session
  non_functional:
    - NFR1: Response < 200ms
    - NFR2: PCI-DSS compliant

interface:
  methods:
    - name: register
      input: { email: "string", password: "string (min 8 chars)" }
      output: { success: boolean, userId?: string, error?: Error }
    - name: login
      input: { email: "string", password: "string" }
      output: { success: boolean, token?: "JWT 24h", error?: Error }

testing:
  unit: [password validation, token generation]
  integration: [registration flow, login flow]
  edge_cases: [duplicate email, invalid credentials]

Iterative Refinement Loop

async function omegaDevelopment(spec: Specification): Promise<Code> {
  let code = await generateFromSpec(spec);
  let iteration = 0;

  while (iteration < 5) {
    const results = await runTests(code);

    if (results.allPassing && results.coverage >= 80) {
      return code; // Done!
    }

    const issues = analyzeResults(results);
    code = await refineCode(code, issues);
    iteration++;
  }

  throw new Error('Max iterations reached');
}

// Iteration log example:
// 1: 8/12 tests pass -> Fix null checks, date handling
// 2: 11/12 tests pass -> Add empty input validation
// 3: 12/12 tests, 85% coverage -> Complete!

Prompt Templates

## Component Generation
Create a [TYPE] component named [NAME] with:

Requirements:
- [Req 1]
- [Req 2]

Interface:
[Define inputs, outputs, methods]

Constraints:
- Language: TypeScript
- Error handling: Return Result types
- Include unit tests

## Refactoring Request
Refactor this code to:
1. [Improvement 1]
2. [Improvement 2]

Current code: [paste]

Preserve: functionality, API, types

## Bug Fix Request
Fix the bug in this code:

Code: [paste]
Bug: [description]
Expected: [behavior]
Actual: [behavior]

Provide: root cause, fixed code, regression test

Leverage Multiplication Tactics

// Tactic 1: Generate, Don't Write
// Schema -> API -> Controllers -> Services -> Tests
// All generated, all consistent, all in minutes

// Tactic 2: Transform, Don't Recreate
// "Convert JavaScript to TypeScript with types"
// "Add error handling to all async functions"

// Tactic 3: Batch Operations
// "Add JSDoc to all exports in src/utils/"
// "Update all class components to functional"

// Tactic 4: Template Once, Generate Many
const template = {
  components: ['route', 'validation', 'service', 'repository', 'tests']
};
const resources = ['users', 'products', 'orders'];
// Result: 3 resources x 5 components = 15 files generated

// Tactic 5: Test-First Specification
describe('ShoppingCart', () => {
  it('calculates total', () => {
    const cart = new ShoppingCart();
    cart.addItem({ price: 10, quantity: 2 });
    expect(cart.total).toBe(20);
  });
});
// Then: "Implement ShoppingCart to pass these tests"

Quality Code Patterns

// 1. Self-documenting with branded types
interface User {
  id: UserId;           // Branded type
  email: Email;         // Validated type
  status: UserStatus;   // Union type
}

// 2. Pure functions where possible
const calculateTotal = (items: LineItem[]): Money =>
  items.reduce((sum, item) => sum.add(item.price.multiply(item.quantity)), Money.zero());

// 3. Explicit error handling with Result types
type Result<T, E = Error> = { success: true; value: T } | { success: false; error: E };

async function findUser(id: UserId): Promise<Result<User, NotFoundError>> {
  const user = await db.users.find(id);
  if (!user) return { success: false, error: new NotFoundError('User', id) };
  return { success: true, value: user };
}

// 4. Composable pipelines
const processDocument = pipe(parseMarkdown, extractEntities, enrichWithContext, generateSummary);

// 5. Dependency injection for testability
class OrderService {
  constructor(
    private readonly repo: OrderRepository,
    private readonly payment: PaymentGateway
  ) {}
}

Abstraction Levels

// Level 1: Solve one problem (avoid)
function validateEmail(email: string): boolean {
  return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
}

// Level 2: Solve the class of problems (prefer)
function createValidator<T>(rules: ValidationRule<T>[]): Validator<T> {
  return (value: T) => {
    const errors = rules.filter(r => !r.validate(value)).map(r => r.message);
    return { valid: errors.length === 0, errors };
  };
}

// Now email validation is just one instance:
const validateEmail = createValidator([
  { validate: v => v.includes('@'), message: 'Must contain @' },
  { validate: v => v.length <= 254, message: 'Too long' }
]);

Best Practices

Do Avoid
Write specifications before generating Generating without clear requirements
Use iterative refinement (generate, test, improve) Trusting generated code without verification
Leverage AI for repetitive tasks Skipping tests for AI-generated code
Verify generated code meets requirements Using AI for security-critical code without review
Maintain human oversight for critical logic Losing the spec-code relationship
Build reusable templates and patterns Over-relying on AI for creative design
Document prompts that work well Using outdated AI models for complex tasks
Combine AI strengths with human judgment Forgetting to understand generated code
Start simple, add complexity Ignoring AI suggestions for improvement
Keep specifications updated Skipping code review for AI-generated code
Weekly Installs
1
GitHub Stars
3
First Seen
6 days ago
Installed on
zencoder1
amp1
cline1
openclaw1
opencode1
cursor1