@ai-content-space/loopx 0.2.9 → 0.2.10

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 (99) hide show
  1. package/README.md +10 -6
  2. package/README.zh-CN.md +10 -6
  3. package/docs/loopx/design/loopx-skill-suite-v1-design.md +12 -0
  4. package/docs/loopx/plans/2026-06-15-support-lens-skills-migration.md +1153 -0
  5. package/package.json +6 -1
  6. package/plugins/loopx/.codex-plugin/plugin.json +1 -1
  7. package/plugins/loopx/skills/api-designer/SKILL.md +232 -0
  8. package/plugins/loopx/skills/api-designer/references/error-handling.md +541 -0
  9. package/plugins/loopx/skills/api-designer/references/openapi.md +824 -0
  10. package/plugins/loopx/skills/api-designer/references/pagination.md +494 -0
  11. package/plugins/loopx/skills/api-designer/references/rest-patterns.md +335 -0
  12. package/plugins/loopx/skills/api-designer/references/versioning.md +391 -0
  13. package/plugins/loopx/skills/architecture-designer/SKILL.md +117 -0
  14. package/plugins/loopx/skills/architecture-designer/references/adr-template.md +116 -0
  15. package/plugins/loopx/skills/architecture-designer/references/architecture-patterns.md +346 -0
  16. package/plugins/loopx/skills/architecture-designer/references/database-selection.md +102 -0
  17. package/plugins/loopx/skills/architecture-designer/references/nfr-checklist.md +212 -0
  18. package/plugins/loopx/skills/architecture-designer/references/system-design.md +313 -0
  19. package/plugins/loopx/skills/clarify/SKILL.md +1 -1
  20. package/plugins/loopx/skills/cli-developer/SKILL.md +124 -0
  21. package/plugins/loopx/skills/cli-developer/references/design-patterns.md +221 -0
  22. package/plugins/loopx/skills/cli-developer/references/go-cli.md +540 -0
  23. package/plugins/loopx/skills/cli-developer/references/node-cli.md +383 -0
  24. package/plugins/loopx/skills/cli-developer/references/python-cli.md +422 -0
  25. package/plugins/loopx/skills/cli-developer/references/ux-patterns.md +448 -0
  26. package/plugins/loopx/skills/debug/SKILL.md +1 -1
  27. package/plugins/loopx/skills/doc-readability/SKILL.md +1 -1
  28. package/plugins/loopx/skills/exec/SKILL.md +1 -1
  29. package/plugins/loopx/skills/final-review/SKILL.md +1 -1
  30. package/plugins/loopx/skills/finish/SKILL.md +1 -1
  31. package/plugins/loopx/skills/fix-review/SKILL.md +1 -1
  32. package/plugins/loopx/skills/go-style/SKILL.md +1 -1
  33. package/plugins/loopx/skills/kratos/SKILL.md +2 -1
  34. package/plugins/loopx/skills/plan-to-exec/SKILL.md +1 -1
  35. package/plugins/loopx/skills/refactor-plan/SKILL.md +1 -1
  36. package/plugins/loopx/skills/requirement-analyzer/SKILL.md +161 -0
  37. package/plugins/loopx/skills/requirement-analyzer/references/example-reports.md +170 -0
  38. package/plugins/loopx/skills/requirement-analyzer/references/prd-gap-checklist.md +167 -0
  39. package/plugins/loopx/skills/requirement-analyzer/references/readiness-rubric.md +70 -0
  40. package/plugins/loopx/skills/requirement-analyzer/references/report-template.md +83 -0
  41. package/plugins/loopx/skills/review/SKILL.md +1 -1
  42. package/plugins/loopx/skills/spec/SKILL.md +1 -1
  43. package/plugins/loopx/skills/sql-style/SKILL.md +108 -0
  44. package/plugins/loopx/skills/sql-style/references/database-design.md +402 -0
  45. package/plugins/loopx/skills/sql-style/references/dialect-differences.md +419 -0
  46. package/plugins/loopx/skills/sql-style/references/optimization.md +384 -0
  47. package/plugins/loopx/skills/sql-style/references/query-patterns.md +285 -0
  48. package/plugins/loopx/skills/sql-style/references/window-functions.md +328 -0
  49. package/plugins/loopx/skills/subagent-exec/SKILL.md +1 -1
  50. package/plugins/loopx/skills/tdd/SKILL.md +1 -1
  51. package/plugins/loopx/skills/verify/SKILL.md +1 -1
  52. package/scripts/verify-skills.mjs +0 -2
  53. package/skills/RESOLVER.md +8 -1
  54. package/skills/api-designer/SKILL.md +232 -0
  55. package/skills/api-designer/references/error-handling.md +541 -0
  56. package/skills/api-designer/references/openapi.md +824 -0
  57. package/skills/api-designer/references/pagination.md +494 -0
  58. package/skills/api-designer/references/rest-patterns.md +335 -0
  59. package/skills/api-designer/references/versioning.md +391 -0
  60. package/skills/architecture-designer/SKILL.md +117 -0
  61. package/skills/architecture-designer/references/adr-template.md +116 -0
  62. package/skills/architecture-designer/references/architecture-patterns.md +346 -0
  63. package/skills/architecture-designer/references/database-selection.md +102 -0
  64. package/skills/architecture-designer/references/nfr-checklist.md +212 -0
  65. package/skills/architecture-designer/references/system-design.md +313 -0
  66. package/skills/clarify/SKILL.md +1 -1
  67. package/skills/cli-developer/SKILL.md +124 -0
  68. package/skills/cli-developer/references/design-patterns.md +221 -0
  69. package/skills/cli-developer/references/go-cli.md +540 -0
  70. package/skills/cli-developer/references/node-cli.md +383 -0
  71. package/skills/cli-developer/references/python-cli.md +422 -0
  72. package/skills/cli-developer/references/ux-patterns.md +448 -0
  73. package/skills/debug/SKILL.md +1 -1
  74. package/skills/doc-readability/SKILL.md +1 -1
  75. package/skills/exec/SKILL.md +1 -1
  76. package/skills/final-review/SKILL.md +1 -1
  77. package/skills/finish/SKILL.md +1 -1
  78. package/skills/fix-review/SKILL.md +1 -1
  79. package/skills/go-style/SKILL.md +1 -1
  80. package/skills/kratos/SKILL.md +2 -1
  81. package/skills/plan-to-exec/SKILL.md +1 -1
  82. package/skills/refactor-plan/SKILL.md +1 -1
  83. package/skills/requirement-analyzer/SKILL.md +161 -0
  84. package/skills/requirement-analyzer/references/example-reports.md +170 -0
  85. package/skills/requirement-analyzer/references/prd-gap-checklist.md +167 -0
  86. package/skills/requirement-analyzer/references/readiness-rubric.md +70 -0
  87. package/skills/requirement-analyzer/references/report-template.md +83 -0
  88. package/skills/review/SKILL.md +1 -1
  89. package/skills/spec/SKILL.md +1 -1
  90. package/skills/sql-style/SKILL.md +108 -0
  91. package/skills/sql-style/references/database-design.md +402 -0
  92. package/skills/sql-style/references/dialect-differences.md +419 -0
  93. package/skills/sql-style/references/optimization.md +384 -0
  94. package/skills/sql-style/references/query-patterns.md +285 -0
  95. package/skills/sql-style/references/window-functions.md +328 -0
  96. package/skills/subagent-exec/SKILL.md +1 -1
  97. package/skills/tdd/SKILL.md +1 -1
  98. package/skills/verify/SKILL.md +1 -1
  99. package/src/install-discovery.mjs +5 -0
@@ -0,0 +1,212 @@
1
+ # Non-Functional Requirements Checklist
2
+
3
+ ## NFR Categories
4
+
5
+ ### Scalability
6
+
7
+ | Question | Common Targets | How to Measure |
8
+ |----------|----------------|----------------|
9
+ | Expected concurrent users? | 100 / 1K / 10K / 100K | Load test with realistic user sessions |
10
+ | Requests per second? | 10 / 100 / 1000 / 10000 | Throughput benchmark under load |
11
+ | Data volume? | GB / TB / PB | Current size + growth projection |
12
+ | Growth rate? | 10% / 50% / 100% per year | Historical data or business forecast |
13
+ | Peak vs average load? | 2x / 5x / 10x | Traffic analysis over time windows |
14
+
15
+ **Quantified Example**:
16
+ > The system must handle 5,000 concurrent WebSocket connections with < 100ms message delivery p95. During daily peak (09:00-11:00 UTC), traffic reaches 8x the off-peak average. The system must auto-scale within 60 seconds when QPS exceeds 2,000.
17
+
18
+ ### Performance
19
+
20
+ | Question | Common Targets | How to Measure |
21
+ |----------|----------------|----------------|
22
+ | API response time? | < 100ms / 200ms / 500ms p95 | APM percentile tracking |
23
+ | Page load time? | < 1s / 2s / 3s | Lighthouse, Core Web Vitals |
24
+ | Database query time? | < 10ms / 50ms / 100ms | Slow query log, EXPLAIN ANALYZE |
25
+ | Batch processing throughput? | 1K / 10K / 100K records/hour | Job completion time tracking |
26
+ | Cold start time? | < 500ms / 1s / 3s | First-request latency after deploy |
27
+
28
+ **Quantified Example**:
29
+ > API endpoints must respond within 200ms at p95 and 500ms at p99 under normal load (< 1000 QPS). Search queries over datasets > 1M rows must complete within 1s at p95. Background job processing must sustain 50K events/hour with < 5 minute end-to-end latency.
30
+
31
+ ### Availability
32
+
33
+ | Target | Downtime/Year | Use Case | Error Budget/Month |
34
+ |--------|---------------|----------|-------------------|
35
+ | 99% | 3.65 days | Internal tools | 7.3 hours |
36
+ | 99.9% | 8.76 hours | Business apps | 43.8 minutes |
37
+ | 99.95% | 4.38 hours | E-commerce | 21.9 minutes |
38
+ | 99.99% | 52.6 minutes | Financial systems | 4.38 minutes |
39
+ | 99.999% | 5.26 minutes | Life-critical | 26.3 seconds |
40
+
41
+ **Quantified Example**:
42
+ > The payment processing service requires 99.95% availability measured monthly. Planned maintenance windows (max 2 hours/month, announced 72h in advance) are excluded. Degraded mode (read-only, cached responses) is acceptable for up to 15 minutes before counting as downtime.
43
+
44
+ ### Security
45
+
46
+ | Question | Considerations | Verification |
47
+ |----------|----------------|--------------|
48
+ | Authentication required? | JWT, OAuth, SAML, MFA | Penetration testing, auth bypass tests |
49
+ | Authorization model? | RBAC, ABAC, ACL | Permission matrix review |
50
+ | Data sensitivity? | Public, internal, confidential, PII | Data classification audit |
51
+ | Compliance requirements? | GDPR, HIPAA, PCI DSS, SOC 2 | Compliance audit checklist |
52
+ | Encryption needs? | At rest, in transit, end-to-end | Certificate and key rotation policy |
53
+ | Secret management? | Vault, KMS, env vars | Secret scanning in CI |
54
+
55
+ **Quantified Example**:
56
+ > All PII must be encrypted at rest (AES-256) and in transit (TLS 1.3). Authentication tokens expire in 15 minutes with refresh tokens valid for 7 days. Failed login attempts are rate-limited to 5 per minute per IP. All admin actions require MFA. Secrets must rotate every 90 days.
57
+
58
+ ### Reliability
59
+
60
+ | Question | Considerations | Verification |
61
+ |----------|----------------|--------------|
62
+ | Acceptable data loss? | RPO: 0 / 1hr / 24hr | Backup restore drill |
63
+ | Recovery time target? | RTO: 1hr / 4hr / 24hr | Disaster recovery exercise |
64
+ | Backup frequency? | Real-time / hourly / daily | Backup monitoring alerts |
65
+ | Disaster recovery? | Single region / multi-region | Failover test |
66
+ | Data integrity? | Checksums, reconciliation | Periodic data validation jobs |
67
+
68
+ **Quantified Example**:
69
+ > RPO: 1 hour (max 1 hour of data loss acceptable). RTO: 30 minutes (service must recover within 30 minutes). Automated daily backups with 30-day retention. Cross-region backup replication with 6-hour lag tolerance. Monthly disaster recovery drill required.
70
+
71
+ ### Maintainability
72
+
73
+ | Question | Considerations | Verification |
74
+ |----------|----------------|--------------|
75
+ | Deployment frequency? | Daily / weekly / monthly | Deployment metrics |
76
+ | Deployment strategy? | Blue-green, canary, rolling | Rollback success rate |
77
+ | Monitoring requirements? | Logs, metrics, traces, alerts | Observability coverage audit |
78
+ | On-call requirements? | 24/7, business hours | Incident response SLA |
79
+ | Code health? | Test coverage, tech debt ratio | SonarQube or equivalent |
80
+
81
+ **Quantified Example**:
82
+ > Deploy to production at least twice per week with < 5 minute rollback capability. Zero-downtime deployments required. Alert on: error rate > 1%, p95 latency > 500ms, CPU > 80% for 5 minutes. On-call rotation with 15-minute acknowledgment SLA during business hours, 30-minute outside.
83
+
84
+ ### Cost
85
+
86
+ | Question | Considerations | Verification |
87
+ |----------|----------------|--------------|
88
+ | Infrastructure budget? | $/month, $/user, $/request | Monthly cost reports |
89
+ | Operational budget? | FTE for maintenance | Team capacity planning |
90
+ | Cost per transaction? | Target unit economics | Cost attribution per service |
91
+ | Cost optimization? | Reserved instances, spot, autoscaling | Monthly optimization review |
92
+ | Cost alerts? | Thresholds for notification | Budget alerts in cloud console |
93
+
94
+ **Quantified Example**:
95
+ > Infrastructure cost must stay below $0.001 per API request at 1M requests/day. Total monthly cloud spend must not exceed $15K for the first year. Auto-scaling must scale down within 10 minutes when load drops below 30% capacity to avoid waste.
96
+
97
+ ## NFR Priority Framework
98
+
99
+ Not all NFRs are equally important. Use this framework to prioritize.
100
+
101
+ ### Priority Matrix
102
+
103
+ | Priority | Meaning | Action |
104
+ |----------|---------|--------|
105
+ | **P0 - Must Have** | System is unusable without this | Design for it from day 1 |
106
+ | **P1 - Should Have** | Significant user/business impact | Plan in architecture, may defer implementation |
107
+ | **P2 - Nice to Have** | Improves experience but not critical | Design to not preclude, implement later |
108
+ | **P3 - Future** | Anticipated need, not current | Document for future, avoid painting into corner |
109
+
110
+ ### Common Priority Conflicts
111
+
112
+ | Conflict | Trade-off | Decision Driver |
113
+ |----------|-----------|-----------------|
114
+ | Performance vs Cost | Faster = more expensive infra | Unit economics, user tolerance |
115
+ | Availability vs Consistency | Higher availability often means eventual consistency | Data correctness requirements |
116
+ | Security vs UX | Stricter auth = more friction | Risk profile, compliance needs |
117
+ | Scalability vs Simplicity | Scale-ready = more complexity | Growth timeline, team size |
118
+ | Maintainability vs Time-to-Market | Clean code takes longer | Technical debt budget |
119
+
120
+ ### Decision Template
121
+
122
+ When two NFRs conflict, document the trade-off:
123
+
124
+ ```markdown
125
+ ## NFR Trade-off: {NFR A} vs {NFR B}
126
+
127
+ **Context**: [Why they conflict in this system]
128
+ **Decision**: Prioritize {NFR A} because [reason]
129
+ **Consequence**: {NFR B} will be limited to [specific bound]
130
+ **Mitigation**: [How we partially address the deprioritized NFR]
131
+ **Revisit When**: [Trigger for re-evaluating this trade-off]
132
+ ```
133
+
134
+ ## NFR Elicitation Questions
135
+
136
+ Use these when stakeholders haven't specified NFRs.
137
+
138
+ ### For Product Owners
139
+
140
+ 1. What happens to revenue if the system is down for 1 hour? 1 day?
141
+ 2. How many users do you expect in 6 months? 2 years?
142
+ 3. Which markets/regions must we serve? (latency, compliance implications)
143
+ 4. What is the acceptable delay for data to appear after submission?
144
+ 5. Are there regulatory requirements we must meet?
145
+
146
+ ### For Engineering Teams
147
+
148
+ 1. What is our current deployment frequency? Target?
149
+ 2. What is our error budget? How much have we consumed?
150
+ 3. What is the most expensive query/operation today?
151
+ 4. What broke last quarter? What would have prevented it?
152
+ 5. Where does the on-call team spend the most time?
153
+
154
+ ### For Security/Compliance
155
+
156
+ 1. What data classification applies to our user data?
157
+ 2. Which compliance frameworks must we satisfy?
158
+ 3. What is our threat model? Who are we defending against?
159
+ 4. What is our incident response time target?
160
+ 5. How often must secrets/certificates rotate?
161
+
162
+ ## Template
163
+
164
+ ```markdown
165
+ ## Non-Functional Requirements
166
+
167
+ ### Performance
168
+ - API response time: < 200ms p95, < 500ms p99
169
+ - Page load time: < 2s (LCP)
170
+ - Database query time: < 50ms p95
171
+ - Background job latency: < 5 min end-to-end
172
+
173
+ ### Scalability
174
+ - Concurrent users: 10,000
175
+ - Requests per second: 1,000 (peak: 5,000)
176
+ - Data volume: 1TB (growing 50%/year)
177
+ - Auto-scale trigger: CPU > 70% for 2 minutes
178
+
179
+ ### Availability
180
+ - Target: 99.9% (43.8 min downtime/month)
181
+ - RPO: 1 hour
182
+ - RTO: 30 minutes
183
+ - Degraded mode: read-only acceptable for 15 min
184
+
185
+ ### Security
186
+ - Authentication: JWT (15 min) + refresh token (7 days)
187
+ - Authorization: RBAC with tenant isolation
188
+ - Encryption: AES-256 at rest, TLS 1.3 in transit
189
+ - Compliance: GDPR, SOC 2
190
+
191
+ ### Observability
192
+ - Logging: Structured JSON, 30-day retention
193
+ - Metrics: Prometheus + Grafana, 1-year retention
194
+ - Tracing: OpenTelemetry, 7-day retention
195
+ - Alerts: PagerDuty, 15-min ack SLA
196
+
197
+ ### Cost
198
+ - Monthly budget: $15K infrastructure
199
+ - Target unit cost: < $0.001 per request
200
+ - Optimization: Reserved instances for baseline, spot for burst
201
+ ```
202
+
203
+ ## Quick Reference
204
+
205
+ | Category | Key Metric | Typical Range |
206
+ |----------|------------|---------------|
207
+ | Performance | Response time (p95) | 100ms - 500ms |
208
+ | Scalability | Concurrent users, RPS | 1K - 100K |
209
+ | Availability | Uptime percentage | 99% - 99.99% |
210
+ | Reliability | RPO, RTO | Minutes - Hours |
211
+ | Security | Compliance requirements | GDPR, SOC2, PCI |
212
+ | Cost | $/month budget | Based on unit economics |
@@ -0,0 +1,313 @@
1
+ # System Design Template
2
+
3
+ ## Design Document Structure
4
+
5
+ ```markdown
6
+ # System: {System Name}
7
+
8
+ ## Requirements
9
+
10
+ ### Functional
11
+ - [What the system must do]
12
+ - [Core features and capabilities]
13
+
14
+ ### Non-Functional
15
+ - **Performance**: Response time < 200ms p95
16
+ - **Availability**: 99.9% uptime (8.76 hours downtime/year)
17
+ - **Scalability**: Support 10,000 concurrent users
18
+ - **Security**: PCI DSS compliance required
19
+
20
+ ### Constraints
21
+ - Budget: $X/month for infrastructure
22
+ - Timeline: MVP in 3 months
23
+ - Team: 5 backend, 3 frontend engineers
24
+
25
+ ## High-Level Architecture
26
+
27
+ [Component diagram with technology choices]
28
+
29
+ ## Component Details
30
+
31
+ [Per-component: technology, responsibilities, scaling strategy]
32
+
33
+ ## Key Decisions
34
+
35
+ [Decision table with rationale]
36
+
37
+ ## Scaling Strategy
38
+
39
+ [Current → 10x → 100x growth plan]
40
+
41
+ ## Security Considerations
42
+
43
+ [Auth, encryption, compliance, rate limiting]
44
+
45
+ ## Failure Modes
46
+
47
+ [Failure scenarios with impact and mitigation]
48
+ ```
49
+
50
+ ## Capacity Estimation
51
+
52
+ ### Back-of-Envelope Framework
53
+
54
+ Before selecting technology or sizing infrastructure, estimate the system's load profile.
55
+
56
+ #### Step 1: Identify Load Drivers
57
+
58
+ | Driver | Question | Example |
59
+ |--------|----------|---------|
60
+ | Users | DAU / MAU? | 100K DAU |
61
+ | Actions | Actions per user per day? | 10 reads, 2 writes |
62
+ | Data | Bytes per action? | 1KB per read, 5KB per write |
63
+ | Growth | Monthly growth rate? | 15% |
64
+
65
+ #### Step 2: Calculate Throughput
66
+
67
+ ```
68
+ Read QPS = DAU × reads_per_user / seconds_per_day
69
+ = 100,000 × 10 / 86,400
70
+ ≈ 12 QPS (average)
71
+
72
+ Write QPS = DAU × writes_per_user / seconds_per_day
73
+ = 100,000 × 2 / 86,400
74
+ ≈ 2.3 QPS (average)
75
+
76
+ Peak QPS = average × peak_factor (typically 3x-10x)
77
+ ≈ 12 × 5 = 60 QPS (peak reads)
78
+ ```
79
+
80
+ #### Step 3: Calculate Storage
81
+
82
+ ```
83
+ Daily new data = DAU × writes_per_user × bytes_per_write
84
+ = 100,000 × 2 × 5KB = 1GB/day
85
+
86
+ Annual storage = daily × 365 × replication_factor
87
+ = 1GB × 365 × 3 = ~1TB/year
88
+
89
+ With indexes = storage × 1.3 (30% index overhead)
90
+ ≈ 1.3TB/year
91
+ ```
92
+
93
+ #### Step 4: Calculate Bandwidth
94
+
95
+ ```
96
+ Ingress = write_QPS × avg_request_size
97
+ = 2.3 × 5KB ≈ 12KB/s
98
+
99
+ Egress = read_QPS × avg_response_size
100
+ = 12 × 10KB ≈ 120KB/s (average)
101
+ = 60 × 10KB ≈ 600KB/s (peak)
102
+ ```
103
+
104
+ #### Step 5: Calculate Memory (Cache)
105
+
106
+ ```
107
+ Cache size = hot_data_percentage × total_data
108
+ = 20% × 365GB (one year) ≈ 73GB
109
+
110
+ Or by QPS: cache_entries = peak_QPS × avg_response_time × response_size
111
+ = 60 × 0.2s × 10KB ≈ 120KB active working set
112
+ ```
113
+
114
+ ### Estimation Quick Reference
115
+
116
+ | Scale | DAU | QPS (avg) | Storage/year | Typical Architecture |
117
+ |-------|-----|-----------|--------------|---------------------|
118
+ | Small | 1K | < 1 | < 10GB | Single server |
119
+ | Medium | 100K | 10-100 | 100GB-1TB | Load balancer + replicas |
120
+ | Large | 10M | 1K-10K | 10TB-100TB | Microservices + sharding |
121
+ | Massive | 1B | 100K+ | PB+ | Global distribution |
122
+
123
+ ### Common Capacity Numbers
124
+
125
+ | Resource | Typical Limit | Planning Target |
126
+ |----------|--------------|-----------------|
127
+ | Single PostgreSQL | 10K QPS | 5K QPS (headroom) |
128
+ | Single Redis | 100K QPS | 50K QPS |
129
+ | Single API server | 1K-5K req/s | 1K req/s (with business logic) |
130
+ | Network (1Gbps) | 125MB/s | 80MB/s |
131
+ | SSD IOPS | 50K-100K | 30K |
132
+
133
+ ## Load / Store / Compute Analysis
134
+
135
+ Decompose system load into three dimensions to identify bottlenecks.
136
+
137
+ ### Load (Ingress)
138
+
139
+ | Question | Analysis |
140
+ |----------|----------|
141
+ | What enters the system? | Requests, events, uploads, streams |
142
+ | What rate? | QPS, messages/sec, bytes/sec |
143
+ | What pattern? | Steady, bursty, time-of-day, seasonal |
144
+ | What size? | Request payload sizes, batch sizes |
145
+ | What validation? | Schema validation, auth, rate limits |
146
+
147
+ ### Store (Persistence)
148
+
149
+ | Question | Analysis |
150
+ |----------|----------|
151
+ | What must be durable? | Transactions, events, documents, blobs |
152
+ | What access pattern? | Random read, sequential scan, time-range |
153
+ | What consistency? | Strong, eventual, causal, read-your-writes |
154
+ | What retention? | Forever, TTL, tiered (hot/warm/cold) |
155
+ | What growth rate? | Linear, exponential, bounded |
156
+
157
+ ### Compute (Processing)
158
+
159
+ | Question | Analysis |
160
+ |----------|----------|
161
+ | What transforms data? | Business logic, aggregation, ML inference |
162
+ | What latency budget? | Sync (< 200ms), async (seconds-minutes), batch (hours) |
163
+ | What parallelism? | Independent per request, fan-out/fan-in, pipeline |
164
+ | What failure mode? | Retry, skip, dead-letter, compensate |
165
+ | What cost driver? | CPU, memory, GPU, external API calls |
166
+
167
+ ### Bottleneck Identification
168
+
169
+ ```
170
+ For each dimension, ask:
171
+ 1. What is the current capacity?
172
+ 2. What is the current utilization?
173
+ 3. At what growth rate does it saturate?
174
+ 4. What is the scaling mechanism? (vertical, horizontal, architectural change)
175
+ 5. What is the cost curve? (linear, superlinear, cliff)
176
+ ```
177
+
178
+ ## Caching Strategy Selection
179
+
180
+ ### Cache Decision Framework
181
+
182
+ ```
183
+ Should I cache this?
184
+ 1. Is it read more than written? (read:write > 3:1) → Yes
185
+ 2. Is it expensive to compute/fetch? (> 50ms) → Yes
186
+ 3. Can I tolerate stale data? → If no, consider write-through or skip cache
187
+ 4. Is the data set bounded? → If no, need eviction strategy
188
+ ```
189
+
190
+ ### Cache Patterns
191
+
192
+ | Pattern | How It Works | Best For | Risk |
193
+ |---------|-------------|----------|------|
194
+ | **Cache-Aside** | App reads cache, on miss reads DB and fills cache | General purpose | Cache stampede on cold start |
195
+ | **Read-Through** | Cache reads from DB on miss transparently | Simplify app logic | Cache becomes critical path |
196
+ | **Write-Through** | Write to cache and DB synchronously | Strong consistency | Write latency increase |
197
+ | **Write-Behind** | Write to cache, async flush to DB | Write-heavy workloads | Data loss on cache failure |
198
+ | **Refresh-Ahead** | Proactively refresh before TTL expires | Predictable hot keys | Wasted refreshes for cold keys |
199
+
200
+ ### Cache-Aside (Most Common)
201
+
202
+ ```
203
+ Read:
204
+ 1. Check cache → hit → return
205
+ 2. Miss → read DB → write to cache → return
206
+
207
+ Write:
208
+ 1. Write DB
209
+ 2. Invalidate cache (don't update — avoids race conditions)
210
+ ```
211
+
212
+ ### Cache Invalidation Strategies
213
+
214
+ | Strategy | Consistency | Complexity | Use When |
215
+ |----------|-------------|------------|----------|
216
+ | TTL-based | Eventual (bounded staleness) | Low | Staleness within TTL is acceptable |
217
+ | Event-driven invalidation | Near real-time | Medium | Write events are available |
218
+ | Write-through | Strong | Medium | Cannot tolerate stale reads |
219
+ | Versioned keys | Strong for specific version | Low | Immutable data with version |
220
+
221
+ ### Multi-Layer Caching
222
+
223
+ ```
224
+ ┌─────────┐ ┌──────────┐ ┌─────────┐ ┌──────────┐
225
+ │ Browser │────▶│ CDN │────▶│App Cache│────▶│ Database │
226
+ │ Cache │ │ (edge) │ │ (Redis) │ │ │
227
+ └─────────┘ └──────────┘ └─────────┘ └──────────┘
228
+ seconds minutes seconds source
229
+ per-user per-region per-app of truth
230
+ ```
231
+
232
+ | Layer | TTL | Scope | Invalidation |
233
+ |-------|-----|-------|-------------|
234
+ | Browser | 60s-1h | Per user | Cache-Control headers |
235
+ | CDN | 5m-24h | Per region | Purge API or TTL |
236
+ | Application (Redis) | 1m-1h | Per app cluster | Event-driven or TTL |
237
+ | Database query cache | Automatic | Per instance | On table mutation |
238
+
239
+ ### Cache Sizing
240
+
241
+ ```
242
+ Working set = unique_keys × avg_value_size × overhead_factor
243
+
244
+ Example:
245
+ 1M users × 2KB avg profile × 1.5 overhead = 3GB
246
+ → Fits in a single Redis instance (recommend 8GB for headroom)
247
+ ```
248
+
249
+ ### Anti-Patterns
250
+
251
+ | Anti-Pattern | Problem | Fix |
252
+ |---|---|---|
253
+ | Cache everything | Memory waste, cold start storms | Cache only hot, expensive, read-heavy data |
254
+ | No TTL | Stale data forever | Always set TTL, even if long |
255
+ | Update cache on write | Race condition between concurrent writes | Invalidate on write, let next read fill |
256
+ | Unbounded cache | OOM | Set max memory + eviction policy |
257
+ | Cache as primary store | Data loss on eviction/restart | Cache is acceleration, DB is truth |
258
+
259
+ ## Architecture Diagram Template
260
+
261
+ Use Mermaid for component, sequence, and deployment diagrams.
262
+
263
+ ### Component Diagram
264
+
265
+ ```mermaid
266
+ graph TD
267
+ Client[Client App] --> LB[Load Balancer]
268
+ LB --> API[API Service]
269
+ API --> Auth[Auth Service]
270
+ API --> Cache[(Redis)]
271
+ API --> DB[(PostgreSQL)]
272
+ API --> Queue[Message Queue]
273
+ Queue --> Worker[Background Worker]
274
+ Worker --> DB
275
+ Worker --> External[External APIs]
276
+ ```
277
+
278
+ ### Deployment Diagram
279
+
280
+ ```mermaid
281
+ graph TD
282
+ subgraph Region A
283
+ LB_A[Load Balancer]
284
+ subgraph AZ-1
285
+ API_1[API x2]
286
+ Worker_1[Worker x1]
287
+ end
288
+ subgraph AZ-2
289
+ API_2[API x2]
290
+ Worker_2[Worker x1]
291
+ end
292
+ DB_Primary[(DB Primary)]
293
+ DB_Replica[(DB Replica)]
294
+ Redis_A[(Redis Cluster)]
295
+ end
296
+ LB_A --> API_1
297
+ LB_A --> API_2
298
+ API_1 --> DB_Primary
299
+ API_2 --> DB_Primary
300
+ DB_Primary --> DB_Replica
301
+ ```
302
+
303
+ ## Quick Reference
304
+
305
+ | Section | Key Questions |
306
+ |---------|---------------|
307
+ | Requirements | What must it do? How well? |
308
+ | Capacity | How much load? How much data? How fast is it growing? |
309
+ | Architecture | What components? How connected? |
310
+ | Caching | What is hot? What tolerance for stale? |
311
+ | Decisions | Why these choices? What was rejected? |
312
+ | Scaling | How to grow 10x? Where is the bottleneck? |
313
+ | Failures | What can break? How to recover? What is the blast radius? |
@@ -3,7 +3,7 @@ name: clarify
3
3
  description: "Grills ambiguous loopx work until material questions are answered, then routes to spec or plan using a design gate. Not for clear implementation tasks, approved specs, or code changes."
4
4
  when_to_use: "clarify, requirements, ambiguous request, unclear scope, non-goals, decision boundaries, acceptance criteria, 需求澄清, 范围不清"
5
5
  metadata:
6
- version: "0.2.9"
6
+ version: "0.2.10"
7
7
  ---
8
8
 
9
9
  # loopx Clarify
@@ -0,0 +1,124 @@
1
+ ---
2
+ name: cli-developer
3
+ description: "Applies loopx CLI design discipline for commands, flags, human and JSON output, errors, interactivity, help text, shell behavior, and cross-platform UX. Not for replacing clarify, spec, implementation planning, code review, or workflow state transitions."
4
+ when_to_use: "cli-developer, CLI, command design, flags, JSON output, stdout stderr, interactive prompt, help text, shell completion, 命令行"
5
+ license: MIT
6
+ metadata:
7
+ version: "0.2.10"
8
+ forked_from: https://github.com/Jeffallan/claude-skills/tree/main/skills/cli-developer
9
+ maintained_by: loopx
10
+ ---
11
+
12
+ # CLI Developer
13
+
14
+ ## loopx Boundary
15
+
16
+ `cli-developer` is a support lens, not a workflow state. Use it directly when the user asks for CLI design or implementation guidance, and use it from `spec`, `exec`, `review`, or `final-review` when changes affect command behavior.
17
+
18
+ This skill does not replace `clarify`, `spec`, `plan-to-exec`, `review`, or `final-review`. If product behavior, compatibility, migration, or public CLI contract decisions are unclear, route those decisions through `clarify` or `spec`.
19
+
20
+ For loopx itself, preserve the established rule that human output is default for first-use commands and complete runtime payloads require explicit `--json`.
21
+
22
+ ## Purpose
23
+
24
+ Use this skill to design, implement, or review command-line behavior: command hierarchy, flags, arguments, help text, output contracts, errors, prompts, progress indicators, shell completions, terminal behavior, startup cost, and cross-platform UX.
25
+
26
+ It applies to Node.js, Python, Go, and other CLI stacks, but defer to the repository's existing framework and command conventions before introducing new dependencies.
27
+
28
+ ## Core Workflow
29
+
30
+ 1. **Analyze UX** — Identify the user workflows, command hierarchy, common tasks, automation paths, and first-use onboarding path.
31
+ 2. **Design commands** — Plan subcommands, flags, positional arguments, configuration sources, environment variables, and compatibility with existing command signatures.
32
+ 3. **Specify output contracts** — Decide which output is human-facing, which output is machine-readable, and how `--json`, stdout, stderr, and exit codes behave.
33
+ 4. **Implement** — Use the project's established CLI framework. After wiring commands, run representative `<cli> --help`, `<cli> --version`, success, validation-error, and non-interactive invocations.
34
+ 5. **Polish shell behavior** — Review color, TTY detection, SIGINT handling, prompt fallbacks, progress indicators, and shell completion support where the command is public or repeated-use.
35
+ 6. **Verify** — Run the relevant test suite and smoke tests on command behavior. Measure startup time against project-specific expectations when startup cost matters.
36
+
37
+ ## Reference Guide
38
+
39
+ Load detailed guidance based on context:
40
+
41
+ | Topic | Reference | Load When |
42
+ |-------|-----------|-----------|
43
+ | Design Patterns | `references/design-patterns.md` | Subcommands, flags, config, architecture |
44
+ | Node.js CLIs | `references/node-cli.md` | commander, yargs, inquirer, chalk |
45
+ | Python CLIs | `references/python-cli.md` | click, typer, argparse, rich |
46
+ | Go CLIs | `references/go-cli.md` | cobra, viper, bubbletea |
47
+ | UX Patterns | `references/ux-patterns.md` | Progress bars, colors, prompts, help text |
48
+
49
+ ## Command And Flag Discipline
50
+
51
+ - Preserve existing command signatures unless a breaking change is explicitly approved and documented.
52
+ - Prefer stable subcommands and explicit flags over mode inference that is hard to script.
53
+ - Keep flag names consistent with existing project vocabulary and common CLI conventions.
54
+ - Support `--help`; support `--version` for installable public CLIs or when the project already exposes it.
55
+ - Validate user input early and return actionable errors with a non-zero exit code.
56
+ - Treat command names, flags, positional arguments, JSON fields, and exit codes as public API once users can script against them.
57
+ - Document deprecated flags before removing them when compatibility matters.
58
+
59
+ ## Output Discipline
60
+
61
+ - Human output is the default for exploratory, onboarding, and first-use commands.
62
+ - Complete runtime payloads, state snapshots, and automation-friendly output require explicit `--json`.
63
+ - Keep stdout for requested command results. Send diagnostics, warnings, progress, logs, and prompts to stderr.
64
+ - Do not mix spinner/progress text into stdout when stdout may be piped or parsed.
65
+ - Use stable JSON schemas for `--json` output. Avoid prose in JSON fields that callers need to branch on.
66
+ - Include enough structured error data in JSON mode for automation to handle failures.
67
+ - Keep human error messages concise, specific, and action-oriented.
68
+
69
+ ## Interactivity And CI Discipline
70
+
71
+ - Do not require interactive input in CI or non-TTY contexts.
72
+ - Provide flags, environment variables, config files, or documented defaults for non-interactive operation.
73
+ - Detect TTY before enabling prompts, colors, alternate screens, spinners, or progress bars.
74
+ - When prompting, show the exact consequence of destructive or compatibility-sensitive choices.
75
+ - Respect common non-interactive signals such as `CI=1`, piped stdin/stdout, and explicit `--yes`, `--no-input`, or equivalent project conventions.
76
+ - Handle SIGINT gracefully: stop active work when possible, clean up partial local state when required, and exit with a clear message.
77
+
78
+ ## Installer And Onboarding Discipline
79
+
80
+ - First-run commands should be readable without `--json` and should not require users to know internal workflow state.
81
+ - Installer and postinstall flows must be non-interactive-safe unless the package manager or platform explicitly permits prompts.
82
+ - Avoid writing generated runtime state into the repository unless the command explicitly operates on repo-managed artifacts.
83
+ - For loopx plugin or skill installation flows, preserve mirror expectations and avoid overwriting user-edited installed copies outside the current repository.
84
+ - Keep help text and error text compatible with common terminals and package manager logs.
85
+
86
+ ## Shell And Cross-Platform Discipline
87
+
88
+ - Use platform-neutral path APIs. Do not hardcode `/`, `~`, drive letters, or shell-specific quoting.
89
+ - Avoid assuming Bash. Consider zsh, fish, PowerShell, and cmd.exe when commands are public or documented for users.
90
+ - Quote shell examples so paths with spaces work.
91
+ - Detect color support and avoid color in non-TTY output unless the project supports explicit color forcing.
92
+ - Normalize line endings and path display carefully when output may be compared in tests.
93
+ - Provide shell completions for public, repeated-use CLIs when the framework and distribution path make them maintainable. Do not require completions for every internal or one-off CLI.
94
+
95
+ ## Performance Discipline
96
+
97
+ - Keep startup work proportional to the command. Avoid loading large modules, reading network resources, or scanning large trees before argument parsing when not needed.
98
+ - Measure startup time against project-specific expectations before claiming a performance target.
99
+ - Prefer lazy loading for expensive subcommand-only dependencies.
100
+ - Stream large inputs and outputs instead of buffering unnecessarily.
101
+
102
+ ## Review Checklist
103
+
104
+ - Is the command hierarchy understandable from `--help`?
105
+ - Are flags, arguments, environment variables, and config precedence explicit?
106
+ - Are stdout and stderr separated correctly for piping and automation?
107
+ - Does `--json` return complete, stable, machine-readable payloads without human-only text?
108
+ - Does the command work in non-interactive CI and non-TTY contexts?
109
+ - Are prompts, colors, spinners, and progress indicators gated by terminal capability?
110
+ - Are errors actionable and backed by appropriate exit codes?
111
+ - Are public command signatures and JSON schemas backward-compatible or intentionally migrated?
112
+ - Are startup costs measured when startup time matters?
113
+ - Are shell examples and path handling cross-platform?
114
+
115
+ ## Output Checklist
116
+
117
+ When delivering CLI design or implementation guidance, provide:
118
+
119
+ 1. Command structure: entry point, subcommands, arguments, and flags
120
+ 2. Output contract: human output, `--json` shape, stdout/stderr behavior, and exit codes
121
+ 3. Configuration handling: config files, env vars, flags, and precedence
122
+ 4. Interactivity rules: prompts, CI behavior, defaults, and TTY behavior
123
+ 5. Shell behavior: help text, completions when applicable, colors, paths, and signal handling
124
+ 6. Verification commands: help/version smoke tests, success/error invocations, JSON-mode checks, and project tests