-
Notifications
You must be signed in to change notification settings - Fork 3
Knowledge Base
The Knowledge Base is Sylphx Flow's curated collection of development guidelines, best practices, and architectural patterns that AI assistants can search and reference.
A structured repository of development knowledge organized into categories:
- Stacks: Framework-specific patterns (React, Next.js, Node.js)
- Guides: Architecture and design guidelines
- Universal: Cross-cutting concerns (security, performance, testing, deployment)
- Data: Database patterns and best practices
Sylphx Flow intentionally does NOT support custom knowledge base.
This design decision aligns with the MEP (Minimal Effective Prompt) philosophy:
β
Every guideline is professionally curated and verified
β
Content consistency and accuracy guaranteed
β
No outdated or incorrect information
β
Maintained by experts
vs.
β Custom knowledge = User maintains quality
β Potential for outdated info
β Inconsistent guidelines
β Maintenance burden
# With curated knowledge:
npx @sylphx/flow init # Auto-updates to latest
# With custom knowledge (if supported):
flow knowledge add my-guide.md
flow knowledge update my-guide.md
flow knowledge validate my-guide.md
# Constant maintenance required// Fixed knowledge base = Optimized search
const performance = {
searchTime: "<100ms", // TF-IDF search (primary)
indexSize: "Fixed", // Known size, optimized storage
cacheStrategy: "Perfect", // Can pre-cache everything
vectorSearch: "Optional" // OpenAI embeddings if API key provided
};
// Custom knowledge = Variable performance
const customPerformance = {
searchTime: "100-500ms", // Dynamic index
indexSize: "Variable", // Unknown size
cacheStrategy: "Complex" // Hard to optimize
};// Without custom knowledge:
User: "implement auth"
AI: [Uses curated best practices]
// No decisions needed
// With custom knowledge:
User: "implement auth"
User: "Which guideline should I use?"
User: "Should I add my own patterns?"
User: "How do I organize custom knowledge?"
// Increases complexityUse Codebase Search Instead!
# Your project's patterns are already in your code
flow codebase search "our authentication pattern"
# Advantages:
β
Always up-to-date (syncs with code)
β
Real implementation examples
β
No extra maintenance
β
Actual patterns you useExample Workflow:
# 1. Search curated knowledge for best practices
flow knowledge search "authentication security"
# Returns: JWT best practices, security guidelines
# 2. Search your codebase for your implementation
flow codebase search "authentication implementation"
# Returns: YOUR actual auth code
# 3. AI combines both:
# - Best practices from knowledge base
# - Your existing patterns from codebase
# = Perfect implementation!| Aspect | Curated Only | Custom Support |
|---|---|---|
| Quality | Guaranteed | User-dependent |
| Maintenance | Zero | High |
| Performance | <100ms | Variable |
| Cognitive Load | Minimal | Higher |
| Updates | Automatic | Manual |
| Consistency | Always | Depends |
Scenario 1: Company-specific conventions
# Solution: Document in your codebase
# src/docs/conventions.md or comments in code
# AI finds via codebase searchScenario 2: Internal best practices
# Solution: Codify as actual code patterns
# AI learns from your codebaseScenario 3: Domain-specific knowledge
# Solution: Add to your code as comments/docs
# Use codebase search to find it- π Semantic Search - Find guidelines by meaning, not just keywords
- π Curated Content - Hand-selected best practices
- π― Context-Aware - Content tailored for AI consumption
- β‘ Fast Access - Vector-indexed for instant retrieval
- π Always Updated - Content indexed and ready to use
# Basic search
npx @sylphx/flow knowledge search "react hooks patterns"
# Include content in results
npx @sylphx/flow knowledge search "nextjs routing" --include-content
# Limit results
npx @sylphx/flow knowledge search "security best practices" --limit 5
# JSON output for scripting
npx @sylphx/flow knowledge search "testing strategies" --output json# Retrieve by URI
npx @sylphx/flow knowledge get "/stacks/react-app"
npx @sylphx/flow knowledge get "/guides/saas-template"
npx @sylphx/flow knowledge get "/universal/security"# List all available knowledge
npx @sylphx/flow knowledge list
# Filter by category
npx @sylphx/flow knowledge list --category stacks
# JSON output
npx @sylphx/flow knowledge list --output json# View knowledge base status
npx @sylphx/flow knowledge statusWhen the MCP server is running, AI assistants can use these tools:
Search the knowledge base semantically.
Parameters:
-
query(required): Search query -
limit(optional): Maximum results (default: 5) -
include_content(optional): Include full content (default: false)
Example:
// AI assistant internally calls:
knowledge_search({
query: "react component patterns",
limit: 5,
include_content: true
})Retrieve a specific knowledge document by URI.
Parameters:
-
uri(required): Document URI (e.g., "/stacks/react-app")
Example:
// AI assistant internally calls:
knowledge_get({
uri: "/stacks/react-app"
})List all available knowledge resources.
Parameters:
-
category(optional): Filter by category
Example:
// AI assistant internally calls:
knowledge_list({
category: "stacks"
})- Component patterns and best practices
- Hooks usage and custom hooks
- State management strategies
- Performance optimization
- Testing React components
- App Router patterns
- Server Components vs Client Components
- Data fetching strategies
- Routing and navigation
- Deployment optimization
- Express.js patterns
- Middleware architecture
- Error handling
- Authentication & authorization
- API design best practices
- Multi-tenant architecture
- Subscription management
- Role-based access control
- Data isolation strategies
- Scaling considerations
- Technology selection frameworks
- Trade-off analysis
- Integration patterns
- Migration strategies
- Design system patterns
- Accessibility (WCAG)
- Responsive design
- User experience best practices
- Authentication strategies (JWT, OAuth, sessions)
- Authorization patterns (RBAC, ABAC)
- Input validation and sanitization
- SQL injection prevention
- XSS and CSRF protection
- Secure password handling
- API security
- Optimization strategies
- Caching patterns (client, server, CDN)
- Database query optimization
- Asset optimization
- Lazy loading
- Monitoring and profiling
- Test-driven development (TDD)
- Unit testing strategies
- Integration testing
- End-to-end testing
- Test coverage goals
- Mocking and stubbing
- CI/CD pipelines
- Infrastructure as code
- Container orchestration
- Blue-green deployments
- Rollback strategies
- Monitoring and alerting
- Query optimization
- Indexing strategies
- Migration patterns
- Transaction management
- N+1 query prevention
- Database normalization
Scenario: Developer wants to learn Next.js App Router patterns
# Search for Next.js patterns
flow knowledge search "nextjs app router patterns"
# Get the full Next.js guide
flow knowledge get "/stacks/nextjs-app"Result: AI assistant provides curated patterns and best practices.
Scenario: Need to implement authentication securely
# Search security guidelines
flow knowledge search "authentication security best practices"
# Get detailed security guide
flow knowledge get "/universal/security"Result: AI follows established security patterns.
Scenario: Building a SaaS application
# Get SaaS architecture patterns
flow knowledge get "/guides/saas-template"
# Search for multi-tenant patterns
flow knowledge search "multi-tenant architecture"Result: AI suggests proven architectural patterns.
Scenario: Reviewing React code for best practices
# AI automatically searches relevant guidelines
flow run "review this component for best practices" --agent reviewer
# AI internally calls:
# knowledge_search("react component best practices")Result: Code review based on curated guidelines.
1. Knowledge files in assets/knowledge/
β
2. Parsed and chunked into sections
β
3. StarCoder2 tokenization + TF-IDF indexing (always)
β
4. Check if API key is configured
β
5a. Has API key:
β Generate OpenAI-compatible embeddings
β Build vector index (stored separately)
5b. No API key:
β Skip vector index generation
β
6. Stored in .sylphx-flow/knowledge.db
β
7. Ready for hybrid search
1. User/AI searches: "react hooks patterns"
β
2. Check if API key is configured
β
3a. Has API key:
β Generate query embedding with OpenAI-compatible API
β Vector similarity search
β Return ranked results
3b. No API key:
β StarCoder2 tokenization
β TF-IDF statistical search
β Return ranked results
# Optional: For vector embeddings (enhances search quality)
# Works without API key using TF-IDF search
OPENAI_API_KEY=your-api-key-here
# Optional: Custom embedding model (only if OPENAI_API_KEY is set)
EMBEDDING_MODEL=text-embedding-3-small
# Optional: OpenAI-compatible endpoint (Azure OpenAI, etc.)
OPENAI_BASE_URL=https://api.openai.com/v1
# Hybrid Search Architecture (Auto-switching):
# - Has API key β Uses OpenAI-compatible vector embeddings search
# - No API key β Automatically falls back to TF-IDF search
# - Same search service handles both modes seamlessly# Start with knowledge tools enabled (default)
flow mcp start
# Disable knowledge tools
flow mcp start --disable-knowledge# View status and statistics
flow knowledge statusExample Output:
π Knowledge Base Status
========================
Status: β
Indexed and ready
Resources:
β’ Stacks: 3 documents
β’ Guides: 3 documents
β’ Universal: 4 documents
β’ Data: 1 document
β’ Total: 11 documents
Index:
β’ Search method: TF-IDF (primary) + Vector (optional)
β’ TF-IDF index: 247 chunks
β’ Vector embeddings: Available (if OpenAI API key set)
β’ Database size: 1.2 MB
β’ Last indexed: 2025-10-30 19:00:00
π Database: .sylphx-flow/knowledge.db
# β
Good: Specific and descriptive
flow knowledge search "react custom hooks patterns"
flow knowledge search "nextjs server component data fetching"
flow knowledge search "sql query optimization indexing"
# β Poor: Too vague
flow knowledge search "react"
flow knowledge search "code"
flow knowledge search "help"# Search within a specific stack
flow knowledge search "component patterns" --category stacks
# Find architectural guidance
flow knowledge search "scalability" --category guides
# Look for security best practices
flow knowledge search "authentication" --category universal-
Create markdown file in
assets/knowledge/:
# Custom Pattern
## Overview
Your custom pattern description...
## Best Practices
- Practice 1
- Practice 2
## Examples
...- Rebuild the index:
# Knowledge base automatically reindexes on MCP start
flow mcp start- Verify:
flow knowledge list
flow knowledge search "custom pattern"# Title
## Section 1
Content that will be indexed...
## Section 2
More content...
### Subsection
Nested content is supported...Best Practices:
- Use clear headings
- Write for AI consumption
- Include practical examples
- Keep sections focused
- Use code blocks for examples
# Check if indexed
flow knowledge status
# Verify database exists
ls -la .sylphx-flow/knowledge.db
# Restart MCP server to reindex
flow mcp start# Check if query is too specific
flow knowledge search "broad topic"
# List all available resources
flow knowledge list
# Try different search terms
flow knowledge search "alternative keywords"# Check if indexed
flow knowledge status
# Verify database exists
ls -la .sylphx-flow/knowledge.db
# Restart to reindex
flow init
# Note: Search works without OPENAI_API_KEY (uses TF-IDF)
# Vector embeddings are optional enhancements- Cold start: ~100-300ms (first search)
- Warm cache: ~20-50ms (subsequent searches, TF-IDF)
- With vector embeddings: +100-200ms per query (optional)
- Base knowledge (TF-IDF): ~1-2 MB
- Vector embeddings (optional): +4 KB per chunk (~1 MB extra)
- Total with embeddings: ~2-3 MB
# Use --limit to reduce result size
flow knowledge search "query" --limit 3
# Avoid --include-content unless needed
flow knowledge search "query" # Metadata only
# Reindex periodically for performance
rm .sylphx-flow/knowledge.db
flow mcp start- Search before implementing to find patterns
- Reference guidelines during code review
- Use knowledge for architectural decisions
- Combine with codebase search for context
- Add project-specific patterns to knowledge base
- Use knowledge search for onboarding
- Reference during code review
- Keep knowledge updated with team learnings
- Standardize on knowledge base guidelines
- Add team conventions to knowledge
- Use as single source of truth
- Regular knowledge review and updates
- Codebase Search - Search your actual code
- Agent Framework - Use agents with knowledge
- MCP Integration - Connect AI tools
- CLI Commands - Complete command reference
Last Updated: 2025-10-30 | Edit this page | Report Issues