@kienha/anti-chaotic 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agent/skills/ai-engineer/SKILL.md +14 -9
- package/.agent/skills/ai-engineer/references/agentic-patterns.md +47 -0
- package/.agent/skills/ai-engineer/references/evaluation.md +42 -0
- package/.agent/skills/ai-engineer/references/llm.md +41 -9
- package/.agent/skills/ai-engineer/references/rag-advanced.md +42 -0
- package/.agent/skills/ai-engineer/references/serving-optimization.md +39 -0
- package/.agent/skills/blockchain-engineer/SKILL.md +37 -7
- package/.agent/skills/blockchain-engineer/references/deployment.md +28 -0
- package/.agent/skills/blockchain-engineer/references/mechanisms.md +32 -0
- package/.agent/skills/blockchain-engineer/references/solidity.md +32 -0
- package/.agent/workflows/documentation.md +65 -6
- package/package.json +1 -1
|
@@ -1,23 +1,28 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ai-engineer
|
|
3
|
-
description: AI Engineer role. Focuses on
|
|
3
|
+
description: Expert AI Engineer role (10+ Years Exp). Focuses on production-grade GenAI, Agentic Systems, Advanced RAG, and rigorous Evaluation.
|
|
4
4
|
license: MIT
|
|
5
5
|
metadata:
|
|
6
6
|
role: AI Engineer
|
|
7
|
-
version: "
|
|
7
|
+
version: "2.0"
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
-
# AI Engineer
|
|
10
|
+
# Senior AI Engineer
|
|
11
11
|
|
|
12
|
-
You build
|
|
12
|
+
You are a Senior Staff AI Engineer with experience at top-tier tech companies (Google, OpenAI, Anthropic). You build robust, scalable, and intelligent systems. You do not just "call APIs"; you engineer reliability, observability, and performance into stochastic systems.
|
|
13
13
|
|
|
14
14
|
## Core Responsibilities
|
|
15
15
|
|
|
16
|
-
1. **
|
|
17
|
-
2. **
|
|
18
|
-
3. **Evaluation**:
|
|
16
|
+
1. **Agentic Systems & Architecture**: Designing multi-agent workflows, planning capabilities, and reliable tool-use patterns.
|
|
17
|
+
2. **Advanced RAG & Retrieval**: Implementing hybrid search, query expansion, re-ranking, and knowledge graphs.
|
|
18
|
+
3. **Evaluation & Reliability (Evals)**: Setting up rigorous evaluation pipelines (LLM-as-a-judge), regression testing, and guardrails.
|
|
19
|
+
4. **Model Integration & Optimization**: Function calling, structured outputs, prompt engineering, and choosing the right model for the task (latency vs. intelligence trade-offs).
|
|
20
|
+
5. **MLOps & Serving**: Observability, tracing, caching, and cost management.
|
|
19
21
|
|
|
20
22
|
## Dynamic Stack Loading
|
|
21
23
|
|
|
22
|
-
- **
|
|
23
|
-
- **
|
|
24
|
+
- **Agentic Patterns**: [Principles for reliable agents](references/agentic-patterns.md)
|
|
25
|
+
- **Advanced RAG**: [Techniques for high-recall retrieval](references/rag-advanced.md)
|
|
26
|
+
- **Evaluation Frameworks**: [Testing & Metrics](references/evaluation.md)
|
|
27
|
+
- **Serving & Optimization**: [Performance & MLOps](references/serving-optimization.md)
|
|
28
|
+
- **LLM Fundamentals**: [Prompting & SDKs](references/llm.md)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Agentic Patterns & Architectures
|
|
2
|
+
|
|
3
|
+
Building agents is about engineering reliability into stochastic systems.
|
|
4
|
+
|
|
5
|
+
## Core Patterns
|
|
6
|
+
|
|
7
|
+
### 1. The ReAct Loop (Reason + Act)
|
|
8
|
+
|
|
9
|
+
The fundamental loop of an agent:
|
|
10
|
+
|
|
11
|
+
1. **Thought**: Analyze the current state and goal.
|
|
12
|
+
2. **Act**: Decide on a tool to call.
|
|
13
|
+
3. **Obs**: Observe the output of the tool.
|
|
14
|
+
4. **Repeat**.
|
|
15
|
+
|
|
16
|
+
### 2. Planning & Reflection
|
|
17
|
+
|
|
18
|
+
- **Planning**: Break complex tasks into steps _before_ execution. (e.g., "First I will search for X, then I will calculate Y").
|
|
19
|
+
- **Reflection**: After an output, ask the model "Does this answer the user's question? Is it accurate?". Use a separate "Critic" prompt.
|
|
20
|
+
|
|
21
|
+
### 3. Memory Architectures
|
|
22
|
+
|
|
23
|
+
- **Short-term**: Current context window (conversation history).
|
|
24
|
+
- **Long-term**: Vector database (semantic search over past interactions).
|
|
25
|
+
- **Procedural**: Storing successful "recipes" or tool sequences for future use.
|
|
26
|
+
|
|
27
|
+
## Multi-Agent Architectures
|
|
28
|
+
|
|
29
|
+
### 1. Orchestrator-Workers (Router)
|
|
30
|
+
|
|
31
|
+
A central "Manager" LLM analyzes the request and delegates to specific "Worker" agents (e.g., Coder, Researcher, Reviewer).
|
|
32
|
+
|
|
33
|
+
- **Pros**: Clear separation of concerns, easy to eval workers independently.
|
|
34
|
+
- **Cons**: Latency (multiple hops).
|
|
35
|
+
|
|
36
|
+
### 2. Autonomous Teams (CrewAI / AutoGen)
|
|
37
|
+
|
|
38
|
+
Agents converse with each other to solve a problem.
|
|
39
|
+
|
|
40
|
+
- **Role-Playing**: "You represent the User", "You are the QA Tester".
|
|
41
|
+
- **Dynamic**: Can handle ambiguous tasks but harder to control.
|
|
42
|
+
|
|
43
|
+
## Best Practices
|
|
44
|
+
|
|
45
|
+
- **Deterministic Tools**: Tools should be as reliable as possible (APIs, Code execution).
|
|
46
|
+
- **Human-in-the-Loop**: Always pause for confirmation before destructive actions (Write DB, Deploy).
|
|
47
|
+
- **Fail Gracefully**: If a tool fails, the agent should catch the error and retry or ask for help, not crash.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Evaluation & Reliability
|
|
2
|
+
|
|
3
|
+
If you can't measure it, you can't improve it.
|
|
4
|
+
|
|
5
|
+
## The Evaluation Hierarchy
|
|
6
|
+
|
|
7
|
+
### 1. Unit Tests (Deterministic)
|
|
8
|
+
|
|
9
|
+
- Does the output JSON parse?
|
|
10
|
+
- Does the code compile?
|
|
11
|
+
- Are forbidden words present?
|
|
12
|
+
|
|
13
|
+
### 2. LLM-as-a-Judge (Semantic)
|
|
14
|
+
|
|
15
|
+
Use a stronger model (GPT-4o) to evaluate the output of your application model.
|
|
16
|
+
|
|
17
|
+
- **Frameworks**: Ragas, DeepEval, Promptfoo.
|
|
18
|
+
- **Metrics**:
|
|
19
|
+
- **Faithfulness**: Is the answer derived _only_ from the retrieved context?
|
|
20
|
+
- **Answer Relevance**: Does the answer address the user's query?
|
|
21
|
+
- **Context Precision**: Was the relevant chunk ranked at the top?
|
|
22
|
+
|
|
23
|
+
### 3. Human Review (Ground Truth)
|
|
24
|
+
|
|
25
|
+
- Create a "Golden Dataset" of 50-100 Q&A pairs verified by experts.
|
|
26
|
+
- Run regression tests against this dataset on every prompt change.
|
|
27
|
+
|
|
28
|
+
## Techniques
|
|
29
|
+
|
|
30
|
+
### Regression Testing
|
|
31
|
+
|
|
32
|
+
Treat prompts like code.
|
|
33
|
+
|
|
34
|
+
1. Change strictness in system prompt.
|
|
35
|
+
2. Run `promptfoo eval` against 50 test cases.
|
|
36
|
+
3. Compare pass rate (98% -> 92%? **Revert**).
|
|
37
|
+
|
|
38
|
+
### Guardrails
|
|
39
|
+
|
|
40
|
+
- **Input Rails**: PII detection, Jailbreak attempts.
|
|
41
|
+
- **Output Rails**: Hallucination check, Tone check.
|
|
42
|
+
- **Tools**: NeMo Guardrails, Llama Guard.
|
|
@@ -1,13 +1,45 @@
|
|
|
1
|
-
# Tech: LLMs &
|
|
1
|
+
# Tech: LLMs & Integration Patterns
|
|
2
2
|
|
|
3
|
-
## Stack
|
|
3
|
+
## Stack Selection
|
|
4
4
|
|
|
5
|
-
- **
|
|
6
|
-
- **
|
|
7
|
-
- **
|
|
5
|
+
- **Inference Engine**:
|
|
6
|
+
- **Complex Reasoning**: GPT-4o, Claude 3.5 Sonnet.
|
|
7
|
+
- **Fast/Cheap**: Gemini Flash, Haiku, Llama 3 (Groq/Together).
|
|
8
|
+
- **Orchestration**:
|
|
9
|
+
- **Production**: Vercel AI SDK (Type-safe, streaming first).
|
|
10
|
+
- **Prototyping**: LangChain (Use with caution in production due to abstraction overhead).
|
|
11
|
+
- **Gateway**: Portkey or Helicone for observability and fallback.
|
|
8
12
|
|
|
9
|
-
##
|
|
13
|
+
## Advanced Patterns
|
|
10
14
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
### 1. Structured Outputs
|
|
16
|
+
|
|
17
|
+
Stop parsing regex. Use native JSON mode or tool definitions to enforce strict schemas (Zod).
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
// Example using Vercel AI SDK
|
|
21
|
+
const { object } = await generateObject({
|
|
22
|
+
model: openai("gpt-4o"),
|
|
23
|
+
schema: z.object({
|
|
24
|
+
sentiment: z.enum(["positive", "negative"]),
|
|
25
|
+
reasoning: z.string(),
|
|
26
|
+
}),
|
|
27
|
+
prompt: "Analyze this customer feedback...",
|
|
28
|
+
});
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### 2. Reliable Prompt Engineering
|
|
32
|
+
|
|
33
|
+
- **Chain of Thought (CoT)**: Force the model to "think" before answering. `Let's think step by step.`
|
|
34
|
+
- **Few-Shot Prompting**: Provide 3-5 high-quality examples of input -> output.
|
|
35
|
+
- **System Prompts**: strict role definition, output constraints, and "tone of voice" instructions. Version control these!
|
|
36
|
+
|
|
37
|
+
### 3. Streaming & UI Integration
|
|
38
|
+
|
|
39
|
+
- **Optimistic UI**: Show skeleton loaders or predicted text while waiting.
|
|
40
|
+
- **Generative UI**: Stream React components directly from the LLM (Vercel AI SDK RSC).
|
|
41
|
+
|
|
42
|
+
### 4. Cost Management
|
|
43
|
+
|
|
44
|
+
- **Token Counting**: Always estimate tokens before sending requests.
|
|
45
|
+
- **Caching**: Cache identical prompts at the edge/gateway layer.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Advanced RAG Patterns
|
|
2
|
+
|
|
3
|
+
Move beyond naive "chunk & retrieve".
|
|
4
|
+
|
|
5
|
+
## Retrieval Optimization
|
|
6
|
+
|
|
7
|
+
### 1. Hybrid Search (Keyword + Semantic)
|
|
8
|
+
|
|
9
|
+
Dense vectors (semantic) miss exact matches (IDs, acronyms). Sparse vectors (BM25/Splade) miss intent.
|
|
10
|
+
**Solution**: Combine both with Reciprocal Rank Fusion (RRF).
|
|
11
|
+
|
|
12
|
+
- **Stack**: Pinecone (Hybrid), Weaviate, Supabase (pgvector + pg_search).
|
|
13
|
+
|
|
14
|
+
### 2. Re-Ranking (Cross-Encoders)
|
|
15
|
+
|
|
16
|
+
Retrieving 50 docs with a bi-encoder is fast but inaccurate.
|
|
17
|
+
**Solution**: Retrieve 50 -> Re-rank top 5 with a Cross-Encoder (Cohere Rerank, bge-reranker). This dramatically improves precision.
|
|
18
|
+
|
|
19
|
+
### 3. Query Transformations
|
|
20
|
+
|
|
21
|
+
Users write bad queries.
|
|
22
|
+
|
|
23
|
+
- **Expansion**: Generate synonyms or related questions.
|
|
24
|
+
- **Decomposition**: Break complex questions into sub-queries.
|
|
25
|
+
- **HyDE (Hypothetical Document Embeddings)**: Generate a fake answer, embed _that_, and search for similar real chunks.
|
|
26
|
+
|
|
27
|
+
### 4. Contextual Compression
|
|
28
|
+
|
|
29
|
+
Don't shove 10 full documents into the context.
|
|
30
|
+
|
|
31
|
+
- Summarize retrieved docs relative to the query before passing to the LLM.
|
|
32
|
+
|
|
33
|
+
## Knowledge Graphs (GraphRAG)
|
|
34
|
+
|
|
35
|
+
For questions requiring global reasoning ("How do the themes in book A relate to book B?").
|
|
36
|
+
|
|
37
|
+
- Extract entities and relationships -> Store in Graph DB (Neo4j) -> Traverse during retrieval.
|
|
38
|
+
|
|
39
|
+
## Indexing Strategy
|
|
40
|
+
|
|
41
|
+
- **Parent-Child Chunking**: Retrieve small chunks (better matching), but return the parent large chunk (better context).
|
|
42
|
+
- **Multi-Vector Retrieval**: Embed summaries for search, but return full raw text for generation.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Serving & Optimization (MLOps)
|
|
2
|
+
|
|
3
|
+
Moving from "it works on my laptop" to "production scale".
|
|
4
|
+
|
|
5
|
+
## Observability & Tracing
|
|
6
|
+
|
|
7
|
+
You cannot debug a stochastic system with `console.log`.
|
|
8
|
+
|
|
9
|
+
- **Tracing**: Visualize the entire chain (User -> RAG -> Tool -> LLM).
|
|
10
|
+
- **Tools**: LangSmith, Arize Phoenix, Helicone.
|
|
11
|
+
- **Key Metrics**:
|
|
12
|
+
- **Latency**: Time to First Token (TTFT), Total Latency.
|
|
13
|
+
- **Cost**: Cost per request, Token usage.
|
|
14
|
+
- **Quality**: User feedback (Thumbs up/down).
|
|
15
|
+
|
|
16
|
+
## Optimization Techniques
|
|
17
|
+
|
|
18
|
+
### 1. Caching (The Semantic Cache)
|
|
19
|
+
|
|
20
|
+
Don't pay for the same answer twice.
|
|
21
|
+
|
|
22
|
+
- **Exact Match**: Redis check on prompt string.
|
|
23
|
+
- **Semantic Match**: Check vector distance of prompt embeddings (e.g., "How do I reset password" ~= "modify password steps").
|
|
24
|
+
|
|
25
|
+
### 2. Latency Reduction
|
|
26
|
+
|
|
27
|
+
- **Streaming**: Non-negotiable for UX.
|
|
28
|
+
- **Speculative Decoding**: Use a small model to draft, large model to verify.
|
|
29
|
+
- **Quantization**: Run int8/int4 models if self-hosting (vLLM).
|
|
30
|
+
|
|
31
|
+
### 3. Cost Control
|
|
32
|
+
|
|
33
|
+
- **Model Cascading**: Try a cheap model (Flash/Haiku) first. If confidence < X, retry with GPT-4.
|
|
34
|
+
- **Fine-tuning**: Fine-tune a small model (Llama 3 8B) on your specific task to match GPT-4 performance at 1/10th the cost.
|
|
35
|
+
|
|
36
|
+
## Deployment Stack
|
|
37
|
+
|
|
38
|
+
- **Managed**: Vercel, AWS Bedrock.
|
|
39
|
+
- **Self-Hosted**: vLLM, TGI (Text Generation Inference), Ray Serve.
|
|
@@ -1,23 +1,53 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: blockchain-engineer
|
|
3
|
-
description: Blockchain Engineer
|
|
3
|
+
description: Expert Blockchain Engineer (10+ Years). Master of Protocol Architecture, Advanced Smart Contract Development, and Security.
|
|
4
4
|
license: MIT
|
|
5
5
|
metadata:
|
|
6
6
|
role: Blockchain Engineer
|
|
7
|
-
version: "
|
|
7
|
+
version: "2.0"
|
|
8
8
|
---
|
|
9
9
|
|
|
10
10
|
# Blockchain Engineer
|
|
11
11
|
|
|
12
|
-
You build the decentralized layer.
|
|
12
|
+
You are an expert Blockchain Engineer with 10+ years of experience at top tech firms. You build the decentralized layer with a focus on security, scalability, and economic robustness.
|
|
13
13
|
|
|
14
14
|
## Core Responsibilities
|
|
15
15
|
|
|
16
|
-
1. **
|
|
17
|
-
2. **
|
|
18
|
-
3. **Security**:
|
|
16
|
+
1. **Protocol Architecture**: Design tokenomics, governance structures, and ensuring incentive alignment across the network.
|
|
17
|
+
2. **Smart Contract Mastery**: End-to-end lifecycle management of smart contracts on EVM (Solidity/Yul) and SVM (Rust/Anchor).
|
|
18
|
+
3. **Advanced Security**: Protect value through formal verification, fuzzing, and rigorous audit preparation.
|
|
19
|
+
4. **Scaling Solutions**: Architect solutions using L2s, Optimistic/ZK Rollups, and AppChains.
|
|
20
|
+
|
|
21
|
+
## Technical Standards & Best Practices
|
|
22
|
+
|
|
23
|
+
### Development Lifecycle
|
|
24
|
+
|
|
25
|
+
- **Environment**: Master usage of Hardhat and Foundry (Forge/Cast/Anvil) for EVM; Anchor for Solana.
|
|
26
|
+
- **Testing**: Beyond unit tests—implement invariant testing, fuzzing (Echo/Medusa), and fork testing.
|
|
27
|
+
- **CI/CD**: Automated pipelines for linting, testing, and deterministic deployments.
|
|
28
|
+
|
|
29
|
+
### Optimization & Quality
|
|
30
|
+
|
|
31
|
+
- **Gas Golfing**: Optimize for gas efficiency using Yul/Assembly, storage layout packing, and calldata mastery.
|
|
32
|
+
- **Code Quality**: Enforce NatSpec documentation, strict linting (Solhint/Clippy), and clean code patterns.
|
|
33
|
+
|
|
34
|
+
### Deployment & Ops
|
|
35
|
+
|
|
36
|
+
- **Patterns**: Use deterministic deployment (Create2) and manage upgrades via standard proxies (Transparent, UUPS, Diamond/EIP-2535).
|
|
37
|
+
- **Security**: Manage keys via Multi-sig (Gnosis Safe) and Timelocks. Automate ops with scripting.
|
|
38
|
+
|
|
39
|
+
## Architecture Patterns
|
|
40
|
+
|
|
41
|
+
- **Upgradeability**: Future-proof contracts using Transparent, UUPS, or Diamond patterns.
|
|
42
|
+
- **Interoperability**: Connect chains using Bridges, Atomic Swaps, and CCIP.
|
|
43
|
+
- **Data Integration**: Index data with Subgraphs (The Graph) and secure external feeds via Oracles (Chainlink, Pyth).
|
|
19
44
|
|
|
20
45
|
## Dynamic Stack Loading
|
|
21
46
|
|
|
22
|
-
- **EVM (Ethereum/Polygon)**:
|
|
47
|
+
- **EVM (Ethereum/Polygon/Arbitrum)**:
|
|
48
|
+
- [EVM Overview](references/evm.md)
|
|
49
|
+
- [Solidity Development](references/solidity.md)
|
|
50
|
+
- [Deployment & Ops](references/deployment.md)
|
|
51
|
+
- [Mechanisms & Internals](references/mechanisms.md)
|
|
23
52
|
- **Solana**: (Create `references/solana.md` if needed)
|
|
53
|
+
- **ZK & Privacy**: Focus on ZK-SNARKs/STARKs for privacy and scaling.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Tech: Smart Contract Deployment
|
|
2
|
+
|
|
3
|
+
## Strategies
|
|
4
|
+
|
|
5
|
+
- **Immutable**: Simple deployment. Code cannot be changed. High trust, low flexibility.
|
|
6
|
+
- **Upgradeable Proxies**:
|
|
7
|
+
- **Transparent Upgradeable Proxy**: Admin logic separated. High gas overhead.
|
|
8
|
+
- **UUPS (Universal Upgradeable Proxy Standard)**: Upgrade logic in implementation. Cheaper gas.
|
|
9
|
+
- **Diamond (EIP-2535)**: Modular system, unlimited size, complex management.
|
|
10
|
+
|
|
11
|
+
## Automation & Tooling
|
|
12
|
+
|
|
13
|
+
- **Hardhat Ignition**: Declarative deployment modules. Handles dependency management and recovery.
|
|
14
|
+
- **Foundry Script**: Solidity-based scripting (`forge script`). Fast and integrated with Forge tests.
|
|
15
|
+
- **Deterministic Deployment**:
|
|
16
|
+
- Use `CREATE2` to deploy to the same address across multiple chains.
|
|
17
|
+
- Tool: `Nick's Method` factory / `Arachnid/deterministic-deployment-proxy`.
|
|
18
|
+
|
|
19
|
+
## Verification
|
|
20
|
+
|
|
21
|
+
- **Etherscan/Block Explorers**: ALWAYs verify source code.
|
|
22
|
+
- **Sourcify**: Decentralized verification based on metadata hash.
|
|
23
|
+
|
|
24
|
+
## Operational Safety
|
|
25
|
+
|
|
26
|
+
- **Multisig (Gnosis Safe)**: Never deploy or manage admin keys with a single EOA (Externally Owned Account).
|
|
27
|
+
- **Timelocks**: Enforce a delay (e.g., 48h) between proposing and executing sensitive admin actions.
|
|
28
|
+
- **Access Control Rotation**: Plan for key rotation procedures.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Tech: Blockchain Mechanisms & Internals
|
|
2
|
+
|
|
3
|
+
## Consensus
|
|
4
|
+
|
|
5
|
+
- **PoS (Proof of Stake)**: Validators stake tokens to propose/attest blocks. (Ethereum, Solana).
|
|
6
|
+
- **PoW (Proof of Work)**: Miners solve cryptographic puzzles. (Bitcoin).
|
|
7
|
+
- **Finality**:
|
|
8
|
+
- **Probabilistic**: Bitcoin (wait ~6 blocks).
|
|
9
|
+
- **Deterministic**: Ethereum (after finalized epoch), Tendermint (instant).
|
|
10
|
+
|
|
11
|
+
## State Management
|
|
12
|
+
|
|
13
|
+
- **Account Model (Ethereum/Solana)**: Global state tracks account balances and nonce.
|
|
14
|
+
- **UTXO (Bitcoin/Cardano)**: Unspent Transaction Outputs. State is the set of all unspent outputs.
|
|
15
|
+
- **Data Structures**:
|
|
16
|
+
- **Merkle Patricia Trie (Ethereum)**: Storage, State, Transactions, Receipts.
|
|
17
|
+
- **Verkle Trees**: Future upgrade for stateless clients.
|
|
18
|
+
|
|
19
|
+
## Transaction Lifecycle
|
|
20
|
+
|
|
21
|
+
1. **Creation**: User signs tx with private key.
|
|
22
|
+
2. **Propagation**: Gossip protocol sends tx to Mempool.
|
|
23
|
+
3. **Ordering**: Block Builders/Proposers select and order txs (MEV opportunity here).
|
|
24
|
+
4. **Execution**: EVM executes logic, updates state trie.
|
|
25
|
+
5. **Finalization**: Block is added to chain and finalized by consensus.
|
|
26
|
+
|
|
27
|
+
## EVM Internals
|
|
28
|
+
|
|
29
|
+
- **Stack**: 1024 depth, 256-bit words. Most gas efficient.
|
|
30
|
+
- **Memory**: Linear, byte-addressable. Expanded in 32-byte chunks.
|
|
31
|
+
- **Storage**: Key-value store (256-bit -> 256-bit). Most expensive. SLOAD/SSTORE.
|
|
32
|
+
- **Logs**: Bloom filters used for event indexing. Cheaper than storage but not accessible by contracts.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Tech: Solidity Development
|
|
2
|
+
|
|
3
|
+
## Best Practices
|
|
4
|
+
|
|
5
|
+
- **Layout**: Follow [Solidty Style Guide](https://docs.soliditylang.org/en/latest/style-guide.html).
|
|
6
|
+
- Order: Pragma -> Import -> Interfaces -> Libraries -> Contracts.
|
|
7
|
+
- Inside Contract: Type declarations -> State vars -> Events -> Modifiers -> Functions.
|
|
8
|
+
- **Naming**: `camelCase` for variables/functions, `CapWords` for contracts/structs/events, `UPPER_CASE` for constants.
|
|
9
|
+
- **Error Handling**: Use custom errors (`error InsufficientFunds()`) instead of strings for gas efficiency.
|
|
10
|
+
|
|
11
|
+
## Advanced Concepts
|
|
12
|
+
|
|
13
|
+
- **Storage Layout**: Understand slot packing to minimize storage costs.
|
|
14
|
+
- Pack `uint128`, `address`, `bool` into single 256-bit slots where possible.
|
|
15
|
+
- **Delegatecall**: Execution in the context of the caller (crucial for proxies).
|
|
16
|
+
- **Assembly (Yul)**: Use `assembly { ... }` for low-level memory manipulation and gas optimization.
|
|
17
|
+
- **EIP Standards**:
|
|
18
|
+
- **ERC-20/721/1155**: Token standards.
|
|
19
|
+
- **ERC-4626**: Tokenized Vaults.
|
|
20
|
+
- **ERC-2535**: Diamond Standard.
|
|
21
|
+
|
|
22
|
+
## Security Patterns
|
|
23
|
+
|
|
24
|
+
- **Checks-Effects-Interactions**: Update state _before_ making external calls to prevent reentrancy.
|
|
25
|
+
- **Pull over Push**: Let users withdraw funds rather than pushing them to arrays of addresses (avoids DoS).
|
|
26
|
+
- **Access Control**: Use `OwnableTwoStep` or `AccessControl` (RBAC).
|
|
27
|
+
|
|
28
|
+
## Gas Optimization
|
|
29
|
+
|
|
30
|
+
- **Calldata**: Use `calldata` instead of `memory` for read-only function arguments.
|
|
31
|
+
- **Unchecked Math**: Use `unchecked { ... }` when overflow/underflow is impossible (Solidity 0.8+ default checks cost gas).
|
|
32
|
+
- **Constants/Immutable**: Use `constant` for literal values and `immutable` for constructor-set values.
|
|
@@ -37,24 +37,81 @@ description: Generate comprehensive documentation (Architecture, API, Specs) fro
|
|
|
37
37
|
|
|
38
38
|
1. **Invoke `[lead-architect]` skill** to analyze codebase structure
|
|
39
39
|
2. Identify: tech stack, entry points, API routes, DB schemas
|
|
40
|
-
3. **
|
|
40
|
+
3. **Clarify & Confirm**:
|
|
41
|
+
- **CRITICAL**: If the codebase structure is unclear or ambiguous, **ASK** the user for clarification.
|
|
42
|
+
- Summarize findings and **WAIT** for user to confirm understanding
|
|
41
43
|
|
|
42
44
|
---
|
|
43
45
|
|
|
44
|
-
## Step A2:
|
|
46
|
+
## Step A2: Technical Documentation (Architecture, API, Schema)
|
|
45
47
|
|
|
46
48
|
// turbo
|
|
47
49
|
|
|
48
50
|
1. **Invoke `[lead-architect]` skill** to create:
|
|
49
51
|
- System Context (C4 Context Diagram)
|
|
50
52
|
- Component View (C4 Component Diagram)
|
|
53
|
+
- **Sequence Diagrams** for critical business flows
|
|
51
54
|
2. **Invoke `[backend-developer]` skill** to:
|
|
52
|
-
- Document API endpoints
|
|
55
|
+
- Document API endpoints (OpenAPI/Swagger styled)
|
|
53
56
|
- Generate Entity Relationship Diagram (ERD)
|
|
57
|
+
- Document key algorithms or data processing pipelines
|
|
54
58
|
3. Save to `docs/030-Specs/` and `docs/030-Specs/Architecture/`
|
|
55
59
|
|
|
56
60
|
---
|
|
57
61
|
|
|
62
|
+
## Step A3: Functional Documentation (Reverse Engineering)
|
|
63
|
+
|
|
64
|
+
// turbo
|
|
65
|
+
|
|
66
|
+
**Objective**: Derive business logic and requirements from the existing implementation.
|
|
67
|
+
|
|
68
|
+
1. **Invoke `[business-analysis]` skill** to:
|
|
69
|
+
- Analyze the codebase (controllers, services, frontend views) to understand user flows.
|
|
70
|
+
- **Reverse Engineer** the PRD/Functional Specs:
|
|
71
|
+
- Identify high-level Epics.
|
|
72
|
+
- Document implied User Stories & Acceptance Criteria.
|
|
73
|
+
- Create Use Case definitions for main features.
|
|
74
|
+
2. **Draft Artifacts**:
|
|
75
|
+
- `docs/020-Requirements/Reverse-Engineered-Specs.md`
|
|
76
|
+
- `docs/022-User-Stories/Implied-User-Stories.md`
|
|
77
|
+
3. **Review**: Present these findings to the user to confirm they align with business reality.
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Step A4: Operational & Quality Documentation
|
|
82
|
+
|
|
83
|
+
// turbo
|
|
84
|
+
|
|
85
|
+
**Objective**: Document how to run, test, and deploy the system.
|
|
86
|
+
|
|
87
|
+
1. **Invoke `[devops-engineer]` skill** to create:
|
|
88
|
+
- **Infrastructure**: Document cloud resources, Docker setup (`docs/030-Specs/Architecture/Infrastructure.md`).
|
|
89
|
+
- **Deployment**: CI/CD pipelines and release process (`docs/030-Specs/Architecture/Deployment.md`).
|
|
90
|
+
- **Configuration**: Environment variables reference (`docs/030-Specs/Configuration.md`).
|
|
91
|
+
2. **Invoke `[qa-tester]` skill** to create:
|
|
92
|
+
- **Test Strategy**: Overview of testing tools and approach (`docs/035-QA/Test-Plans/Strategy.md`).
|
|
93
|
+
- **Coverage Report**: Summary of current test coverage and gaps (`docs/035-QA/Reports/Coverage.md`).
|
|
94
|
+
3. **Invoke `[backend-developer]` skill** to create/update:
|
|
95
|
+
- **Onboarding**: `docs/060-Manuals/Admin-Guide/Setup-Guide.md` (Prerequisites, installation, running locally).
|
|
96
|
+
- **Scripts**: Document usage of `package.json` scripts (`docs/060-Manuals/Admin-Guide/Scripts.md`).
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## Step A5: Project Planning & Strategy
|
|
101
|
+
|
|
102
|
+
// turbo
|
|
103
|
+
|
|
104
|
+
**Objective**: Establish high-level strategy and roadmap based on current state.
|
|
105
|
+
|
|
106
|
+
1. **Invoke `[product-manager]` skill** to:
|
|
107
|
+
- **Analyze Maturity**: Assess current feature set against typical market standards.
|
|
108
|
+
- **Reverse Engineer Roadmap**: Draft `docs/010-Planning/Roadmap.md` based on implemented vs. missing features.
|
|
109
|
+
- **Define Objectives**: Draft `docs/010-Planning/OKRs.md` (Objectives and Key Results) aligned with the project's apparent direction.
|
|
110
|
+
- **Status Report**: Create a snapshot of current progress (`docs/010-Planning/Sprints/Current-Status.md`).
|
|
111
|
+
2. **Review**: Present these strategic documents to the user for alignment.
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
58
115
|
# MODE B: From Requirements
|
|
59
116
|
|
|
60
117
|
**Prerequisite**: Existing PRD (from `/brainstorm`).
|
|
@@ -68,13 +125,14 @@ description: Generate comprehensive documentation (Architecture, API, Specs) fro
|
|
|
68
125
|
> - **MUST** use `sequential-thinking` for architectural decisions
|
|
69
126
|
> - Use `context7` with `/vercel/next.js`, `/supabase/supabase` for tech stack research
|
|
70
127
|
|
|
71
|
-
1. **
|
|
128
|
+
1. **Analyze Requirements**: Review the PRD/Roadmap. If there are ambiguities, **ASK** the user to clarify.
|
|
129
|
+
2. **Invoke `[lead-architect]` skill** to draft:
|
|
72
130
|
- High-level system architecture
|
|
73
131
|
- Technology stack decisions
|
|
74
132
|
- Component diagram
|
|
75
133
|
- Data flow overview
|
|
76
|
-
|
|
77
|
-
|
|
134
|
+
3. Create `draft-sdd.md` artifact
|
|
135
|
+
4. After approval → Save to `docs/030-Specs/Architecture/SDD-{ProjectName}.md`
|
|
78
136
|
|
|
79
137
|
---
|
|
80
138
|
|
|
@@ -85,6 +143,7 @@ description: Generate comprehensive documentation (Architecture, API, Specs) fro
|
|
|
85
143
|
1. **Invoke `[business-analysis]` skill** to:
|
|
86
144
|
- Break PRD features into Epics (`docs/022-User-Stories/Epics/`)
|
|
87
145
|
- Define Use Cases with Mermaid diagrams (`docs/020-Requirements/Use-Cases/`)
|
|
146
|
+
- **Note**: If requirements are vague, ask for clarification.
|
|
88
147
|
2. Create artifacts for review before saving
|
|
89
148
|
|
|
90
149
|
---
|