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_search with namespace sparc-state and query for the feature 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, updating current phase to 3 (Architecture) with both artifacts recorded
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 /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 /sparc advance to pass the gate check.
---
**Source:** [`ruvnet/ruflo`](https://github.com/ruvnet/ruflo) → `plugins/ruflo-sparc/skills/sparc-implement/SKILL.md`
1---2name: sparc-implement3description: Run the SPARC Pseudocode and Architecture phases (2 and 3) — write algorithm pseudocode, design module boundaries and API contracts, then implement4---5
6
7# SPARC Architecture + Implementation
8
9Run Phases 2 and 3 of the SPARC methodology: design algorithms with pseudocode, then establish architecture with module boundaries and API contracts.
10
11## When to use
12
13After 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.
14
15## Steps
16
171. **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.
18
192. **Retrieve phase state** — call `mcp__plugin_ruflo-core_ruflo__memory_search` with namespace `sparc-state` and query for the feature to confirm we are in Phase 2 or 3.
20
213. **Search for architectural patterns** — call `mcp__plugin_ruflo-core_ruflo__neural_predict` with the feature description to find relevant architectural decisions from past projects
22
234. **Phase 2 — Pseudocode Design**:
24 a. For each acceptance criterion, write language-agnostic pseudocode that satisfies it
25 b. Define core data structures with type annotations
26 c. Map control flow including:
27 - Happy path
28 - Error/exception paths for each edge case
29 - Concurrent access handling if applicable
30 d. Annotate algorithmic complexity (time and space) for critical paths
31 e. Store pseudocode artifact:
32 - Call `mcp__plugin_ruflo-core_ruflo__memory_store` with namespace `sparc-phases`, key `pseudo-{feature-slug}`
33 - Value: `{ status: "complete", algorithms: [...], dataStructures: [...], controlFlow: [...], complexity: {...} }`
34
355. **Phase 3 — Architecture Design**:
36 a. Define bounded contexts and aggregate roots following DDD patterns:
37 - Identify entity boundaries and value objects
38 - Define aggregate invariants
39 - Map domain events
40 b. Design API contracts:
41 - Request/response schemas with TypeScript interfaces
42 - Error response codes and formats
43 - Versioning strategy if applicable
44 c. Plan module boundaries:
45 - Directory structure
46 - Dependency direction rules (no circular dependencies)
47 - Public vs internal interfaces
48 d. Specify infrastructure concerns:
49 - Persistence strategy (database, cache, file)
50 - Messaging patterns (sync, async, event-driven)
51 - Configuration and environment requirements
52 e. Store architecture artifact:
53 - Call `mcp__plugin_ruflo-core_ruflo__memory_store` with namespace `sparc-phases`, key `arch-{feature-slug}`
54 - Value: `{ status: "complete", boundedContexts: [...], apiContracts: [...], moduleBoundaries: {...}, infrastructure: {...} }`
55
566. **Update phase state** — call `mcp__plugin_ruflo-core_ruflo__memory_store` with namespace `sparc-state`, updating current phase to 3 (Architecture) with both artifacts recorded
57
587. **Record trajectory step** — call `mcp__plugin_ruflo-core_ruflo__hooks_intelligence_trajectory-step` with architecture summary
59
608. **Begin implementation** — if the user confirms, proceed to write production code:
61 a. Create files following the defined module boundaries
62 b. Implement interfaces and types first
63 c. Implement core logic following the pseudocode
64 d. Write unit tests alongside implementation (TDD when possible)
65 e. Run tests to verify acceptance criteria
66
679. **Present architecture** — display the architecture decision record and suggest running `/sparc advance` to pass the Phase 3 gate
68
69## Output format
70
71```
72# Pseudocode: {Feature Name}
73
74## Core Algorithms
75### Algorithm 1: {name}
76```pseudocode
77FUNCTION processRequest(input):
78 VALIDATE input against schema
79 IF invalid THEN THROW ValidationError
80 result <- TRANSFORM input
81 STORE result
82 RETURN result
83```
84Complexity: O(n) time, O(1) space
85
86## Data Structures
87- {StructName}: { field1: type, field2: type }
88
89---
90
91# Architecture: {Feature Name}
92
93## Bounded Contexts
94- {ContextName}: {description}
95 - Aggregates: {list}
96 - Events: {list}
97
98## API Contracts
99### POST /api/{resource}
100- Request: { field1: string, field2: number }
101- Response: { id: string, ...fields }
102- Errors: 400 (validation), 409 (conflict), 500 (internal)
103
104## Module Structure
105```
106src/{feature}/
107 {feature}.types.ts # Interfaces and types
108 {feature}.service.ts # Business logic
109 {feature}.controller.ts # HTTP handling
110 {feature}.repository.ts # Data access
111 {feature}.test.ts # Tests
112```
113
114## Infrastructure
115- Persistence: {strategy}
116- Caching: {strategy}
117- Events: {strategy}
118
119---
120Phases 2-3 complete. Run `/sparc advance` to pass the gate check.
121```
122
123---
124
125**Source:** [`ruvnet/ruflo`](https://github.com/ruvnet/ruflo) → `plugins/ruflo-sparc/skills/sparc-implement/SKILL.md`