SPARC Architecture + Implementation
Run Phases 2 and 3 of the SPARC methodology: design algorithms with pseudocode, then establish architecture with module boundaries and API contracts.
When to use
After the Specification phase is complete and its gate has been passed. This skill covers both the Pseudocode and Architecture phases as they are tightly coupled — algorithm design informs module boundaries and vice versa.
Steps
Retrieve specification — call mcp__plugin_ruflo-core_ruflo__memory_search with namespace sparc-phases and query for the feature's spec. Extract requirements, acceptance criteria, constraints, and edge cases.
Retrieve phase state — call mcp__plugin_ruflo-core_ruflo__memory_retrieve with namespace sparc-state and exact key current-phase-{feature-slug} to confirm we are in Phase 2 or 3.
Search for architectural patterns — call mcp__plugin_ruflo-core_ruflo__neural_predict with the feature description to find relevant architectural decisions from past projects
Phase 2 — Pseudocode Design:
a. For each acceptance criterion, write language-agnostic pseudocode that satisfies it
b. Define core data structures with type annotations
c. Map control flow including:
- Happy path
- Error/exception paths for each edge case
- Concurrent access handling if applicable
d. Annotate algorithmic complexity (time and space) for critical paths
e. Store pseudocode artifact:
- Call
mcp__plugin_ruflo-core_ruflo__memory_store with namespace sparc-phases, key pseudo-{feature-slug}
- Value:
{ status: "complete", algorithms: [...], dataStructures: [...], controlFlow: [...], complexity: {...} }
Phase 3 — Architecture Design:
a. Define bounded contexts and aggregate roots following DDD patterns:
- Identify entity boundaries and value objects
- Define aggregate invariants
- Map domain events
b. Design API contracts:
- Request/response schemas with TypeScript interfaces
- Error response codes and formats
- Versioning strategy if applicable
c. Plan module boundaries:
- Directory structure
- Dependency direction rules (no circular dependencies)
- Public vs internal interfaces
d. Specify infrastructure concerns:
- Persistence strategy (database, cache, file)
- Messaging patterns (sync, async, event-driven)
- Configuration and environment requirements
e. Store architecture artifact:
- Call
mcp__plugin_ruflo-core_ruflo__memory_store with namespace sparc-phases, key arch-{feature-slug}
- Value:
{ status: "complete", boundedContexts: [...], apiContracts: [...], moduleBoundaries: {...}, infrastructure: {...} }
Update phase state — call mcp__plugin_ruflo-core_ruflo__memory_store with namespace sparc-state, exact key current-phase-{feature-slug}; preserve existing state fields, update current phase to 3 (Architecture) with both artifacts recorded, and set updatedAt to the current ISO timestamp
Record trajectory step — call mcp__plugin_ruflo-core_ruflo__hooks_intelligence_trajectory-step with architecture summary
Begin implementation — if the user confirms, proceed to write production code:
a. Create files following the defined module boundaries
b. Implement interfaces and types first
c. Implement core logic following the pseudocode
d. Write unit tests alongside implementation (TDD when possible)
e. Run tests to verify acceptance criteria
Present architecture — display the architecture decision record and suggest running /ruflo-sparc:ruflo-sparc advance to pass the Phase 3 gate
Output format
# Pseudocode: {Feature Name}
## Core Algorithms
### Algorithm 1: {name}
```pseudocode
FUNCTION processRequest(input):
VALIDATE input against schema
IF invalid THEN THROW ValidationError
result <- TRANSFORM input
STORE result
RETURN result
Complexity: O(n) time, O(1) space
Data Structures
- {StructName}: { field1: type, field2: type }
Architecture: {Feature Name}
Bounded Contexts
- {ContextName}: {description}
- Aggregates: {list}
- Events: {list}
API Contracts
POST /api/{resource}
- Request: { field1: string, field2: number }
- Response: { id: string, ...fields }
- Errors: 400 (validation), 409 (conflict), 500 (internal)
Module Structure
src/{feature}/
{feature}.types.ts # Interfaces and types
{feature}.service.ts # Business logic
{feature}.controller.ts # HTTP handling
{feature}.repository.ts # Data access
{feature}.test.ts # Tests
Infrastructure
- Persistence: {strategy}
- Caching: {strategy}
- Events: {strategy}
Phases 2-3 complete. Run /ruflo-sparc:ruflo-sparc advance to pass the gate check.
1---2name: sparc-implement-23description: Run the SPARC Pseudocode and Architecture phases (2 and 3) — write algorithm pseudocode, design module boundaries and API contracts, then implement4argument-hint: ""5allowed-tools: mcp__plugin_ruflo-core_ruflo__memory_store mcp__plugin_ruflo-core_ruflo__memory_search mcp__plugin_ruflo-core_ruflo__memory_retrieve mcp__plugin_ruflo-core_ruflo__task_create mcp__plugin_ruflo-core_ruflo__task_update mcp__plugin_ruflo-core_ruflo__task_complete mcp__plugin_ruflo-core_ruflo__hooks_intelligence_trajectory-step mcp__plugin_ruflo-core_ruflo__neural_predict mcp__plugin_ruflo-core_ruflo__workflow_create Bash Read Write Edit6metadata:7 source: https://skillmd.com/skills/ruvnet/sparc-implement-28---910# SPARC Architecture + Implementation1112Run Phases 2 and 3 of the SPARC methodology: design algorithms with pseudocode, then establish architecture with module boundaries and API contracts.1314## When to use1516After the Specification phase is complete and its gate has been passed. This skill covers both the Pseudocode and Architecture phases as they are tightly coupled — algorithm design informs module boundaries and vice versa.1718## Steps19201. **Retrieve specification** — call `mcp__plugin_ruflo-core_ruflo__memory_search` with namespace `sparc-phases` and query for the feature's spec. Extract requirements, acceptance criteria, constraints, and edge cases.21222. **Retrieve phase state** — call `mcp__plugin_ruflo-core_ruflo__memory_retrieve` with namespace `sparc-state` and exact key `current-phase-{feature-slug}` to confirm we are in Phase 2 or 3.23243. **Search for architectural patterns** — call `mcp__plugin_ruflo-core_ruflo__neural_predict` with the feature description to find relevant architectural decisions from past projects25264. **Phase 2 — Pseudocode Design**:27 a. For each acceptance criterion, write language-agnostic pseudocode that satisfies it28 b. Define core data structures with type annotations29 c. Map control flow including:30 - Happy path31 - Error/exception paths for each edge case32 - Concurrent access handling if applicable33 d. Annotate algorithmic complexity (time and space) for critical paths34 e. Store pseudocode artifact:35 - Call `mcp__plugin_ruflo-core_ruflo__memory_store` with namespace `sparc-phases`, key `pseudo-{feature-slug}`36 - Value: `{ status: "complete", algorithms: [...], dataStructures: [...], controlFlow: [...], complexity: {...} }`37385. **Phase 3 — Architecture Design**:39 a. Define bounded contexts and aggregate roots following DDD patterns:40 - Identify entity boundaries and value objects41 - Define aggregate invariants42 - Map domain events43 b. Design API contracts:44 - Request/response schemas with TypeScript interfaces45 - Error response codes and formats46 - Versioning strategy if applicable47 c. Plan module boundaries:48 - Directory structure49 - Dependency direction rules (no circular dependencies)50 - Public vs internal interfaces51 d. Specify infrastructure concerns:52 - Persistence strategy (database, cache, file)53 - Messaging patterns (sync, async, event-driven)54 - Configuration and environment requirements55 e. Store architecture artifact:56 - Call `mcp__plugin_ruflo-core_ruflo__memory_store` with namespace `sparc-phases`, key `arch-{feature-slug}`57 - Value: `{ status: "complete", boundedContexts: [...], apiContracts: [...], moduleBoundaries: {...}, infrastructure: {...} }`58596. **Update phase state** — call `mcp__plugin_ruflo-core_ruflo__memory_store` with namespace `sparc-state`, exact key `current-phase-{feature-slug}`; preserve existing state fields, update current phase to 3 (Architecture) with both artifacts recorded, and set `updatedAt` to the current ISO timestamp60617. **Record trajectory step** — call `mcp__plugin_ruflo-core_ruflo__hooks_intelligence_trajectory-step` with architecture summary62638. **Begin implementation** — if the user confirms, proceed to write production code:64 a. Create files following the defined module boundaries65 b. Implement interfaces and types first66 c. Implement core logic following the pseudocode67 d. Write unit tests alongside implementation (TDD when possible)68 e. Run tests to verify acceptance criteria69709. **Present architecture** — display the architecture decision record and suggest running `/ruflo-sparc:ruflo-sparc advance` to pass the Phase 3 gate7172## Output format7374```75# Pseudocode: {Feature Name}7677## Core Algorithms78### Algorithm 1: {name}79```pseudocode80FUNCTION processRequest(input):81 VALIDATE input against schema82 IF invalid THEN THROW ValidationError83 result <- TRANSFORM input84 STORE result85 RETURN result86```87Complexity: O(n) time, O(1) space8889## Data Structures90- {StructName}: { field1: type, field2: type }9192---9394# Architecture: {Feature Name}9596## Bounded Contexts97- {ContextName}: {description}98 - Aggregates: {list}99 - Events: {list}100101## API Contracts102### POST /api/{resource}103- Request: { field1: string, field2: number }104- Response: { id: string, ...fields }105- Errors: 400 (validation), 409 (conflict), 500 (internal)106107## Module Structure108```109src/{feature}/110 {feature}.types.ts # Interfaces and types111 {feature}.service.ts # Business logic112 {feature}.controller.ts # HTTP handling113 {feature}.repository.ts # Data access114 {feature}.test.ts # Tests115```116117## Infrastructure118- Persistence: {strategy}119- Caching: {strategy}120- Events: {strategy}121122---123Phases 2-3 complete. Run `/ruflo-sparc:ruflo-sparc advance` to pass the gate check.124```