agentleFS
CarbeneAICarbeneAI/Forge/.claude/skills/Algorithm/SKILL.md

Algorithm

Skill9 starsChanged 7 months agoMITView on GitHub

Structured 7-phase execution engine for systematic problem-solving with effort classification and rigorous methodology. USE WHEN user mentions algorithm, systematic approach, structured execution, step-by-step methodology, rigorous framework, OR wants disciplined problem-solving process.

The file

Show its rules and text

We split this skill into the rules it gives an agent

19 rules. About 0 are common, 19 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈19

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Actions: Read, investigate, measure, document current state

    line 24
  2. Distinctive:

    Purpose: Create the solution components.

    line 45
  3. Distinctive:

    Actions: Write code, create documents, build infrastructure

    line 48
  4. Distinctive:

    Exit criteria: All planned components exist and are integrated

    line 50
  5. Distinctive:

    Purpose: Run the solution in target environment.

    line 53
  6. Distinctive:

    Actions: Test, measure, compare to success criteria

    line 64
  7. Distinctive:

    Exit criteria: All success metrics met, no critical failures

    line 66
  8. Distinctive:

    Actions: Document learnings, identify improvements, update knowledge

    line 72
  9. Distinctive:

    Before executing the Algorithm, classify the effort level to determine appropriate depth for each phase:

    line 78
  10. Distinctive:

    When previous ad-hoc attempts failed

    line 109
  11. Distinctive:

    FirstPrinciples skill: Use in THINK phase to challenge assumptions

    line 121
  12. Distinctive:

    Research skill: Use in OBSERVE phase to gather information

    line 122
  13. Distinctive:

    test-driven-development skill: Use in BUILD and VERIFY phases

    line 123
  14. Distinctive:

    systematic-debugging skill: Use when VERIFY reveals failures

    line 124
  15. Distinctive:

    cto-advisor / ceo-advisor: Use for strategic decision-making

    line 125
  16. Distinctive:

    When using Algorithm skill, structure output by phase:

    line 319
  17. Distinctive:

    Sequential phases: Don't skip ahead. Each phase builds on the previous.

    line 355
  18. Distinctive:

    Exit criteria: Don't move to next phase until current phase is complete.

    line 356
  19. Distinctive:

    Documentation: Write as you go, don't document after the fact.

    line 358

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Algorithm

A structured 7-phase execution framework for systematic problem-solving. The Algorithm skill provides a rigorous, repeatable methodology for approaching any task - from trivial to complex - with appropriate depth based on effort classification.

Core Philosophy

Every problem deserves the right amount of rigor.

The Algorithm framework scales from TRIVIAL tasks (minutes of effort) to DETERMINED challenges (multi-day investigations) by adjusting the depth of each phase while maintaining consistent structure.

The 7 Phases

The Algorithm consists of seven sequential phases, each with clear inputs, actions, outputs, and exit criteria:

1. OBSERVE

Purpose: Gather facts and understand the current state.

  • Input: Problem statement or task description
  • Actions: Read, investigate, measure, document current state
  • Output: Factual understanding of what exists now
  • Exit criteria: Can describe problem objectively without interpretation

2. THINK

Purpose: Analyze, reason, and form hypotheses.

  • Input: Observations from OBSERVE phase
  • Actions: Analyze patterns, identify root causes, generate theories
  • Output: Understanding of why things are the way they are
  • Exit criteria: Have working theory of causation and relationships

3. PLAN

Purpose: Design solution approach and implementation strategy.

  • Input: Understanding from THINK phase
  • Actions: Design solution, sequence steps, identify resources
  • Output: Detailed implementation plan with success criteria
  • Exit criteria: Clear roadmap from current state to desired state

4. BUILD

Purpose: Create the solution components.

  • Input: Plan from PLAN phase
  • Actions: Write code, create documents, build infrastructure
  • Output: Working implementation of solution
  • Exit criteria: All planned components exist and are integrated

5. EXECUTE

Purpose: Run the solution in target environment.

  • Input: Built solution from BUILD phase
  • Actions: Deploy, configure, launch, operate
  • Output: Solution running in production/real environment
  • Exit criteria: System operational and handling real work

6. VERIFY

Purpose: Confirm solution meets requirements and objectives.

  • Input: Executing solution from EXECUTE phase
  • Actions: Test, measure, compare to success criteria
  • Output: Evidence that solution works as intended
  • Exit criteria: All success metrics met, no critical failures

7. LEARN

Purpose: Extract insights and improve future performance.

  • Input: Results from VERIFY phase
  • Actions: Document learnings, identify improvements, update knowledge
  • Output: Captured knowledge for future reference
  • Exit criteria: Key insights documented, ready for next iteration

Effort Classification System

Before executing the Algorithm, classify the effort level to determine appropriate depth for each phase:

LevelDurationCharacteristicsExample
TRIVIALMinutesObvious path, no unknowns, routine"Create new directory"
SIMPLE~1 hourClear path, minimal unknowns, straightforward"Fix known bug with clear cause"
MODERATEFew hoursSome unknowns, requires investigation"Add new feature to existing system"
COMPLEX1+ daysMultiple unknowns, requires research/design"Redesign authentication system"
DETERMINEDMulti-daySignificant unknowns, requires deep investigation"Root cause performance degradation"

Classification drives depth:

  • TRIVIAL: Minimal documentation, fast execution
  • SIMPLE: Basic documentation, standard thoroughness
  • MODERATE: Detailed documentation, careful execution
  • COMPLEX: Comprehensive documentation, rigorous validation
  • DETERMINED: Exhaustive documentation, extreme rigor

Workflow Routing

WorkflowTriggerFile
Execute"use algorithm", "systematic approach", "structured execution"workflows/Execute.md

When to Use Algorithm

High-value scenarios:

  • Complex problems requiring systematic approach
  • Unfamiliar domains where structure helps
  • Critical tasks where rigor prevents mistakes
  • Team collaboration requiring shared methodology
  • Learning scenarios where process matters
  • When previous ad-hoc attempts failed

Lower-value scenarios:

  • Well-practiced routine tasks (muscle memory suffices)
  • Genuinely trivial operations (overhead exceeds benefit)
  • Brainstorming or creative exploration (structure inhibits)
  • Time-critical emergencies (act first, analyze later)

Integration with Other Skills

Algorithm works well with:

  • FirstPrinciples skill: Use in THINK phase to challenge assumptions
  • Research skill: Use in OBSERVE phase to gather information
  • test-driven-development skill: Use in BUILD and VERIFY phases
  • systematic-debugging skill: Use when VERIFY reveals failures
  • cto-advisor / ceo-advisor: Use for strategic decision-making

Common patterns:

Algorithm (OBSERVE + THINK) → FirstPrinciples → Algorithm (PLAN + BUILD)
Algorithm (OBSERVE) → Research skill → Algorithm (THINK + PLAN)
Algorithm (BUILD) → test-driven-development → Algorithm (VERIFY)

Examples

Example 1: TRIVIAL task (classified appropriately)

User: "Create a new skills directory for Algorithm skill"

→ Activates Algorithm skill
→ Effort classification: TRIVIAL (minutes, obvious path)
→ Execute workflow (minimal depth):

OBSERVE: Need directory at ~/.claude/skills/Algorithm/
THINK: Standard skill structure: SKILL.md + workflows/ + reference/
PLAN: mkdir -p and create files
BUILD: Execute mkdir commands
EXECUTE: Verify directories created
VERIFY: ls confirms structure exists
LEARN: Standard skill creation pattern works

Result: Task complete in 2 minutes with appropriate rigor

Example 2: MODERATE task (appropriate depth)

User: "Our API response times increased from 200ms to 2000ms over the last week"

→ Activates Algorithm skill
→ Effort classification: MODERATE (hours, some unknowns require investigation)
→ Execute workflow (detailed depth):

OBSERVE:
- Baseline: 200ms response time (last week)
- Current: 2000ms response time (today)
- Change: 10x degradation over 7 days
- Affected: All endpoints, not isolated to one
- Infrastructure: No changes to servers/config

THINK:
- Hypothesis 1: Database queries slowed (most common cause)
- Hypothesis 2: Increased load (check traffic metrics)
- Hypothesis 3: External dependency degraded (check third-party APIs)
- Root cause: Likely database (affects all endpoints uniformly)

PLAN:
1. Check database query performance logs
2. Review slow query log for new patterns
3. Check for missing indexes (common after data growth)
4. Test query performance in staging
5. If confirmed, add missing index

BUILD:
- Query to find slow queries: SELECT * FROM pg_stat_statements ORDER BY total_time DESC
- Identified: User lookup query doing full table scan (no index)
- Solution: CREATE INDEX idx_users_email ON users(email)

EXECUTE:
- Run CREATE INDEX in staging (test first)
- Monitor performance impact
- Deploy to production during low-traffic window

VERIFY:
- Response times: 2000ms → 180ms (back to baseline)
- Query time: 1800ms → 5ms (index working)
- No errors introduced
- All endpoints fast again

LEARN:
- User table grew past index-less threshold (~100K rows)
- Add monitoring alert for queries >500ms
- Document: Always index foreign keys and email lookups
- Future: Automated index suggestions in staging

Result: Performance restored in 3 hours with root cause documented

Example 3: COMPLEX task (comprehensive depth)

User: "Design and implement authentication system for new SaaS product"

→ Activates Algorithm skill
→ Effort classification: COMPLEX (1-2 days, multiple unknowns, security-critical)
→ Execute workflow (comprehensive depth):

OBSERVE:
- Requirements: Multi-tenant SaaS, B2B customers
- Users: 10-10,000 users per tenant
- Security: SOC2 compliance required
- Use cases: SSO for enterprise, email/password for SMB
- Constraints: Budget $50K, 3-month timeline
- Current state: New product, no existing auth

THINK:
- Build vs. buy analysis:
  - Build: Full control, $50K dev cost, ongoing maintenance
  - Buy: Faster, $20K/year, vendor dependency
- Security requirements:
  - Password hashing (bcrypt/argon2)
  - MFA support (TOTP, SMS backup)
  - SSO (SAML, OAuth)
  - Session management (JWT + refresh tokens)
- Compliance: Need audit logs, encryption at rest/transit
- Decision: Use Auth0 for SSO, custom for email/password (hybrid)
  - Rationale: SSO complexity high, email/password well-understood

PLAN:
1. Week 1: Design auth flow, select tools
2. Week 2: Implement email/password with Auth0 integration
3. Week 3: Add MFA, session management
4. Week 4: SSO integration, testing
5. Week 5: Security audit, penetration testing
6. Week 6: Documentation, monitoring, launch

Detailed tasks:
- Database schema: users, sessions, mfa_devices, audit_log
- API endpoints: /login, /logout, /register, /mfa/setup, /mfa/verify
- Frontend: Login page, registration, MFA setup
- Integration: Auth0 for SSO tenants
- Security: Rate limiting, password policies, session expiry
- Monitoring: Failed login alerts, unusual patterns

BUILD:
[Detailed implementation phase - code, tests, infrastructure]
- Database migrations with encrypted password storage
- JWT token service with refresh token rotation
- MFA implementation using TOTP (Google Authenticator compatible)
- Auth0 integration for SSO tenants
- Rate limiting middleware (max 5 failed attempts → 15min lockout)
- Comprehensive test suite (unit, integration, security)

EXECUTE:
- Deploy to staging with test tenants
- Run penetration testing (internal + external firm)
- Beta test with 3 pilot customers
- Monitor for issues (error rates, performance)
- Fix bugs identified in testing

VERIFY:
✅ Functional tests: All auth flows work correctly
✅ Security tests: No vulnerabilities in pentest report
✅ Performance tests: Login <200ms, SSO <500ms
✅ Compliance: Audit log captures all auth events
✅ User testing: 3 beta customers successfully using system
✅ Documentation: Admin guide, user guide, API docs complete

LEARN:
Key insights:
1. Hybrid approach (custom + Auth0) was right call
   - Saved 3 weeks vs. full custom implementation
   - Avoided SSO complexity (SAML is hard)
   - Maintained control over core user experience

2. Security testing revealed issues early
   - Missing rate limiting on password reset
   - Session tokens not invalidated on password change
   - Both caught and fixed before launch

3. MFA adoption requires education
   - 60% of beta users didn't set up MFA initially
   - After adding in-app prompts: 90% adoption
   - Lesson: Security features need UX focus

4. Monitoring is critical
   - Failed login spike = credential stuffing attack
   - Caught and blocked within 15 minutes
   - Alert system proved valuable immediately

Improvements for next time:
- Start with security testing framework from day 1
- Involve security team in design phase (not just review)
- Plan for phased MFA rollout (don't force immediately)

Documentation:
- Architecture decision record (ADR) for auth choices
- Runbook for common auth issues
- Security incident response playbook
- User onboarding guide with security best practices

Result: Production-ready auth system in 6 weeks, SOC2 compliant, zero security incidents in first 3 months

Output Format

When using Algorithm skill, structure output by phase:

# Algorithm Execution: [Task Name]

**Effort Classification:** [TRIVIAL / SIMPLE / MODERATE / COMPLEX / DETERMINED]

## 1. OBSERVE
[What is the current state? What facts do we have?]

## 2. THINK
[What does this mean? What are the patterns? What's the root cause?]

## 3. PLAN
[What's the solution approach? What are the steps?]

## 4. BUILD
[Create the solution components]

## 5. EXECUTE
[Run the solution in target environment]

## 6. VERIFY
[Does it work? Does it meet requirements?]

## 7. LEARN
[What did we learn? What would we do differently?]

---

**Status:** [Complete / In Progress / Blocked]
**Next:** [What comes next, if anything]

Key Principles

  1. Sequential phases: Don't skip ahead. Each phase builds on the previous.
  2. Exit criteria: Don't move to next phase until current phase is complete.
  3. Appropriate depth: Match rigor to effort classification.
  4. Documentation: Write as you go, don't document after the fact.
  5. Learning: LEARN phase is not optional - extract insights for future.

Anti-Patterns to Avoid

❌ Jumping to BUILD without THINK: Implementing before understanding ❌ Skipping VERIFY: Assuming it works without testing ❌ Forgetting LEARN: Missing the opportunity to improve ❌ Over-engineering TRIVIAL tasks: Using COMPLEX rigor for simple work ❌ Under-engineering COMPLEX tasks: Using TRIVIAL rigor for critical work

Success Criteria

Algorithm execution is successful when:

  • ✅ All 7 phases completed with appropriate depth
  • ✅ Exit criteria met for each phase before proceeding
  • ✅ Solution verified to meet requirements
  • ✅ Learnings documented for future reference
  • ✅ Next steps clear (or task complete)

Meta Note

The Algorithm skill is itself an algorithm. This recursive nature makes it particularly powerful for complex problem-solving: you can use the Algorithm to improve the Algorithm.

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.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

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.