agentic-team-templates 0.3.0

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.
Files changed (103) hide show
  1. package/README.md +280 -0
  2. package/bin/cli.js +5 -0
  3. package/package.json +47 -0
  4. package/src/index.js +521 -0
  5. package/templates/_shared/code-quality.md +162 -0
  6. package/templates/_shared/communication.md +114 -0
  7. package/templates/_shared/core-principles.md +62 -0
  8. package/templates/_shared/git-workflow.md +165 -0
  9. package/templates/_shared/security-fundamentals.md +173 -0
  10. package/templates/blockchain/.cursorrules/defi-patterns.md +520 -0
  11. package/templates/blockchain/.cursorrules/gas-optimization.md +339 -0
  12. package/templates/blockchain/.cursorrules/overview.md +130 -0
  13. package/templates/blockchain/.cursorrules/security.md +318 -0
  14. package/templates/blockchain/.cursorrules/smart-contracts.md +364 -0
  15. package/templates/blockchain/.cursorrules/testing.md +415 -0
  16. package/templates/blockchain/.cursorrules/web3-integration.md +538 -0
  17. package/templates/blockchain/CLAUDE.md +389 -0
  18. package/templates/cli-tools/.cursorrules/architecture.md +412 -0
  19. package/templates/cli-tools/.cursorrules/arguments.md +406 -0
  20. package/templates/cli-tools/.cursorrules/distribution.md +546 -0
  21. package/templates/cli-tools/.cursorrules/error-handling.md +455 -0
  22. package/templates/cli-tools/.cursorrules/overview.md +136 -0
  23. package/templates/cli-tools/.cursorrules/testing.md +537 -0
  24. package/templates/cli-tools/.cursorrules/user-experience.md +545 -0
  25. package/templates/cli-tools/CLAUDE.md +356 -0
  26. package/templates/data-engineering/.cursorrules/data-modeling.md +367 -0
  27. package/templates/data-engineering/.cursorrules/data-quality.md +455 -0
  28. package/templates/data-engineering/.cursorrules/overview.md +85 -0
  29. package/templates/data-engineering/.cursorrules/performance.md +339 -0
  30. package/templates/data-engineering/.cursorrules/pipeline-design.md +280 -0
  31. package/templates/data-engineering/.cursorrules/security.md +460 -0
  32. package/templates/data-engineering/.cursorrules/testing.md +452 -0
  33. package/templates/data-engineering/CLAUDE.md +974 -0
  34. package/templates/devops-sre/.cursorrules/capacity-planning.md +653 -0
  35. package/templates/devops-sre/.cursorrules/change-management.md +584 -0
  36. package/templates/devops-sre/.cursorrules/chaos-engineering.md +651 -0
  37. package/templates/devops-sre/.cursorrules/disaster-recovery.md +641 -0
  38. package/templates/devops-sre/.cursorrules/incident-management.md +565 -0
  39. package/templates/devops-sre/.cursorrules/observability.md +714 -0
  40. package/templates/devops-sre/.cursorrules/overview.md +230 -0
  41. package/templates/devops-sre/.cursorrules/postmortems.md +588 -0
  42. package/templates/devops-sre/.cursorrules/runbooks.md +760 -0
  43. package/templates/devops-sre/.cursorrules/slo-sli.md +617 -0
  44. package/templates/devops-sre/.cursorrules/toil-reduction.md +567 -0
  45. package/templates/devops-sre/CLAUDE.md +1007 -0
  46. package/templates/documentation/.cursorrules/adr.md +277 -0
  47. package/templates/documentation/.cursorrules/api-documentation.md +411 -0
  48. package/templates/documentation/.cursorrules/code-comments.md +253 -0
  49. package/templates/documentation/.cursorrules/maintenance.md +260 -0
  50. package/templates/documentation/.cursorrules/overview.md +82 -0
  51. package/templates/documentation/.cursorrules/readme-standards.md +306 -0
  52. package/templates/documentation/CLAUDE.md +120 -0
  53. package/templates/fullstack/.cursorrules/api-contracts.md +331 -0
  54. package/templates/fullstack/.cursorrules/architecture.md +298 -0
  55. package/templates/fullstack/.cursorrules/overview.md +109 -0
  56. package/templates/fullstack/.cursorrules/shared-types.md +348 -0
  57. package/templates/fullstack/.cursorrules/testing.md +386 -0
  58. package/templates/fullstack/CLAUDE.md +349 -0
  59. package/templates/ml-ai/.cursorrules/data-engineering.md +483 -0
  60. package/templates/ml-ai/.cursorrules/deployment.md +601 -0
  61. package/templates/ml-ai/.cursorrules/model-development.md +538 -0
  62. package/templates/ml-ai/.cursorrules/monitoring.md +658 -0
  63. package/templates/ml-ai/.cursorrules/overview.md +131 -0
  64. package/templates/ml-ai/.cursorrules/security.md +637 -0
  65. package/templates/ml-ai/.cursorrules/testing.md +678 -0
  66. package/templates/ml-ai/CLAUDE.md +1136 -0
  67. package/templates/mobile/.cursorrules/navigation.md +246 -0
  68. package/templates/mobile/.cursorrules/offline-first.md +302 -0
  69. package/templates/mobile/.cursorrules/overview.md +71 -0
  70. package/templates/mobile/.cursorrules/performance.md +345 -0
  71. package/templates/mobile/.cursorrules/testing.md +339 -0
  72. package/templates/mobile/CLAUDE.md +233 -0
  73. package/templates/platform-engineering/.cursorrules/ci-cd.md +778 -0
  74. package/templates/platform-engineering/.cursorrules/developer-experience.md +632 -0
  75. package/templates/platform-engineering/.cursorrules/infrastructure-as-code.md +600 -0
  76. package/templates/platform-engineering/.cursorrules/kubernetes.md +710 -0
  77. package/templates/platform-engineering/.cursorrules/observability.md +747 -0
  78. package/templates/platform-engineering/.cursorrules/overview.md +215 -0
  79. package/templates/platform-engineering/.cursorrules/security.md +855 -0
  80. package/templates/platform-engineering/.cursorrules/testing.md +878 -0
  81. package/templates/platform-engineering/CLAUDE.md +850 -0
  82. package/templates/utility-agent/.cursorrules/action-control.md +284 -0
  83. package/templates/utility-agent/.cursorrules/context-management.md +186 -0
  84. package/templates/utility-agent/.cursorrules/hallucination-prevention.md +253 -0
  85. package/templates/utility-agent/.cursorrules/overview.md +78 -0
  86. package/templates/utility-agent/.cursorrules/token-optimization.md +369 -0
  87. package/templates/utility-agent/CLAUDE.md +513 -0
  88. package/templates/web-backend/.cursorrules/api-design.md +255 -0
  89. package/templates/web-backend/.cursorrules/authentication.md +309 -0
  90. package/templates/web-backend/.cursorrules/database-patterns.md +298 -0
  91. package/templates/web-backend/.cursorrules/error-handling.md +366 -0
  92. package/templates/web-backend/.cursorrules/overview.md +69 -0
  93. package/templates/web-backend/.cursorrules/security.md +358 -0
  94. package/templates/web-backend/.cursorrules/testing.md +395 -0
  95. package/templates/web-backend/CLAUDE.md +366 -0
  96. package/templates/web-frontend/.cursorrules/accessibility.md +296 -0
  97. package/templates/web-frontend/.cursorrules/component-patterns.md +204 -0
  98. package/templates/web-frontend/.cursorrules/overview.md +72 -0
  99. package/templates/web-frontend/.cursorrules/performance.md +325 -0
  100. package/templates/web-frontend/.cursorrules/state-management.md +227 -0
  101. package/templates/web-frontend/.cursorrules/styling.md +271 -0
  102. package/templates/web-frontend/.cursorrules/testing.md +311 -0
  103. package/templates/web-frontend/CLAUDE.md +399 -0
@@ -0,0 +1,389 @@
1
+ # Blockchain Development Guide
2
+
3
+ Staff-level guidelines for blockchain and Web3 development. This guide covers smart contract development, DeFi protocols, and decentralized application architecture.
4
+
5
+ ---
6
+
7
+ ## Overview
8
+
9
+ This guide applies to:
10
+
11
+ - Smart contract development (Solidity, Vyper)
12
+ - DeFi protocols (AMMs, lending, yield strategies)
13
+ - Token implementations (ERC-20, ERC-721, ERC-1155, ERC-4626)
14
+ - Web3 frontend applications
15
+ - Cross-chain and L2 integrations
16
+
17
+ ### Key Principles
18
+
19
+ 1. **Security Is Non-Negotiable** - Immutable code handling real value
20
+ 2. **Gas Efficiency Matters** - Users pay for every operation
21
+ 3. **Composability Is King** - Build for the ecosystem
22
+ 4. **Defense in Depth** - Multiple layers of protection
23
+
24
+ ### Technology Stack
25
+
26
+ | Layer | Technology |
27
+ |-------|------------|
28
+ | Smart Contracts | Solidity 0.8.x, OpenZeppelin |
29
+ | Testing | Foundry (Forge), Hardhat |
30
+ | Static Analysis | Slither, Mythril |
31
+ | Web3 Frontend | Viem, Wagmi, React |
32
+ | Wallet Connection | ConnectKit, RainbowKit |
33
+ | Oracles | Chainlink, Uniswap TWAP |
34
+
35
+ ---
36
+
37
+ ## Smart Contract Patterns
38
+
39
+ ### File Structure
40
+
41
+ ```solidity
42
+ // SPDX-License-Identifier: MIT
43
+ pragma solidity 0.8.20;
44
+
45
+ // Imports (interfaces → libraries → contracts)
46
+ import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
47
+ import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
48
+ import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
49
+
50
+ contract Protocol is ReentrancyGuard {
51
+ using SafeERC20 for IERC20;
52
+
53
+ // State: constants → immutables → storage
54
+ uint256 public constant MAX_FEE = 1000;
55
+ address public immutable i_owner;
56
+ uint256 private s_totalDeposits;
57
+
58
+ // Events
59
+ event Deposited(address indexed user, uint256 amount);
60
+
61
+ // Errors
62
+ error InsufficientBalance(uint256 requested, uint256 available);
63
+
64
+ // External → Public → Internal → Private → View/Pure
65
+ }
66
+ ```
67
+
68
+ ### Checks-Effects-Interactions Pattern
69
+
70
+ ```solidity
71
+ function withdraw(uint256 amount) external nonReentrant {
72
+ // 1. CHECKS
73
+ if (s_balances[msg.sender] < amount) {
74
+ revert InsufficientBalance(amount, s_balances[msg.sender]);
75
+ }
76
+
77
+ // 2. EFFECTS
78
+ s_balances[msg.sender] -= amount;
79
+
80
+ // 3. INTERACTIONS
81
+ IERC20(token).safeTransfer(msg.sender, amount);
82
+ }
83
+ ```
84
+
85
+ ### Input Validation
86
+
87
+ ```solidity
88
+ function deposit(address token, uint256 amount, address recipient) external {
89
+ if (token == address(0)) revert ZeroAddress();
90
+ if (amount == 0) revert ZeroAmount();
91
+ if (!s_allowedTokens[token]) revert TokenNotAllowed(token);
92
+
93
+ IERC20(token).safeTransferFrom(msg.sender, address(this), amount);
94
+ s_balances[recipient] += amount;
95
+ }
96
+ ```
97
+
98
+ ---
99
+
100
+ ## Security Checklist
101
+
102
+ ### Attack Vectors to Test
103
+
104
+ | Attack | Prevention |
105
+ |--------|------------|
106
+ | Reentrancy | CEI pattern + ReentrancyGuard |
107
+ | Flash Loan Manipulation | TWAP oracles, not spot prices |
108
+ | Front-Running/MEV | Commit-reveal, slippage protection |
109
+ | Integer Overflow | Solidity 0.8+ (careful with unchecked) |
110
+ | Access Control | Role-based access, no tx.origin |
111
+ | DoS | Pull over push, pagination |
112
+
113
+ ### Before Deployment
114
+
115
+ - [ ] Slither reports zero high/medium findings
116
+ - [ ] Fuzz tests with >100k runs
117
+ - [ ] Invariant tests for protocol properties
118
+ - [ ] Mainnet fork tests pass
119
+ - [ ] External audit completed
120
+ - [ ] Bug bounty program ready
121
+
122
+ ---
123
+
124
+ ## Gas Optimization
125
+
126
+ ### Storage Optimization
127
+
128
+ ```solidity
129
+ // Pack variables into 32-byte slots
130
+ struct UserData {
131
+ uint128 balance; // 16 bytes
132
+ uint64 lastUpdate; // 8 bytes
133
+ uint32 nonce; // 4 bytes
134
+ bool isActive; // 1 byte
135
+ // Total: 29 bytes = 1 slot
136
+ }
137
+
138
+ // Cache storage in memory
139
+ function process() external {
140
+ uint256 counter = s_counter; // Read once
141
+ for (uint256 i = 0; i < 10;) {
142
+ counter++;
143
+ unchecked { ++i; }
144
+ }
145
+ s_counter = counter; // Write once
146
+ }
147
+ ```
148
+
149
+ ### Calldata vs Memory
150
+
151
+ ```solidity
152
+ // Bad: Copies to memory
153
+ function processBad(uint256[] memory data) external { }
154
+
155
+ // Good: Read from calldata
156
+ function processGood(uint256[] calldata data) external { }
157
+ ```
158
+
159
+ ### Custom Errors
160
+
161
+ ```solidity
162
+ // Bad: String storage is expensive
163
+ require(balance >= amount, "Insufficient balance");
164
+
165
+ // Good: Custom errors are cheaper
166
+ error InsufficientBalance(uint256 requested, uint256 available);
167
+ if (balance < amount) revert InsufficientBalance(amount, balance);
168
+ ```
169
+
170
+ ---
171
+
172
+ ## Testing Strategy
173
+
174
+ ### Test Types
175
+
176
+ | Type | Coverage | Purpose |
177
+ |------|----------|---------|
178
+ | Unit | 100% branches | Individual functions |
179
+ | Fuzz | 10,000+ runs | Edge cases |
180
+ | Invariant | 10,000+ calls | System properties |
181
+ | Fork | Critical paths | Real integrations |
182
+
183
+ ### Foundry Test Example
184
+
185
+ ```solidity
186
+ function testFuzz_deposit(uint256 amount) public {
187
+ amount = bound(amount, 1, INITIAL_BALANCE);
188
+
189
+ vm.prank(user);
190
+ vault.deposit(amount, user);
191
+
192
+ assertEq(vault.balanceOf(user), amount);
193
+ }
194
+
195
+ function invariant_noShareInflation() public view {
196
+ assertGe(token.balanceOf(address(vault)), vault.totalSupply());
197
+ }
198
+ ```
199
+
200
+ ### Useful Cheatcodes
201
+
202
+ ```solidity
203
+ vm.prank(user); // Next call from user
204
+ vm.warp(block.timestamp + 1 days); // Time travel
205
+ deal(address(token), user, amount); // Set balance
206
+ vm.expectRevert(Error.selector); // Expect revert
207
+ ```
208
+
209
+ ---
210
+
211
+ ## Web3 Frontend Integration
212
+
213
+ ### Wagmi + Viem Setup
214
+
215
+ ```typescript
216
+ import { useReadContract, useWriteContract, useWaitForTransactionReceipt } from 'wagmi';
217
+
218
+ export function useDeposit() {
219
+ const { data: hash, writeContract, isPending } = useWriteContract();
220
+ const { isLoading, isSuccess } = useWaitForTransactionReceipt({ hash });
221
+
222
+ const deposit = (amount: bigint) => {
223
+ writeContract({
224
+ address: VAULT_ADDRESS,
225
+ abi: vaultAbi,
226
+ functionName: 'deposit',
227
+ args: [amount],
228
+ });
229
+ };
230
+
231
+ return { deposit, isPending, isLoading, isSuccess };
232
+ }
233
+ ```
234
+
235
+ ### Transaction States
236
+
237
+ ```typescript
238
+ type TransactionState =
239
+ | 'idle' // No transaction
240
+ | 'pending' // Waiting for wallet
241
+ | 'confirming' // In mempool
242
+ | 'confirmed' // Success
243
+ | 'failed'; // Reverted
244
+
245
+ // Always show clear feedback for each state
246
+ ```
247
+
248
+ ### Error Handling
249
+
250
+ ```typescript
251
+ import { ContractFunctionRevertedError } from 'viem';
252
+
253
+ function parseError(error: unknown): string {
254
+ if (error instanceof ContractFunctionRevertedError) {
255
+ const errorName = error.data?.errorName ?? 'Unknown';
256
+ const messages: Record<string, string> = {
257
+ InsufficientBalance: "You don't have enough balance",
258
+ SlippageExceeded: 'Price moved too much, try again',
259
+ };
260
+ return messages[errorName] ?? errorName;
261
+ }
262
+ return 'An unexpected error occurred';
263
+ }
264
+ ```
265
+
266
+ ---
267
+
268
+ ## DeFi Patterns
269
+
270
+ ### Token Standards
271
+
272
+ | Standard | Use Case |
273
+ |----------|----------|
274
+ | ERC-20 | Fungible tokens (currencies, rewards) |
275
+ | ERC-721 | NFTs (unique items) |
276
+ | ERC-1155 | Multi-token (gaming, bulk NFTs) |
277
+ | ERC-4626 | Yield-bearing vaults |
278
+
279
+ ### MEV Protection
280
+
281
+ ```solidity
282
+ function swap(
283
+ uint256 amountIn,
284
+ uint256 minAmountOut, // Slippage protection
285
+ uint256 deadline // Expiry protection
286
+ ) external {
287
+ if (block.timestamp > deadline) revert Expired();
288
+ uint256 amountOut = _calculateOutput(amountIn);
289
+ if (amountOut < minAmountOut) revert SlippageExceeded();
290
+ _executeSwap(amountIn, amountOut);
291
+ }
292
+ ```
293
+
294
+ ### Oracle Best Practices
295
+
296
+ ```solidity
297
+ // Always validate oracle data
298
+ function getPrice(address feed) public view returns (uint256) {
299
+ (, int256 price,, uint256 updatedAt,) = AggregatorV3Interface(feed).latestRoundData();
300
+
301
+ // Staleness check
302
+ if (block.timestamp - updatedAt > 1 hours) revert StalePrice();
303
+
304
+ // Sanity check
305
+ if (price <= 0) revert InvalidPrice();
306
+
307
+ return uint256(price);
308
+ }
309
+ ```
310
+
311
+ ---
312
+
313
+ ## Definition of Done
314
+
315
+ ### Smart Contract
316
+
317
+ - [ ] All functions have NatSpec documentation
318
+ - [ ] Unit tests cover all branches (>95% coverage)
319
+ - [ ] Fuzz tests for external functions
320
+ - [ ] Invariant tests for protocol properties
321
+ - [ ] Slither: zero high/medium findings
322
+ - [ ] Gas benchmarks documented
323
+ - [ ] Mainnet fork tests pass
324
+ - [ ] External audit (for mainnet)
325
+
326
+ ### Web3 Frontend
327
+
328
+ - [ ] Works with multiple wallet types
329
+ - [ ] Handles all transaction states
330
+ - [ ] Meaningful error messages
331
+ - [ ] Network switching works
332
+ - [ ] Mobile wallet compatible
333
+ - [ ] Transaction simulation before signing
334
+
335
+ ---
336
+
337
+ ## Common Pitfalls
338
+
339
+ ### 1. Trusting Spot Prices
340
+
341
+ ```solidity
342
+ // Bad: Manipulable in same transaction
343
+ uint256 price = amm.getSpotPrice();
344
+
345
+ // Good: Resistant to manipulation
346
+ uint256 price = oracle.getTwapPrice(1 hours);
347
+ ```
348
+
349
+ ### 2. Missing Slippage Protection
350
+
351
+ ```solidity
352
+ // Bad: No protection
353
+ function swap(uint256 amountIn) external;
354
+
355
+ // Good: User specifies minimum acceptable output
356
+ function swap(uint256 amountIn, uint256 minAmountOut, uint256 deadline) external;
357
+ ```
358
+
359
+ ### 3. Floating Pragma
360
+
361
+ ```solidity
362
+ // Bad
363
+ pragma solidity ^0.8.0;
364
+
365
+ // Good
366
+ pragma solidity 0.8.20;
367
+ ```
368
+
369
+ ### 4. Unbounded Loops
370
+
371
+ ```solidity
372
+ // Bad: Can run out of gas
373
+ for (uint256 i = 0; i < users.length; i++) { }
374
+
375
+ // Good: Paginated
376
+ function processBatch(uint256 start, uint256 count) external { }
377
+ ```
378
+
379
+ ---
380
+
381
+ ## Resources
382
+
383
+ - [Solidity Documentation](https://docs.soliditylang.org/)
384
+ - [OpenZeppelin Contracts](https://docs.openzeppelin.com/contracts)
385
+ - [Foundry Book](https://book.getfoundry.sh/)
386
+ - [Wagmi Documentation](https://wagmi.sh/)
387
+ - [Viem Documentation](https://viem.sh/)
388
+ - [OWASP Smart Contract Security](https://scs.owasp.org/)
389
+ - [Ethereum Security Best Practices](https://ethereum.org/en/developers/docs/smart-contracts/security/)