@sylphx/flow 0.2.13 → 1.0.1

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 (158) hide show
  1. package/CHANGELOG.md +318 -0
  2. package/LOOP_MODE.md +446 -0
  3. package/dist/index.d.ts +10 -0
  4. package/dist/index.js +59398 -698
  5. package/dist/lancedb.linux-x64-gnu-b7f0jgsz.node +0 -0
  6. package/dist/lancedb.linux-x64-musl-tgcv22rx.node +0 -0
  7. package/dist/shared/chunk-25dwp0dp.js +89 -0
  8. package/dist/shared/chunk-3pjb6063.js +208 -0
  9. package/dist/shared/chunk-4d6ydpw7.js +2854 -0
  10. package/dist/shared/chunk-4wjcadjk.js +225 -0
  11. package/dist/shared/chunk-5j4w74t6.js +30 -0
  12. package/dist/shared/chunk-5j8m3dh3.js +58 -0
  13. package/dist/shared/chunk-5thh3qem.js +91 -0
  14. package/dist/shared/chunk-6g9xy73m.js +252 -0
  15. package/dist/shared/chunk-7eq34c42.js +23 -0
  16. package/dist/shared/chunk-c2gwgx3r.js +115 -0
  17. package/dist/shared/chunk-cjd3mk4c.js +1320 -0
  18. package/dist/shared/chunk-g5cv6703.js +368 -0
  19. package/dist/shared/chunk-hpkhykhq.js +574 -0
  20. package/dist/shared/chunk-m2322pdk.js +122 -0
  21. package/dist/shared/chunk-nd5fdvaq.js +26 -0
  22. package/dist/shared/chunk-pgd3m6zf.js +108 -0
  23. package/dist/shared/chunk-qk8n91hw.js +494 -0
  24. package/dist/shared/chunk-rkkn8szp.js +16855 -0
  25. package/dist/shared/chunk-t16rfxh0.js +61 -0
  26. package/dist/shared/chunk-t4fbfa5v.js +19 -0
  27. package/dist/shared/chunk-t77h86w6.js +276 -0
  28. package/dist/shared/chunk-v0ez4aef.js +71 -0
  29. package/dist/shared/chunk-v29j2r3s.js +32051 -0
  30. package/dist/shared/chunk-vfbc6ew5.js +765 -0
  31. package/dist/shared/chunk-vmeqwm1c.js +204 -0
  32. package/dist/shared/chunk-x66eh37x.js +137 -0
  33. package/package.json +45 -93
  34. package/README.md +0 -625
  35. package/assets/agents/coder.md +0 -32
  36. package/assets/agents/orchestrator.md +0 -36
  37. package/assets/agents/reviewer.md +0 -30
  38. package/assets/agents/writer.md +0 -30
  39. package/assets/knowledge/data/sql.md +0 -216
  40. package/assets/knowledge/guides/saas-template.md +0 -85
  41. package/assets/knowledge/guides/system-prompt.md +0 -344
  42. package/assets/knowledge/guides/tech-stack.md +0 -92
  43. package/assets/knowledge/guides/ui-ux.md +0 -44
  44. package/assets/knowledge/stacks/nextjs-app.md +0 -165
  45. package/assets/knowledge/stacks/node-api.md +0 -220
  46. package/assets/knowledge/stacks/react-app.md +0 -232
  47. package/assets/knowledge/universal/deployment.md +0 -109
  48. package/assets/knowledge/universal/performance.md +0 -121
  49. package/assets/knowledge/universal/security.md +0 -79
  50. package/assets/knowledge/universal/testing.md +0 -111
  51. package/assets/output-styles/silent.md +0 -23
  52. package/assets/rules/core.md +0 -197
  53. package/assets/slash-commands/commit.md +0 -23
  54. package/assets/slash-commands/context.md +0 -112
  55. package/assets/slash-commands/explain.md +0 -35
  56. package/assets/slash-commands/mep.md +0 -63
  57. package/assets/slash-commands/review.md +0 -39
  58. package/assets/slash-commands/test.md +0 -30
  59. package/dist/assets/agents/coder.md +0 -32
  60. package/dist/assets/agents/orchestrator.md +0 -36
  61. package/dist/assets/agents/reviewer.md +0 -30
  62. package/dist/assets/agents/writer.md +0 -30
  63. package/dist/assets/knowledge/data/sql.md +0 -216
  64. package/dist/assets/knowledge/guides/saas-template.md +0 -85
  65. package/dist/assets/knowledge/guides/system-prompt.md +0 -344
  66. package/dist/assets/knowledge/guides/tech-stack.md +0 -92
  67. package/dist/assets/knowledge/guides/ui-ux.md +0 -44
  68. package/dist/assets/knowledge/stacks/nextjs-app.md +0 -165
  69. package/dist/assets/knowledge/stacks/node-api.md +0 -220
  70. package/dist/assets/knowledge/stacks/react-app.md +0 -232
  71. package/dist/assets/knowledge/universal/deployment.md +0 -109
  72. package/dist/assets/knowledge/universal/performance.md +0 -121
  73. package/dist/assets/knowledge/universal/security.md +0 -79
  74. package/dist/assets/knowledge/universal/testing.md +0 -111
  75. package/dist/assets/output-styles/silent.md +0 -23
  76. package/dist/assets/rules/core.md +0 -197
  77. package/dist/assets/slash-commands/commit.md +0 -23
  78. package/dist/assets/slash-commands/context.md +0 -112
  79. package/dist/assets/slash-commands/explain.md +0 -35
  80. package/dist/assets/slash-commands/mep.md +0 -63
  81. package/dist/assets/slash-commands/review.md +0 -39
  82. package/dist/assets/slash-commands/test.md +0 -30
  83. package/dist/chunk-01gv4qey.js +0 -4
  84. package/dist/chunk-01gv4qey.js.map +0 -11
  85. package/dist/chunk-1e8xf3f6.js +0 -27
  86. package/dist/chunk-1e8xf3f6.js.map +0 -23
  87. package/dist/chunk-3m9whg4q.js +0 -4
  88. package/dist/chunk-3m9whg4q.js.map +0 -9
  89. package/dist/chunk-3qxj0zy3.js +0 -23
  90. package/dist/chunk-3qxj0zy3.js.map +0 -11
  91. package/dist/chunk-3w6pd43t.js +0 -25
  92. package/dist/chunk-3w6pd43t.js.map +0 -61
  93. package/dist/chunk-4e5g3df9.js +0 -105
  94. package/dist/chunk-4e5g3df9.js.map +0 -27
  95. package/dist/chunk-4nm4ere4.js +0 -4
  96. package/dist/chunk-4nm4ere4.js.map +0 -11
  97. package/dist/chunk-4vrj3f8r.js +0 -26
  98. package/dist/chunk-4vrj3f8r.js.map +0 -75
  99. package/dist/chunk-5njgv5k5.js +0 -161
  100. package/dist/chunk-5njgv5k5.js.map +0 -83
  101. package/dist/chunk-67n29s4q.js +0 -7
  102. package/dist/chunk-67n29s4q.js.map +0 -10
  103. package/dist/chunk-7yyg008s.js +0 -27
  104. package/dist/chunk-7yyg008s.js.map +0 -14
  105. package/dist/chunk-86ce45n6.js +0 -3
  106. package/dist/chunk-86ce45n6.js.map +0 -10
  107. package/dist/chunk-99pz5wm0.js +0 -75
  108. package/dist/chunk-99pz5wm0.js.map +0 -12
  109. package/dist/chunk-cv1nhr27.js +0 -2
  110. package/dist/chunk-cv1nhr27.js.map +0 -9
  111. package/dist/chunk-g4baca7p.js +0 -10
  112. package/dist/chunk-g4baca7p.js.map +0 -23
  113. package/dist/chunk-gc66xe7z.js +0 -4
  114. package/dist/chunk-gc66xe7z.js.map +0 -11
  115. package/dist/chunk-hj6qtsqp.js +0 -15
  116. package/dist/chunk-hj6qtsqp.js.map +0 -10
  117. package/dist/chunk-jbd95k1f.js +0 -14
  118. package/dist/chunk-jbd95k1f.js.map +0 -20
  119. package/dist/chunk-jk1ebfqn.js +0 -23
  120. package/dist/chunk-jk1ebfqn.js.map +0 -132
  121. package/dist/chunk-kn908zkk.js +0 -4
  122. package/dist/chunk-kn908zkk.js.map +0 -10
  123. package/dist/chunk-mw13a082.js +0 -4
  124. package/dist/chunk-mw13a082.js.map +0 -10
  125. package/dist/chunk-n8vzewr3.js +0 -4
  126. package/dist/chunk-n8vzewr3.js.map +0 -12
  127. package/dist/chunk-nke51f3c.js +0 -4
  128. package/dist/chunk-nke51f3c.js.map +0 -10
  129. package/dist/chunk-ns5atzyz.js +0 -3
  130. package/dist/chunk-ns5atzyz.js.map +0 -10
  131. package/dist/chunk-q4nh3vst.js +0 -54
  132. package/dist/chunk-q4nh3vst.js.map +0 -53
  133. package/dist/chunk-q5gqgs0p.js +0 -4
  134. package/dist/chunk-q5gqgs0p.js.map +0 -10
  135. package/dist/chunk-qpej66sh.js +0 -6
  136. package/dist/chunk-qpej66sh.js.map +0 -11
  137. package/dist/chunk-s9bsh0gp.js +0 -4
  138. package/dist/chunk-s9bsh0gp.js.map +0 -10
  139. package/dist/chunk-waemzsf4.js +0 -4
  140. package/dist/chunk-waemzsf4.js.map +0 -10
  141. package/dist/chunk-wnhhwtsy.js +0 -19
  142. package/dist/chunk-wnhhwtsy.js.map +0 -11
  143. package/dist/chunk-xs370t8p.js +0 -119
  144. package/dist/chunk-xs370t8p.js.map +0 -26
  145. package/dist/chunk-xtrn4wn0.js +0 -3
  146. package/dist/chunk-xtrn4wn0.js.map +0 -10
  147. package/dist/index.js.map +0 -920
  148. package/drizzle/0000_wooden_lady_bullseye.sql +0 -52
  149. package/drizzle/0001_material_pyro.sql +0 -85
  150. package/drizzle/0002_lyrical_random.sql +0 -2
  151. package/drizzle/0003_romantic_lockjaw.sql +0 -4
  152. package/drizzle/0004_blushing_meteorite.sql +0 -6
  153. package/drizzle/meta/0000_snapshot.json +0 -310
  154. package/drizzle/meta/0001_snapshot.json +0 -906
  155. package/drizzle/meta/0002_snapshot.json +0 -920
  156. package/drizzle/meta/0003_snapshot.json +0 -920
  157. package/drizzle/meta/0004_snapshot.json +0 -921
  158. package/drizzle/meta/_journal.json +0 -41
@@ -1,216 +0,0 @@
1
- ---
2
- name: SQL & Relational DBs
3
- description: Postgres/MySQL patterns, indexing, transactions, migrations, query optimization
4
- ---
5
-
6
- # SQL & Relational Databases
7
-
8
- ## When SQL vs NoSQL
9
-
10
- **SQL (Postgres, MySQL)**: Clear relationships, ACID transactions, complex queries with joins, strong consistency, stable schema
11
-
12
- **NoSQL (MongoDB)**: Flexible schema, horizontal scaling, document data, simple queries
13
-
14
- **Default: SQL (Postgres)** - More powerful, safer for most use cases
15
-
16
- ## Schema Design
17
-
18
- ### Foreign Keys & Relationships
19
- Always use foreign keys with `ON DELETE CASCADE/SET NULL`. Prevents orphaned records.
20
-
21
- ```sql
22
- CREATE TABLE posts (
23
- id SERIAL PRIMARY KEY,
24
- user_id INTEGER REFERENCES users(id) ON DELETE CASCADE
25
- );
26
- ```
27
-
28
- ### Many-to-Many
29
- Use junction table with composite primary key to prevent duplicates:
30
-
31
- ```sql
32
- CREATE TABLE likes (
33
- user_id INTEGER REFERENCES users(id) ON DELETE CASCADE,
34
- post_id INTEGER REFERENCES posts(id) ON DELETE CASCADE,
35
- PRIMARY KEY (user_id, post_id)
36
- );
37
- ```
38
-
39
- ## Indexes
40
-
41
- ```sql
42
- -- Single column
43
- CREATE INDEX idx_posts_user_id ON posts(user_id);
44
-
45
- -- Composite (order matters!)
46
- CREATE INDEX idx_posts_user_created ON posts(user_id, created_at DESC);
47
- ```
48
-
49
- **When to index:**
50
- - ✅ Foreign keys (always), WHERE clauses, ORDER BY, JOIN conditions
51
- - ❌ Frequently changing columns (slows writes), small tables (< 1000 rows)
52
-
53
- ## Query Optimization
54
-
55
- ### N+1 Problem
56
- ```sql
57
- -- BAD: N+1 queries
58
- SELECT * FROM users;
59
- -- Then for each user:
60
- SELECT * FROM posts WHERE user_id = ?;
61
-
62
- -- GOOD: 1 query with JOIN
63
- SELECT u.*, p.id as post_id, p.title FROM users u
64
- LEFT JOIN posts p ON p.user_id = u.id;
65
- ```
66
-
67
- ### Use EXPLAIN
68
- ```sql
69
- EXPLAIN ANALYZE SELECT * FROM posts WHERE user_id = 123;
70
-
71
- -- Look for: Index Scan (good), Seq Scan (bad - full table)
72
- ```
73
-
74
- ### Pagination
75
- ```sql
76
- -- BAD: OFFSET slow for large offsets
77
- SELECT * FROM posts ORDER BY created_at LIMIT 20 OFFSET 10000;
78
- -- Reads and discards 10000 rows!
79
-
80
- -- GOOD: Cursor-based
81
- SELECT * FROM posts
82
- WHERE created_at < '2024-01-01'
83
- ORDER BY created_at DESC LIMIT 20;
84
- ```
85
-
86
- ## Transactions (ACID)
87
-
88
- **Use for**: Money transfers, inventory, related records that must stay consistent
89
-
90
- ```sql
91
- BEGIN;
92
- UPDATE accounts SET balance = balance - 100 WHERE id = 1;
93
- UPDATE accounts SET balance = balance + 100 WHERE id = 2;
94
- COMMIT; -- Both succeed or both fail
95
- ```
96
-
97
- **Isolation Levels:**
98
- - READ COMMITTED (default, good for most)
99
- - SERIALIZABLE (strongest, slowest - critical ops)
100
-
101
- ## Common Patterns
102
-
103
- **Soft Deletes**: Add `deleted_at TIMESTAMP NULL`, filter with `WHERE deleted_at IS NULL`
104
-
105
- **Timestamps**: Add `created_at`, `updated_at` with triggers for auto-update
106
-
107
- **Enums**: Use CHECK constraint or ENUM type for fixed values (status, role)
108
-
109
- ## Migrations
110
-
111
- ### Add Column (Safe)
112
- ```sql
113
- -- Safe: nullable
114
- ALTER TABLE users ADD COLUMN phone VARCHAR(20);
115
-
116
- -- Safe: with default
117
- ALTER TABLE users ADD COLUMN is_active BOOLEAN DEFAULT true;
118
- ```
119
-
120
- ### Change Column (Risky)
121
- ```sql
122
- -- Safer: Add new, migrate data, drop old
123
- ALTER TABLE users ADD COLUMN email_new VARCHAR(500);
124
- UPDATE users SET email_new = email;
125
- ALTER TABLE users DROP COLUMN email;
126
- ALTER TABLE users RENAME COLUMN email_new TO email;
127
- ```
128
-
129
- ### Add Index (Lock-Free)
130
- ```sql
131
- -- Postgres: doesn't block writes
132
- CREATE INDEX CONCURRENTLY idx_posts_user_id ON posts(user_id);
133
- ```
134
-
135
- ## Performance Tips
136
-
137
- ### Connection Pooling
138
- ```typescript
139
- const pool = new Pool({
140
- max: 20,
141
- idleTimeoutMillis: 30000,
142
- connectionTimeoutMillis: 2000
143
- })
144
-
145
- // Use pool.query(), not new Client() per request
146
- ```
147
-
148
- ### Prepared Statements (Prevent Injection)
149
- ```typescript
150
- // BAD: SQL injection vulnerable
151
- db.query(`SELECT * FROM users WHERE email = '${userInput}'`)
152
-
153
- // GOOD: Prepared
154
- db.query('SELECT * FROM users WHERE email = $1', [userInput])
155
- ```
156
-
157
- ### Batch Operations
158
- ```sql
159
- -- BAD: 1000 separate inserts
160
- INSERT INTO posts (title) VALUES ('Post 1');
161
-
162
- -- GOOD: Batch
163
- INSERT INTO posts (title) VALUES ('Post 1'), ('Post 2'), ('Post 3');
164
- ```
165
-
166
- ## Full-Text Search
167
-
168
- Add `tsvector` column, create GIN index, use `@@` operator:
169
-
170
- ```sql
171
- ALTER TABLE posts ADD COLUMN search_vector tsvector;
172
- CREATE INDEX idx_posts_search ON posts USING GIN(search_vector);
173
- SELECT * FROM posts WHERE search_vector @@ to_tsquery('react & typescript');
174
- ```
175
-
176
- ## Common Mistakes
177
-
178
- ❌ **Not using foreign keys** → Orphaned records
179
- ❌ **Not indexing foreign keys** → Slow joins
180
- ❌ **VARCHAR without limit** → Use VARCHAR(255)
181
- ❌ **Not handling NULL** → Use IS NULL, not = NULL
182
- ❌ **String concatenation** → SQL injection, use prepared statements
183
-
184
- ## ORMs (Prisma, Drizzle, TypeORM)
185
-
186
- **Pros**: Type safety, easier migrations, less SQL
187
- **Cons**: Less control, can generate inefficient SQL, overhead
188
-
189
- **Recommendation**: ORM for CRUD, raw SQL for complex queries
190
-
191
- ```typescript
192
- // Prisma
193
- const user = await prisma.user.findUnique({
194
- where: { id: 1 },
195
- include: { posts: true }
196
- })
197
-
198
- // Raw when needed
199
- const result = await prisma.$queryRaw`SELECT ... complex query ...`
200
- ```
201
-
202
- ## Monitoring
203
-
204
- **Slow Query Log**: Enable logging for queries > 100ms, identify bottlenecks
205
-
206
- **Check Index Usage**: Find unused indexes with `pg_stat_user_indexes WHERE idx_scan = 0`
207
-
208
- **Check Query Stats**: Use `pg_stat_statements` to find slow queries
209
-
210
- ## Decision Guide
211
-
212
- **Normalize vs Denormalize**: Normalize by default, denormalize for read-heavy, use materialized views for expensive aggregations
213
-
214
- **JSON column**: Flexible schema-less data (user preferences), data you won't query often. NOT for filtering/sorting.
215
-
216
- **Add index**: Column in WHERE on large table, foreign keys (always), after identifying slow queries. NOT on every column.
@@ -1,85 +0,0 @@
1
- ---
2
- name: SaaS Template
3
- description: Complete SaaS feature spec: auth, billing, multi-tenancy, compliance
4
- ---
5
-
6
- # SaaS Platform Specification
7
-
8
- Scalable, secure SaaS for modern web apps. USD wallet billing, tiered memberships, serverless SPA architecture. Prioritize security, usability, extensibility.
9
-
10
- ## Core Requirements
11
- - **Architecture**: Responsive SPA, serverless backend (Vercel/Cloudflare)
12
- - **Currency**: USD only
13
- - **Billing**: Wallet-based (Stripe), membership discounts before deductions
14
- - **Memberships**: Tiers (Small/Medium/Large) with monthly auto-top-ups, discounts, entitlements. Yearly = 10x monthly. Admin-configurable.
15
- - **Compliance**: GDPR/CCPA compliant, verifiable acceptance criteria
16
-
17
- ## Core Features
18
-
19
- ### Auth & User Management
20
- - **Auth**: Email/password, SSO (Google/OAuth), Passkey-first 2FA (SimpleWebAuthn), reCAPTCHA v3, rate limiting (5 attempts/5min)
21
- - **Sessions**: Rotating JWTs, Redis denylist, log all logins (IP, UA, timestamp)
22
- - **Security**: 2FA setup/recovery codes, email alerts for new logins/devices
23
- - **Profiles**: Display name, bio, avatar (128x128px, S3)
24
- - **Usernames**: Unique, lowercase, reserved blocks, 30-day change cooldown + audit
25
- - **Devices**: Active sessions list (IP/UA/location), one-click logout
26
-
27
- - **Invites & Referrals**: Shareable codes/links/QR with limits/expiration. Track referrals, reward wallet credits (configurable).
28
- - **Notifications**: User-configurable email/push, in-app hub with bell, unread counts, mark-read
29
- - **Activity Feed**: Log actions (recharges, spends, logins, invites, referrals) with timestamps/filters
30
-
31
- ### Billing & Wallet
32
- - **Wallet**: USD balances, Stripe top-ups (min $10), auto-deduct with tier discounts
33
- - **Memberships**: Tiers ($10/mo, $50/mo, $100/mo) with auto-top-up, % discounts, perks. Yearly = 10x. Admin CRUD.
34
- - **Invoicing**: PDF receipts, admin dashboard for search/export (CSV/PDF)
35
-
36
- ### Admin Dashboard
37
- Role-based (admin/moderator). Charts/tables for insights.
38
- - **Overview**: Metrics (date, plan, region, device), visualize revenue/users/growth
39
- - **User Management**: Search, role assignment, bans, username approval
40
- - **Billing**: Manage subscriptions/refunds, invoices, bulk adjustments
41
- - **Wallet**: Reconcile, flag anomalies (>$1000 top-up)
42
- - **Marketing**: Newsletter lists/broadcasts, track open/unsubscribe
43
- - **Invites/Referrals**: Generate codes/programs, monitor stats/rewards
44
- - **Memberships**: CRUD plans (price, top-up, discounts, entitlements)
45
- - **Notifications**: Global broadcasts (email/push)
46
- - **Support**: Ticket queue with reply/status
47
- - **Audits**: Searchable logs (user/action/timestamp), export
48
-
49
- ### Content & Support
50
- - **Knowledge Base**: Docs/FAQ (MDX)
51
- - **CMS**: Blog for announcements
52
- - **Status**: Real-time uptime/incidents, historical data
53
- - **Help**: Contact form → tickets, admin responses
54
-
55
- ### Public Pages
56
- - **Landing**: Home, Features, Pricing (SEO-optimized)
57
- - **Profiles**: /u/<username> (bio, stats, Open Graph)
58
- - **Referrals**: /r/<code> redirects with tracking
59
- - **Legal**: Terms, Privacy, Cookies. Consent banner with granular controls.
60
-
61
- ### Advanced Features
62
- - **Error Handling**: Custom 404/500, search/suggestions, auto-redirect
63
- - **Analytics**: Consent-gated GA, newsletter engagement (no PII)
64
- - **Consent**: Log agreements (user_id, type, version, timestamp, IP/UA). Version policies, granular toggles, history export/revocation.
65
-
66
- ## Legal & Compliance
67
- GDPR, CCPA, PECR. Data minimization, user rights.
68
- - **Cookies**: Banner with opt-in/out, categorize (necessary, analytics, marketing), persist in DB
69
- - **Data Rights**: Export/delete endpoints, process within 30 days (P1)
70
- - **Documentation**: MDX pages (Privacy, Terms, Cookies), version updates with notifications
71
- - **Logging**: Immutable consent/action records, audit for compliance
72
-
73
- ## Deployment
74
- Serverless for scalability, CI/CD for reliability.
75
- - **Local**: Docker Compose (web/DB/Redis). Run: `bun install && bun db:migrate && bun dev`
76
- - **Monitoring**: Sentry for errors, SLO alerts (99.9%), retry failed webhooks (3x, exponential)
77
- - **Status**: Auto-update from monitoring events
78
-
79
- ## Testing
80
- 100% coverage, enforce via CI. TDD for new features.
81
- - **Unit**: Vitest, mock externalities
82
- - **E2E**: Playwright (register → login → 2FA → top-up → consume → invoice → unsubscribe → invite → referral → ticket)
83
- - **Accessibility**: axe-core, Lighthouse A11y >95
84
- - **Performance**: Responsive, lazy loading, Iconify icons
85
- - **Quality**: Biome linting/formatting, pre-commit hooks
@@ -1,344 +0,0 @@
1
- ---
2
- name: System Prompt Writing Guide
3
- description: MEP (Minimal Effective Prompt) framework for writing high-signal, efficient prompts
4
- ---
5
-
6
- # Minimal Effective Prompt (MEP) Framework
7
-
8
- > **Core Philosophy**: Find the smallest set of high-signal tokens that maximize desired outcomes.
9
-
10
- ## Core Principles
11
-
12
- ### The Three Golden Rules
13
-
14
- **1. Trust LLM Intelligence**
15
- Modern LLMs (GPT-4, Claude Sonnet 4+):
16
- - Strong contextual reasoning and inference
17
- - Pattern generalization from 1-2 examples
18
- - Trained on common frameworks, standards, best practices
19
- - Understand semantic compression
20
-
21
- **2. Eliminate Redundancy**
22
- Each concept appears **exactly once**.
23
- - Stated in A → Don't repeat in B
24
- - Implied by X → Don't state explicitly
25
- - Common sense → Don't state at all
26
-
27
- **3. Achieve Goldilocks Zone**
28
- Balance:
29
- - Too rigid: Hardcoded if-else, excessive checklists, brittle rules
30
- - Too vague: "Be helpful", high-level platitudes, no concrete guidance
31
- - **Goldilocks**: Specific guidance + flexible heuristics
32
-
33
- ---
34
-
35
- ## The MEP Framework
36
-
37
- ### The Three Questions (For Every Token)
38
-
39
- **1. Is this UNIQUE?**
40
- - Can it be inferred from other parts?
41
- - Is it in LLM's training data?
42
- - Is it just a rewording?
43
-
44
- **2. Is this ACTIONABLE?**
45
- - Does it enable concrete behavior?
46
- - Can LLM act on this?
47
- - Is it specific enough?
48
-
49
- **3. Is this HIGH-SIGNAL?**
50
- - Does it directly impact outcome?
51
- - Is it critical to success?
52
- - Would removing it degrade performance?
53
-
54
- **Decision Matrix:**
55
- ```
56
- All 3 YES → KEEP (essential)
57
- Any 1 NO → REMOVE or MERGE
58
- All 3 NO → DELETE immediately
59
- ```
60
-
61
- ### Signal Density Target
62
-
63
- - **Good**: 60-70% high-signal
64
- - **Great**: 70-80% high-signal
65
- - **Exceptional**: 80-90% high-signal
66
-
67
- Calculate: (High-signal tokens / Total tokens) × 100%
68
-
69
- ---
70
-
71
- ## Writing Process
72
-
73
- ### Phase 1: Brain Dump
74
- Capture all requirements, rules, guidance. Don't filter. Focus on completeness.
75
-
76
- ### Phase 2: Structure
77
- Organize into logical sections:
78
- 1. Core Rules/Principles (always true)
79
- 2. Identity/Role (who is LLM)
80
- 3. Foundational Concepts (philosophy)
81
- 4. Operational Guidance (how to work)
82
- 5. Tools & Resources (available)
83
- 6. Decision Support (when unclear)
84
- 7. Standards (quality, security)
85
- 8. Anti-Patterns (what to avoid)
86
- 9. Output Format (what to deliver)
87
-
88
- ### Phase 3: Identify Redundancy
89
-
90
- **Type A - Exact Repetition**: Same concept, same wording → Keep 1st, delete all others
91
-
92
- **Type B - Semantic Repetition**: Same concept, different wording → Keep clearest
93
-
94
- **Type C - Implied Repetition**: B is logical consequence of A → Keep only A
95
-
96
- **Type D - Section Redundancy**: Entire section restates another → Delete entire section
97
-
98
- ### Phase 4: Apply The Three Questions
99
-
100
- For each section, validate against uniqueness, actionability, high-signal.
101
-
102
- **Remove common sense:**
103
- ❌ "Never commit broken code", "Use descriptive names", "Test your code"
104
-
105
- **Keep specific guidance:**
106
- ✅ "Run tests after EVERY change", "Refactor on 3rd duplication", "Extract when >20 lines"
107
-
108
- ### Phase 5: Optimize Expression
109
-
110
- **Compact Syntax:**
111
- ```
112
- ❌ "First do A, then B, then C" → ✅ "A → B → C"
113
- ❌ "Choose from: A, B, or C" → ✅ "Choose: A / B / C"
114
- ❌ "If X then Y" → ✅ "X? → Y"
115
- ❌ "Never X, never Y, never Z" → ✅ "Never: X / Y / Z"
116
- ```
117
-
118
- **List Consolidation:**
119
- - **Bullets**: Complex items needing explanation
120
- - **Commas**: Simple, parallel items
121
-
122
- **Remove Filler:**
123
- ```
124
- ❌ "You should always make sure to test" → ✅ "Always test"
125
- ❌ "It is important that you document" → ✅ "Document"
126
- ❌ "Try to choose the simplest" → ✅ "Choose simplest"
127
- ```
128
-
129
- **Merge Related Sections:**
130
- When sections are conceptually related, <50 tokens each, total merged <150 tokens.
131
-
132
- ### Phase 6: Format & Polish
133
-
134
- **Headers**: Use hierarchy (`#` > `##` > `###`), avoid excessive nesting
135
-
136
- **Emphasis**: Bold for key terms (first mention only), emoji sparingly (section markers only)
137
-
138
- **Code Blocks**: For templates, examples, specific formats only
139
-
140
- **Tables**: For comparisons and decision matrices
141
-
142
- ---
143
-
144
- ## Judgment Criteria
145
-
146
- ### What to KEEP
147
-
148
- **Unique Information:**
149
- - Custom conventions (document format, commit format, priority hierarchy)
150
- - Novel frameworks (execution modes, decision frameworks)
151
- - Specific guidance ("Refactor on 3rd duplication", "Extract when >20 lines")
152
-
153
- **Actionable Directives:**
154
- - Specific actions ("Run tests after every change", "Validate inputs at boundaries")
155
- - Clear workflows ("Analyze → Check → Assume → Implement")
156
- - Decision rules ("Ambiguous? → existing > conventions > standards")
157
-
158
- **High-Signal Examples:**
159
- 1-2 representative examples per concept (LLM generalizes)
160
-
161
- ### What to REMOVE
162
-
163
- **Redundant Content:**
164
- - Exact repetition (same concept, same wording)
165
- - Semantic repetition (same concept, different wording)
166
- - Implied content (B follows from A)
167
- - Redundant sections (duplicates another section)
168
-
169
- **Low-Signal Content:**
170
- - Common sense ("Write clean code", "Comment your code")
171
- - Vague directives ("Be thoughtful", "Think carefully", "Consider context")
172
- - Over-emphasis ("🔴 CRITICAL: MUST VERIFY" → "Verify")
173
-
174
- **Verbose Expression:**
175
- - Filler words ("You should always...", "It is important that...")
176
- - Redundant explanations (LLM infers implications)
177
-
178
- ---
179
-
180
- ## Common Pitfalls
181
-
182
- **Over-Specification**: 50+ conditional rules → Principles + heuristics instead
183
-
184
- **Repetition for Emphasis**: Stating "Never block" 4 times → State once, trust LLM
185
-
186
- **Excessive Examples**: 5+ examples of same pattern → 2 examples sufficient
187
-
188
- **Common Sense Inclusion**: Universal programming knowledge → Omit
189
-
190
- **Vague Directives**: "Be thoughtful" → Specific, actionable
191
-
192
- **Format Overload**: Too many emoji/bold/emphasis → Minimal, purposeful
193
-
194
- **Section Bloat**: 20+ tiny sections → Merge related (8-15 sections ideal)
195
-
196
- ---
197
-
198
- ## Quality Checklist
199
-
200
- ### Before Optimization
201
- - [ ] Brain dump complete
202
- - [ ] Organized into sections
203
- - [ ] All examples included
204
- - [ ] All rules documented
205
-
206
- ### During Optimization
207
- - [ ] No concept appears >1 time
208
- - [ ] Every statement passes 3 questions
209
- - [ ] Compact syntax used
210
- - [ ] Related sections merged
211
-
212
- ### After Optimization
213
- - [ ] All scenarios handleable
214
- - [ ] All frameworks fully specified
215
- - [ ] 40-60% token reduction
216
- - [ ] 75-85% signal density
217
- - [ ] 8-15 main sections
218
- - [ ] 1-2 examples per concept
219
- - [ ] Goldilocks Zone achieved (specific + flexible)
220
- - [ ] Clean, scannable formatting
221
-
222
- ---
223
-
224
- ## Decision Trees
225
-
226
- ### "Should I keep this content?"
227
- ```
228
- Is it unique (not inferable)?
229
- ├─ NO → DELETE
230
- └─ YES → Is it actionable?
231
- ├─ NO → DELETE
232
- └─ YES → Is it high-signal?
233
- ├─ NO → DELETE
234
- └─ YES → KEEP
235
- ```
236
-
237
- ### "Should I include this example?"
238
- ```
239
- How many examples already?
240
- ├─ 0 → ADD 1-2 representative
241
- ├─ 1-2 → GOOD, stop
242
- └─ 3+ → TOO MANY, remove least representative
243
- ```
244
-
245
- ### "Should I merge these sections?"
246
- ```
247
- Are they related?
248
- ├─ NO → Keep separate
249
- └─ YES → Each <50 tokens?
250
- ├─ NO → Keep separate
251
- └─ YES → Total merged <150?
252
- ├─ NO → Keep separate
253
- └─ YES → MERGE
254
- ```
255
-
256
- ---
257
-
258
- ## Practical Examples
259
-
260
- ### Example 1: Optimizing Rules
261
-
262
- **Before (110 tokens):**
263
- ```markdown
264
- ## Rule 1: Never Block On Uncertainty
265
-
266
- **IMPORTANT**: You must never stop working due to missing information...
267
-
268
- When you encounter uncertainty:
269
- 1-8. [Long list of steps]
270
-
271
- Remember: It is better to complete...
272
- ```
273
-
274
- **After (15 tokens, -86%):**
275
- ```markdown
276
- ## Rule 1: Never Block
277
-
278
- Make reasonable assumptions, document them, complete task.
279
- ```
280
-
281
- ### Example 2: Optimizing Decisions
282
-
283
- **Before (115 tokens):**
284
- ```markdown
285
- When you face an ambiguous requirement:
286
- - You should choose the most reasonable...
287
- [Multiple verbose bullet points]
288
- ```
289
-
290
- **After (30 tokens, -74%):**
291
- ```markdown
292
- **Ambiguous?** → existing patterns > conventions > standards. Document assumption.
293
- **Missing info?** → Industry defaults, make configurable.
294
- **Multiple options?** → Simplest. Note alternatives.
295
- ```
296
-
297
- ---
298
-
299
- ## Token Budget Guidelines
300
-
301
- **System Prompt Types:**
302
-
303
- | Type | Target Tokens | Max Tokens | Focus |
304
- |------|--------------|------------|-------|
305
- | Shared Protocol | 150-250 | 300 | Lightweight, universal |
306
- | Agent-Specific | 800-1200 | 1500 | Comprehensive, specialized |
307
- | Task-Specific | 300-500 | 700 | Focused, actionable |
308
-
309
- ---
310
-
311
- ## Final Validation
312
-
313
- **A great prompt should feel like:**
314
- - ✅ Well-written manual (clear, concise, complete)
315
- - ✅ Expert colleague conversation (professional, efficient)
316
- - ✅ Set of principles (guiding, not restricting)
317
-
318
- **A great prompt should NOT feel like:**
319
- - ❌ Legal terms (exhaustive, repetitive, cautious)
320
- - ❌ IKEA instructions (step-by-step, rigid, brittle)
321
- - ❌ Drill sergeant (emphasis, repetition, no trust)
322
-
323
- **The Ultimate Tests:**
324
-
325
- **Can you explain your prompt's purpose in one sentence?**
326
- - Yes → Focused ✅
327
- - No → Tries to do too much ❌
328
-
329
- **Can you identify high-signal vs noise?**
330
- - 75%+ essential → Great ✅
331
- - 50-75% essential → Good, can improve 🟡
332
- - <50% essential → Too much noise ❌
333
-
334
- **Would you want to read your prompt?**
335
- - Yes → Clean, professional, scannable ✅
336
- - No → Needs work ❌
337
-
338
- ---
339
-
340
- ## Conclusion
341
-
342
- Great prompts = **Clarity** (each concept once) + **Trust** (LLM intelligence) + **Economy** (every token earns place) + **Effectiveness** (achieve outcomes)
343
-
344
- Shorter. Clearer. More effective. 🎯