Overview
/garden-extract is a production command in the Infrastructure category of the Prismatic Platform that extracts reusable patterns, components, and knowledge from GARDEN (Growing Archive of Reusable Development and Engineering Nuggets) repositories and integrates them into the active platform codebase. While /garden-explore discovers what exists in the GARDEN ecosystem, /garden-extract performs the actual knowledge transfer -- transforming historical implementations into production-ready components that conform to current platform standards.
The command operates under the L2+ authority level and is executed by the garden-cultivator agent. It is part of the platform's 216-command slash command registry, built on the AIAD (Autonomous Intelligence Agent Design) standard. The garden-cultivator agent manages the complex process of adapting code from diverse technology stacks and coding conventions into the platform's standardized Elixir/OTP architecture, ensuring that extracted components meet all quality gates and doctrine requirements.
The GARDEN ecosystem contains 116 repositories with over 3,050 files spanning 20+ years of engineering practice. Much of this knowledge exists in older technology stacks (Python, JavaScript, Ruby) or in Elixir code that predates the platform's current quality standards. The /garden-extract command handles the translation layer, converting patterns into idiomatic Elixir that passes compilation with zero warnings, Credo strict mode, Dialyzer analysis, and the full battery of quality gates.
Extraction is not mere copying. The command performs pattern analysis to identify the essential algorithm or architectural concept, strips away implementation-specific details tied to the source technology, and generates a new implementation that leverages Elixir/OTP idioms such as GenServer state management, supervision trees, and the {:ok, result} | {:error, reason} return pattern. This ensures that extracted knowledge genuinely improves the platform rather than introducing technical debt from legacy codebases.
Architecture
The extraction pipeline operates as a multi-stage transformation process.
Source Repo --> Pattern Analyzer --> Transformer --> Generator --> Quality Gate --> Integration
| | | | | |
Raw Code Essential Technology Elixir/OTP Compilation Target App
(any lang) Pattern ID Translation Code Gen + Credo + Tests PlacementPipeline Stages
| Stage | Component | Responsibility |
|---|---|---|
| Analysis | Garden.PatternAnalyzer | Identifies the essential pattern, separating algorithm from implementation details |
| Translation | Garden.Transformer | Converts technology-specific constructs to Elixir/OTP equivalents |
| Generation | Garden.CodeGenerator | Produces idiomatic Elixir modules with typespecs, docs, and tests |
| Validation | Garden.QualityValidator | Runs quality gates on generated code before integration |
| Integration | Garden.Integrator | Places generated code in the target application with proper module naming |
Supported Source Technologies
| Technology | Pattern Types | Translation Complexity |
|---|---|---|
| Elixir | Direct port, GenServer patterns, Phoenix patterns | Low (same ecosystem) |
| Python | Data pipelines, ML patterns, OSINT providers | Medium (paradigm shift) |
| JavaScript | Async patterns, API clients, event handlers | Medium (async model differs) |
| Rust | Performance patterns, systems patterns | High (ownership model) |
| Go | Concurrency patterns, service patterns | Medium (goroutines to processes) |
| Ruby | OOP patterns, DSL patterns, Rails patterns | Medium (OOP to FP) |
Usage
Basic Usage
# Extract a specific pattern from a repository
/garden-extract sig --pattern osint-provider
# Extract and place in a specific target application
/garden-extract sig --pattern osint-provider --target apps/prismatic_agents/
# Extract all patterns from a repository
/garden-extract kuzu-ex --all
# Dry-run extraction to preview what would be generated
/garden-extract prismatic-legacy --pattern blackboard --dry-runSelective Extraction
# Extract only the core algorithm, skip tests and docs
/garden-extract sig --pattern provider-registry --components core
# Extract with full test suite generation
/garden-extract sig --pattern provider-registry --components core,tests,docs
# Extract and adapt to a specific module namespace
/garden-extract crisstal --pattern event-pipeline --namespace PrismaticAgents.EventsCross-Language Extraction
# Extract a Python OSINT provider and convert to Elixir
/garden-extract sig --pattern shodan-provider --source-lang python --target apps/prismatic_agents/
# Extract a Go service pattern and convert to GenServer
/garden-extract comtesse --pattern worker-pool --source-lang rust --target apps/prismatic/Options & Parameters
| Option | Type | Default | Description |
|---|---|---|---|
REPO | string | required | Source GARDEN repository name |
--pattern | string | none | Specific pattern name to extract |
--all | boolean | false | Extract all patterns from the repository |
--target | string | auto | Target application directory for placement |
--namespace | string | auto | Elixir module namespace for generated code |
--components | string | all | Components to extract: core, tests, docs, config |
--source-lang | string | auto | Source language hint for cross-language extraction |
--dry-run | boolean | false | Preview extraction without writing files |
--force | boolean | false | Overwrite existing files at the target location |
--format | string | elixir | Output format: elixir, markdown (for documentation extraction) |
--quality-level | string | strict | Quality gate level: strict, standard, relaxed |
--verbose | boolean | false | Show detailed extraction steps and transformations |
Execution Flow
-
Source Resolution: Locate the source repository in the GARDEN submodule directory (
garden/REPO_NAME/). Verify the submodule is initialized and contains the expected files. -
Pattern Identification: If
--patternis specified, locate the pattern definition in the repository's pattern index. If--allis specified, enumerate all extractable patterns. -
Source Analysis: The PatternAnalyzer examines the source code to identify the essential pattern -- the core algorithm, data structures, and architectural decisions that constitute reusable knowledge. Implementation-specific details (database drivers, HTTP clients, framework bindings) are separated from the essential pattern.
-
Translation Planning: Based on the source language and target Elixir environment, the Transformer creates a translation plan that maps source constructs to Elixir/OTP equivalents. For example, Python classes become Elixir modules, async/await becomes Task/GenServer, and mutable state becomes GenServer state.
-
Code Generation: The CodeGenerator produces Elixir modules following platform conventions: proper module documentation with
@moduledoc, function documentation with@doc, type specifications with@spec, and the{:ok, result} | {:error, reason}return pattern. -
Test Generation: Companion test modules are generated with property-based tests (using StreamData) and example-based tests that verify the extracted pattern behaves correctly.
-
Quality Validation: Generated code is validated against the platform's quality gates: zero compilation warnings, Credo strict compliance, Dialyzer success, and typespec coverage.
-
Integration: Validated code is placed in the target application directory with proper file naming and module structure. Existing files are never overwritten unless
--forceis specified.
Integration Points
| Component | Integration Type | Description |
|---|---|---|
| Prismatic Agents | Execution | Invoked by garden-cultivator agent |
| GARDEN Ecosystem | Source | Reads from 116 GARDEN repositories |
| /garden-explore | Workflow | Exploration typically precedes extraction |
| /garden-search | Discovery | Search results identify extraction targets |
| /garden-sync | Prerequisite | Sync ensures source repositories are current |
| Quality Gates | Validation | Extracted code must pass all quality gates |
| Credo | Static Analysis | Generated code checked for Credo compliance |
| Telemetry | Metrics | Extraction events and success rates tracked |
Best Practices
Always explore before extracting. Use /garden-explore to understand what a pattern contains and which repositories implement it before running extraction. Blind extraction may pull in inappropriate patterns or miss better alternatives.
Use dry-run for complex extractions. Cross-language extractions and large pattern sets benefit from --dry-run to preview the generated code before it is written to disk. This prevents quality issues from reaching the codebase.
Specify a target namespace. The auto-generated namespace may not match the platform's module organization conventions. Use --namespace to place extracted code in the correct module hierarchy.
Extract incrementally. For repositories with many patterns, extract one pattern at a time and verify its integration before proceeding to the next. This makes it easier to identify and resolve integration issues.
Review generated tests carefully. While the CodeGenerator produces functional tests, the generated tests may not cover all edge cases specific to the platform's usage context. Supplement generated tests with domain-specific assertions.
Error Handling
| Error | Cause | Resolution |
|---|---|---|
{:error, :repo_not_found} | Source repository does not exist in GARDEN | Verify repository name; run /garden-explore to list available repos |
{:error, :pattern_not_found} | Specified pattern does not exist in the repository | Check pattern name; use --verbose to see available patterns |
{:error, :translation_failed} | Cross-language translation encountered unsupported constructs | Use --source-lang to hint the correct language; some patterns require manual adaptation |
{:error, :quality_gate_failed} | Generated code did not pass quality validation | Use --quality-level relaxed for initial extraction, then fix violations manually |
{:error, :target_exists} | Target file already exists and --force is not specified | Use --force to overwrite or specify a different --namespace |
{:error, :submodule_missing} | GARDEN submodule is not initialized | Run git submodule update --init garden/REPO_NAME |
Advanced Usage
Batch Extraction with Quality Pipeline
# Extract all OSINT providers from sig repository
/garden-extract sig --pattern "osint-*" --target apps/prismatic_agents/lib/providers/
# Extract and immediately verify integration
/garden-extract sig --pattern shodan-provider --target apps/prismatic_agents/ && \
mix compile --warnings-as-errors && \
mix credo --strict && \
mix test apps/prismatic_agents/test/Pattern Composition
Combine multiple extracted patterns to build higher-level components:
# Extract the base provider pattern
/garden-extract sig --pattern base-provider --namespace PrismaticAgents.Providers.Base
# Extract specific provider implementations
/garden-extract sig --pattern shodan-provider --namespace PrismaticAgents.Providers.Shodan
/garden-extract sig --pattern censys-provider --namespace PrismaticAgents.Providers.Censys
# Extract the registry pattern that ties them together
/garden-extract sig --pattern provider-registry --namespace PrismaticAgents.Providers.RegistryDocumentation Extraction
Extract documentation and knowledge without code:
# Extract architectural documentation from a repository
/garden-extract prismatic-legacy --pattern blackboard --format markdown --target docs/architecture/
# Extract pattern descriptions for the promo site
/garden-extract sig --all --format markdown --components docs --target sites/promo/content/Doctrine Compliance
All commands operate under the NO MERCY, NO DOUBTS doctrine:
- NO MERCY: Zero tolerance for incomplete execution or quality violations. Extracted code must pass all quality gates before integration. No stubs, no TODOs, no incomplete implementations.
- NO DOUBTS: Full investigation before action, evidence-based results. The analysis phase ensures that the essential pattern is fully understood before translation begins. Extraction never proceeds on partial understanding.
The command enforces the platform's meta-rule: if the extracted code could be written identically in Node.js, the extraction has failed. All extracted patterns must leverage Elixir/OTP idioms -- processes, supervision, pattern matching, and functional composition.
Related Commands
- /gardener - GARDEN legacy knowledge repository management across 116 repos
- /garden-explore - Explore GARDEN repositories for patterns and knowledge
- /garden-search - Fast pattern search across all GARDEN reference repositories
- /garden-sync - Synchronize GARDEN submodules to latest remote commits
- /propagate-pattern - Propagate successful patterns across the ecosystem
- /quality-gates - Enforce quality gate checkpoints with zero-warning compilation validation
Connect & Contribute
Created by Tomáš Korcak (korczis) | Open Source under GHL