contextos-agents 2.0.0 → 2.1.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 (223) hide show
  1. package/.agents/AGENTS.md +53 -33
  2. package/.agents/adapters/aider/export.js +41 -14
  3. package/.agents/adapters/claude/export.js +54 -3
  4. package/.agents/adapters/copilot/export.js +1 -1
  5. package/.agents/adapters/cursor/export.js +1 -1
  6. package/.agents/adapters/drift-detector.js +86 -10
  7. package/.agents/adapters/gemini/export.js +1 -1
  8. package/.agents/adapters/pure-compiler.js +28 -6
  9. package/.agents/adapters/shared.js +13 -4
  10. package/.agents/adapters/zed/export.js +1 -1
  11. package/.agents/compiled/registry.v2.json +29 -25
  12. package/.agents/compiled/registry.v2.sha256 +1 -1
  13. package/.agents/core/skills/context-os/SKILL.md +34 -37
  14. package/.agents/core/skills/engineering-workflow/SKILL.md +24 -24
  15. package/.agents/core/skills/gemini-precision/EXAMPLES.md +72 -0
  16. package/.agents/core/skills/gemini-precision/SKILL.md +2 -1
  17. package/.agents/core/skills/gemini-precision/TROUBLESHOOTING.md +25 -0
  18. package/.agents/core/skills/gemini-precision/skill.yaml +2 -0
  19. package/.agents/core/skills/gstack-roles/SKILL.md +7 -6
  20. package/.agents/core/skills/security/SKILL.md +44 -16
  21. package/.agents/core/skills/security/skill.yaml +0 -1
  22. package/.agents/ctx.js +20 -14
  23. package/.agents/generated/claude/skills/context-os/SKILL.md +34 -37
  24. package/.agents/generated/claude/skills/engineering-workflow/SKILL.md +24 -24
  25. package/.agents/generated/claude/skills/gemini-precision/SKILL.md +102 -1
  26. package/.agents/generated/claude/skills/gstack-roles/SKILL.md +7 -6
  27. package/.agents/generated/claude/skills/security/SKILL.md +44 -16
  28. package/.agents/generated/gemini/skills/context-os/SKILL.md +34 -37
  29. package/.agents/generated/gemini/skills/engineering-workflow/SKILL.md +24 -24
  30. package/.agents/generated/gemini/skills/gemini-precision/SKILL.md +105 -1
  31. package/.agents/generated/gemini/skills/gstack-roles/SKILL.md +7 -6
  32. package/.agents/generated/gemini/skills/security/SKILL.md +44 -125
  33. package/.agents/plugins.js +105 -8
  34. package/.agents/profiles.js +32 -11
  35. package/.agents/resolver/canonical-resolver.js +7 -7
  36. package/.agents/validate.js +69 -1
  37. package/README.md +81 -24
  38. package/bin/commands/hook.js +167 -0
  39. package/bin/commands/scan.js +77 -0
  40. package/bin/commands.js +39 -1
  41. package/bin/index.js +151 -34
  42. package/bin/lib/gate.js +171 -0
  43. package/bin/lib/git-snapshot.js +214 -0
  44. package/bin/lib/scan.js +461 -0
  45. package/catalog/skills/adapters/EXAMPLES.md +19 -0
  46. package/catalog/skills/adapters/SKILL.md +101 -0
  47. package/catalog/skills/adapters/TROUBLESHOOTING.md +7 -0
  48. package/catalog/skills/adapters/VALIDATION.json +12 -0
  49. package/catalog/skills/adapters/skill.yaml +13 -0
  50. package/catalog/skills/api-design/EXAMPLES.md +91 -0
  51. package/catalog/skills/api-design/SKILL.md +63 -0
  52. package/catalog/skills/api-design/TROUBLESHOOTING.md +54 -0
  53. package/catalog/skills/api-design/VALIDATION.json +11 -0
  54. package/catalog/skills/api-design/skill.yaml +14 -0
  55. package/catalog/skills/architecture-diagrams/SKILL.md +108 -0
  56. package/catalog/skills/architecture-diagrams/VALIDATION.json +12 -0
  57. package/catalog/skills/architecture-diagrams/skill.yaml +9 -0
  58. package/catalog/skills/brutalist-design/EXAMPLES.md +59 -0
  59. package/catalog/skills/brutalist-design/SKILL.md +150 -0
  60. package/catalog/skills/brutalist-design/VALIDATION.json +12 -0
  61. package/catalog/skills/brutalist-design/skill.yaml +10 -0
  62. package/catalog/skills/ci-cd/EXAMPLES.md +79 -0
  63. package/catalog/skills/ci-cd/SKILL.md +69 -0
  64. package/catalog/skills/ci-cd/TROUBLESHOOTING.md +52 -0
  65. package/catalog/skills/ci-cd/VALIDATION.json +11 -0
  66. package/catalog/skills/ci-cd/skill.yaml +13 -0
  67. package/catalog/skills/database/EXAMPLES.md +74 -0
  68. package/catalog/skills/database/SKILL.md +101 -0
  69. package/catalog/skills/database/TROUBLESHOOTING.md +18 -0
  70. package/catalog/skills/database/VALIDATION.json +11 -0
  71. package/catalog/skills/database/skill.yaml +14 -0
  72. package/catalog/skills/ddd/EXAMPLES.md +42 -0
  73. package/catalog/skills/ddd/SKILL.md +247 -0
  74. package/catalog/skills/ddd/TROUBLESHOOTING.md +19 -0
  75. package/catalog/skills/ddd/VALIDATION.json +12 -0
  76. package/catalog/skills/ddd/skill.yaml +14 -0
  77. package/catalog/skills/decisions/EXAMPLES.md +35 -0
  78. package/catalog/skills/decisions/SKILL.md +90 -0
  79. package/catalog/skills/decisions/TROUBLESHOOTING.md +13 -0
  80. package/catalog/skills/decisions/VALIDATION.json +12 -0
  81. package/catalog/skills/decisions/skill.yaml +13 -0
  82. package/catalog/skills/docker/EXAMPLES.md +56 -0
  83. package/catalog/skills/docker/SKILL.md +169 -0
  84. package/catalog/skills/docker/TROUBLESHOOTING.md +18 -0
  85. package/catalog/skills/docker/VALIDATION.json +11 -0
  86. package/catalog/skills/docker/skill.yaml +13 -0
  87. package/catalog/skills/fastapi/EXAMPLES.md +36 -0
  88. package/catalog/skills/fastapi/SKILL.md +171 -0
  89. package/catalog/skills/fastapi/TROUBLESHOOTING.md +19 -0
  90. package/catalog/skills/fastapi/VALIDATION.json +12 -0
  91. package/catalog/skills/fastapi/skill.yaml +14 -0
  92. package/catalog/skills/generators/EXAMPLES.md +19 -0
  93. package/catalog/skills/generators/SKILL.md +110 -0
  94. package/catalog/skills/generators/TROUBLESHOOTING.md +7 -0
  95. package/catalog/skills/generators/VALIDATION.json +12 -0
  96. package/catalog/skills/generators/skill.yaml +22 -0
  97. package/catalog/skills/generators/templates/API.md +77 -0
  98. package/catalog/skills/generators/templates/ARCHITECTURE.md +70 -0
  99. package/catalog/skills/generators/templates/DATABASE.md +42 -0
  100. package/catalog/skills/generators/templates/DECISION.md +46 -0
  101. package/catalog/skills/generators/templates/PRD.md +67 -0
  102. package/catalog/skills/generators/templates/PROJECT_GRAPH.md +56 -0
  103. package/catalog/skills/generators/templates/ROADMAP.md +51 -0
  104. package/catalog/skills/generators/templates/TASKS.md +43 -0
  105. package/catalog/skills/generators/templates/UI.md +73 -0
  106. package/catalog/skills/graphify/EXAMPLES.md +73 -0
  107. package/catalog/skills/graphify/SKILL.md +130 -0
  108. package/catalog/skills/graphify/VALIDATION.json +12 -0
  109. package/catalog/skills/graphify/skill.yaml +13 -0
  110. package/catalog/skills/impeccable-design/EXAMPLES.md +26 -0
  111. package/catalog/skills/impeccable-design/SKILL.md +201 -0
  112. package/catalog/skills/impeccable-design/TROUBLESHOOTING.md +19 -0
  113. package/catalog/skills/impeccable-design/VALIDATION.json +12 -0
  114. package/catalog/skills/impeccable-design/skill.yaml +15 -0
  115. package/catalog/skills/interview-me/SKILL.md +97 -0
  116. package/catalog/skills/interview-me/VALIDATION.json +12 -0
  117. package/catalog/skills/interview-me/skill.yaml +9 -0
  118. package/catalog/skills/microservices/EXAMPLES.md +38 -0
  119. package/catalog/skills/microservices/SKILL.md +164 -0
  120. package/catalog/skills/microservices/TROUBLESHOOTING.md +19 -0
  121. package/catalog/skills/microservices/VALIDATION.json +12 -0
  122. package/catalog/skills/microservices/skill.yaml +14 -0
  123. package/catalog/skills/minimalist-design/EXAMPLES.md +58 -0
  124. package/catalog/skills/minimalist-design/SKILL.md +113 -0
  125. package/catalog/skills/minimalist-design/VALIDATION.json +12 -0
  126. package/catalog/skills/minimalist-design/skill.yaml +10 -0
  127. package/catalog/skills/nestjs/EXAMPLES.md +40 -0
  128. package/catalog/skills/nestjs/SKILL.md +139 -0
  129. package/catalog/skills/nestjs/TROUBLESHOOTING.md +19 -0
  130. package/catalog/skills/nestjs/VALIDATION.json +12 -0
  131. package/catalog/skills/nestjs/skill.yaml +14 -0
  132. package/catalog/skills/nextjs/EXAMPLES.md +40 -0
  133. package/catalog/skills/nextjs/SKILL.md +163 -0
  134. package/catalog/skills/nextjs/TROUBLESHOOTING.md +19 -0
  135. package/catalog/skills/nextjs/VALIDATION.json +12 -0
  136. package/catalog/skills/nextjs/skill.yaml +14 -0
  137. package/catalog/skills/node/EXAMPLES.md +80 -0
  138. package/catalog/skills/node/SKILL.md +128 -0
  139. package/catalog/skills/node/TROUBLESHOOTING.md +19 -0
  140. package/catalog/skills/node/VALIDATION.json +12 -0
  141. package/catalog/skills/node/skill.yaml +14 -0
  142. package/catalog/skills/performance/EXAMPLES.md +30 -0
  143. package/catalog/skills/performance/SKILL.md +75 -0
  144. package/catalog/skills/performance/TROUBLESHOOTING.md +19 -0
  145. package/catalog/skills/performance/VALIDATION.json +12 -0
  146. package/catalog/skills/performance/skill.yaml +14 -0
  147. package/catalog/skills/react/EXAMPLES.md +79 -0
  148. package/catalog/skills/react/SKILL.md +132 -0
  149. package/catalog/skills/react/TROUBLESHOOTING.md +19 -0
  150. package/catalog/skills/react/VALIDATION.json +12 -0
  151. package/catalog/skills/react/skill.yaml +14 -0
  152. package/catalog/skills/react-best-practices/SKILL.md +158 -0
  153. package/catalog/skills/react-best-practices/VALIDATION.json +12 -0
  154. package/catalog/skills/react-best-practices/skill.yaml +13 -0
  155. package/catalog/skills/redesign-audit/SKILL.md +117 -0
  156. package/catalog/skills/redesign-audit/VALIDATION.json +12 -0
  157. package/catalog/skills/redesign-audit/skill.yaml +9 -0
  158. package/catalog/skills/security-audit/EXAMPLES.md +79 -0
  159. package/catalog/skills/security-audit/SKILL.md +91 -0
  160. package/catalog/skills/security-audit/TROUBLESHOOTING.md +46 -0
  161. package/catalog/skills/security-audit/VALIDATION.json +11 -0
  162. package/catalog/skills/security-audit/skill.yaml +14 -0
  163. package/catalog/skills/soft-design/EXAMPLES.md +51 -0
  164. package/catalog/skills/soft-design/SKILL.md +108 -0
  165. package/catalog/skills/soft-design/VALIDATION.json +12 -0
  166. package/catalog/skills/soft-design/skill.yaml +10 -0
  167. package/catalog/skills/state-management/EXAMPLES.md +56 -0
  168. package/catalog/skills/state-management/SKILL.md +168 -0
  169. package/catalog/skills/state-management/TROUBLESHOOTING.md +18 -0
  170. package/catalog/skills/state-management/VALIDATION.json +11 -0
  171. package/catalog/skills/state-management/skill.yaml +14 -0
  172. package/catalog/skills/subagent-orchestrator/SKILL.md +117 -0
  173. package/catalog/skills/subagent-orchestrator/VALIDATION.json +12 -0
  174. package/catalog/skills/subagent-orchestrator/skill.yaml +9 -0
  175. package/catalog/skills/system-design/EXAMPLES.md +75 -0
  176. package/catalog/skills/system-design/SKILL.md +419 -0
  177. package/catalog/skills/system-design/TROUBLESHOOTING.md +19 -0
  178. package/catalog/skills/system-design/VALIDATION.json +12 -0
  179. package/catalog/skills/system-design/skill.yaml +14 -0
  180. package/catalog/skills/terraform/EXAMPLES.md +74 -0
  181. package/catalog/skills/terraform/SKILL.md +55 -0
  182. package/catalog/skills/terraform/TROUBLESHOOTING.md +53 -0
  183. package/catalog/skills/terraform/VALIDATION.json +11 -0
  184. package/catalog/skills/terraform/skill.yaml +14 -0
  185. package/catalog/skills/testing/EXAMPLES.md +122 -0
  186. package/catalog/skills/testing/SKILL.md +70 -0
  187. package/catalog/skills/testing/TROUBLESHOOTING.md +18 -0
  188. package/catalog/skills/testing/VALIDATION.json +11 -0
  189. package/catalog/skills/testing/skill.yaml +14 -0
  190. package/catalog/skills/typescript/EXAMPLES.md +64 -0
  191. package/catalog/skills/typescript/SKILL.md +112 -0
  192. package/catalog/skills/typescript/TROUBLESHOOTING.md +19 -0
  193. package/catalog/skills/typescript/VALIDATION.json +12 -0
  194. package/catalog/skills/typescript/skill.yaml +14 -0
  195. package/catalog/skills/ui-design/EXAMPLES.md +21 -0
  196. package/catalog/skills/ui-design/SKILL.md +124 -0
  197. package/catalog/skills/ui-design/TROUBLESHOOTING.md +19 -0
  198. package/catalog/skills/ui-design/VALIDATION.json +12 -0
  199. package/catalog/skills/ui-design/skill.yaml +16 -0
  200. package/catalog/skills/ui-ux-pro/EXAMPLES.md +62 -0
  201. package/catalog/skills/ui-ux-pro/SKILL.md +418 -0
  202. package/catalog/skills/ui-ux-pro/TROUBLESHOOTING.md +19 -0
  203. package/catalog/skills/ui-ux-pro/VALIDATION.json +12 -0
  204. package/catalog/skills/ui-ux-pro/skill.yaml +14 -0
  205. package/catalog/skills/ux-design/EXAMPLES.md +36 -0
  206. package/catalog/skills/ux-design/SKILL.md +116 -0
  207. package/catalog/skills/ux-design/TROUBLESHOOTING.md +19 -0
  208. package/catalog/skills/ux-design/VALIDATION.json +12 -0
  209. package/catalog/skills/ux-design/skill.yaml +16 -0
  210. package/catalog/skills/vercel-optimize/SKILL.md +83 -0
  211. package/catalog/skills/vercel-optimize/VALIDATION.json +12 -0
  212. package/catalog/skills/vercel-optimize/scripts/collect-signals.mjs +131 -0
  213. package/catalog/skills/vercel-optimize/scripts/gate-investigations.mjs +142 -0
  214. package/catalog/skills/vercel-optimize/scripts/merge-signals.mjs +143 -0
  215. package/catalog/skills/vercel-optimize/scripts/scan-codebase.mjs +174 -0
  216. package/catalog/skills/vercel-optimize/skill.yaml +15 -0
  217. package/catalog/skills/web-accessibility/EXAMPLES.md +39 -0
  218. package/catalog/skills/web-accessibility/SKILL.md +151 -0
  219. package/catalog/skills/web-accessibility/TROUBLESHOOTING.md +19 -0
  220. package/catalog/skills/web-accessibility/VALIDATION.json +12 -0
  221. package/catalog/skills/web-accessibility/skill.yaml +14 -0
  222. package/package.json +5 -2
  223. package/.agents/core/skills/security/security.md +0 -106
@@ -25,7 +25,7 @@ Activate whenever writing authentication, authorization, session management, dat
25
25
 
26
26
  #### 1. Injection (SQL, NoSQL, Command)
27
27
 
28
- - Always use parameterized queries — never concatenate user input into SQL or shell commands.
28
+ - Always use parameterized queries - never concatenate user input into SQL or shell commands.
29
29
  - Use ORMs (Prisma, Drizzle, SQLAlchemy) with strict schema validation.
30
30
  - Validate and sanitize all user input before processing.
31
31
 
@@ -74,14 +74,20 @@ When building AI workflows, tools, or MCP servers:
74
74
  - Never allow untrusted content to override system instructions or tool execution permissions.
75
75
  2. **Tool Execution Boundaries**:
76
76
  - Destructive operations (database drops, file deletions, payment triggers) MUST require explicit user confirmation.
77
- - Restrict file system tools to the workspace root — block directory traversal (`../`).
77
+ - Restrict file system tools to the workspace root - block directory traversal (`../`).
78
78
  3. **Secret Masking & Output Sanitization**:
79
79
  - Scrub API keys (`sk-...`, `Bearer ...`), tokens, and credentials before writing to agent logs or step summaries.
80
+ 4. **Sandbox Execution & Write Isolation (Supply-Chain Defense)**:
81
+ - Target code is inspected strictly read-only; never execute target-controlled builds or tests with write access to the repository root.
82
+ - Restrict process write boundaries strictly to an isolated temporary `scratch/` directory.
83
+ - Enforce zero outbound external network access during security audits to prevent secret exfiltration via malicious scripts or dependencies.
84
+ - Promote verified non-secret results to retained `artifacts/` only via trusted parent-side inspection code.
80
85
 
81
86
  ---
82
87
 
83
88
  ## Code Examples
84
89
 
90
+
85
91
  ### Timing-Safe Secret Verification
86
92
 
87
93
  ```javascript
@@ -97,28 +103,50 @@ export function verifyWebhookSignature(payload, signature, secret) {
97
103
  }
98
104
  ```
99
105
 
100
- ### Safe SSRF Prevention Wrapper
106
+ ### SSRF Prevention Requirements (OWASP Compliant)
101
107
 
102
- ```typescript
103
- import dns from 'node:dns/promises';
108
+ Per [OWASP SSRF Prevention Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Server_Side_Request_Forgery_Prevention_Cheat_Sheet.html), naive application-level DNS pre-checks followed by standard `fetch(url)` are fundamentally flawed due to DNS rebinding (TOCTOU) and unvalidated HTTP 3xx redirects.
109
+
110
+ #### Mandatory Architectural Controls
104
111
 
105
- export async function validateSafeUrl(urlString: string): Promise<URL> {
112
+ 1. **Network-Layer Defense (Primary)**: For user-supplied arbitrary webhooks or URLs, route all outbound traffic through an isolated egress forward proxy (e.g., Smokescreen, Envoy, Squid) configured with firewall-level IP filters blocking RFC 1918, RFC 6598, link-local (`169.254.169.254`), loopback, and IPv6 local addresses at the socket handshake level.
113
+ 2. **Positive Destination Allowlist**: If fetching from known external partners, validate destination hostname against a strict positive allowlist.
114
+ 3. **Disable Automatic Redirects**: Always set `redirect: 'error'` or `'manual'`. Never follow HTTP redirects automatically without re-validating the target URL against allowlist rules.
115
+ 4. **Protocol & Credential Restrictions**: Enforce `https:` exclusively; reject embedded credentials (`user:pass@host`) and non-standard ports.
116
+
117
+ ```typescript
118
+ /**
119
+ * Verified Allowlist-based HTTP Client (OWASP SSRF Prevention)
120
+ * Enforces HTTPS, strict destination allowlist, and rejects HTTP redirects.
121
+ */
122
+ export async function fetchFromAllowlist(
123
+ urlString: string,
124
+ allowedHostnames: ReadonlySet<string>,
125
+ options: RequestInit = {}
126
+ ): Promise<Response> {
106
127
  const parsed = new URL(urlString);
128
+
129
+ // 1. Enforce HTTPS only
107
130
  if (parsed.protocol !== 'https:') {
108
- throw new Error('Only HTTPS protocol is permitted');
131
+ throw new Error(`SSRF blocked: protocol "${parsed.protocol}" is not permitted; HTTPS required`);
132
+ }
133
+
134
+ // 2. Reject credentials in URL
135
+ if (parsed.username || parsed.password) {
136
+ throw new Error('SSRF blocked: URL credentials (user:password@host) are prohibited');
109
137
  }
110
138
 
111
- const { address } = await dns.lookup(parsed.hostname);
112
- if (
113
- address.startsWith('127.') ||
114
- address.startsWith('10.') ||
115
- address.startsWith('192.168.') ||
116
- address === '169.254.169.254'
117
- ) {
118
- throw new Error('Access to private/metadata IP addresses is blocked');
139
+ // 3. Strict positive destination allowlist (prevents internal network probing)
140
+ const normalizedHost = parsed.hostname.toLowerCase();
141
+ if (!allowedHostnames.has(normalizedHost)) {
142
+ throw new Error(`SSRF blocked: destination host "${normalizedHost}" is not in the approved allowlist`);
119
143
  }
120
144
 
121
- return parsed;
145
+ // 4. Disable automatic redirects to prevent redirection to private IPs or metadata endpoints
146
+ return fetch(urlString, {
147
+ ...options,
148
+ redirect: 'error'
149
+ });
122
150
  }
123
151
  ```
124
152
 
@@ -7,11 +7,11 @@ description: >
7
7
 
8
8
  ## Overview
9
9
 
10
- Deterministic context compiler and policy engine for AI coding agents. Standardizes software engineering workflows across requirements, architecture, atomic task planning, implementation, verification, and release.
10
+ Deterministic context compiler and policy engine for AI coding agents. Governs repository policy configuration, skill dependency graphs, profile management, and multi-agent configuration export.
11
11
 
12
12
  ## When to Use
13
13
 
14
- Activate as the root meta-orchestrator across all development phases to ensure role consistency, quality gates, and structured execution.
14
+ Activate when managing project configuration, resolving skill dependencies, compiling rules for editors, or defining repository-level agent standards. (For task-specific file and context budgeting, use `context-manager`).
15
15
 
16
16
  ## Rules & Patterns
17
17
 
@@ -45,10 +45,10 @@ intent:
45
45
  For each required layer, load the skill graph:
46
46
 
47
47
  1. Read `skill.yaml` from each relevant skill directory
48
- 2. Resolve `requires` — load mandatory dependencies
49
- 3. Check `conflicts` — ensure no incompatible skills are loaded
50
- 4. Apply `optional` — suggest but don't force
51
- 5. Respect project profile (if set) — apply rules from `profiles/`
48
+ 2. Resolve `requires` - load mandatory dependencies
49
+ 3. Check `conflicts` - ensure no incompatible skills are loaded
50
+ 4. Apply `optional` - suggest but don't force
51
+ 5. Respect project profile (if set) - apply rules from `profiles/`
52
52
 
53
53
  **Dependency resolution example:**
54
54
 
@@ -66,48 +66,45 @@ Suggested: [tailwind, prisma, next-auth]
66
66
 
67
67
  Assemble context from three levels:
68
68
 
69
- **Level 1 — Vision (always available):**
69
+ **Level 1 - Vision (always available):**
70
70
 
71
- - `docs/PRD.md` — what are we building
72
- - `docs/ROADMAP.md` — where are we going
73
- - `docs/PROJECT_GRAPH.md` — project structure
71
+ - `docs/PRD.md` - what are we building
72
+ - `docs/ROADMAP.md` - where are we going
73
+ - `docs/PROJECT_GRAPH.md` - project structure
74
+ - `docs/API.md` - API specification (optional, when backend API layer is present)
75
+ - `docs/UI.md` - UI/UX specification (optional, when UI layer is present)
74
76
 
75
- **Level 2 — Architecture (load when needed):**
77
+ **Level 2 - Architecture (load when needed):**
76
78
 
77
- - `docs/ARCHITECTURE.md` — system design
78
- - `docs/DATABASE.md` — data model
79
- - `docs/API.md` — API contracts
80
- - `docs/decisions/` — prior decisions
79
+ - `docs/ARCHITECTURE.md` - system design and boundaries
80
+ - `docs/decisions/` - architecture decision records (ADRs)
81
+ - `docs/PRODUCT_BOUNDARIES.md` - maturity boundaries and non-promises
82
+ - `references/context-rules.md` - dynamic context selection and compilation rules
81
83
 
82
- **Level 3 — Development (load per task):**
84
+ **Level 3 - Task-Specific Context (load per task):**
83
85
 
84
- - Relevant skill `.md` files
85
- - `docs/UI.md` — for frontend tasks
86
- - `docs/TASKS.md` — current sprint
86
+ - Relevant skill documents from `.agents/skills/`
87
+ - Target code and test files within planned blast radius
87
88
 
88
- **Context Filtering Rules:**
89
- See `references/context-rules.md` for the full mapping of task types to required documents.
89
+ ### Stage 4: Focused Context Selection
90
90
 
91
- ### Stage 4: Prompt Optimization
91
+ Before sending context to the AI coding assistant:
92
92
 
93
- Before sending to the AI agent:
93
+ 1. Select only skills relevant to the task domain and touched files
94
+ 2. Prioritize: task goal > architectural constraints > project conventions
95
+ 3. Include active Decision Records that affect the target component
96
+ 4. Enforce quality guardrails and verification criteria
94
97
 
95
- 1. Remove sections not relevant to the current task
96
- 2. Prioritize: current task context > architecture > vision
97
- 3. Include recent Decision Records that affect the current task
98
- 4. Add coding rules from the loaded skills
99
-
100
- ## Commands
98
+ ## Core CLI Commands
101
99
 
102
100
  | Command | Action |
103
101
  | --- | --- |
104
- | `ctx init` | Analyze project idea, generate all docs |
105
- | `ctx plan` | Generate development plan from PRD |
106
- | `ctx compile` | Compile context for a specific task |
107
- | `ctx update` | Update changed documents |
108
- | `ctx graph` | Show/update Project Graph |
109
- | `ctx doctor` | Validate skill dependencies, check for conflicts |
110
- | `ctx explain` | Explain why specific context was loaded |
102
+ | `contextos init` | Initialize `.agents/` folder and bootstrap profiles |
103
+ | `contextos export <agent>` | Compile skills for target agent (`gemini`, `claude`, `cursor`, `copilot`, `aider`, `zed`, `all`) |
104
+ | `contextos resolve "<task>"` | Dynamically resolve relevant skills, rules, and risk level for task |
105
+ | `contextos validate` | Validate skill schemas, dependencies, and detect configuration drift |
106
+ | `contextos doctor` | Pre-flight diagnostics for skills, profiles, and compiler synchronization |
107
+ | `contextos watch` | Background file watcher for continuous auto-compilation |
111
108
 
112
109
  ## Project Initialization Flow
113
110
 
@@ -125,7 +122,7 @@ When user says something like "Сделай CRM для стоматологии"
125
122
  3. **Select profile** (startup/enterprise/mvp/hackathon)
126
123
  4. **Resolve skills** (Stage 2)
127
124
  5. **Generate all documents** using `generators/` skill
128
- 6. **Create Project Graph** — the master map of modules → features → tasks → files → skills
125
+ 6. **Create Project Graph** - the master map of modules -> features -> tasks -> files -> skills
129
126
  7. **Output agent config** using `adapters/` skill
130
127
 
131
128
  ## Skill Discovery
@@ -42,7 +42,7 @@ Inspired by [addyosmani/agent-skills](https://github.com/addyosmani/agent-skills
42
42
 
43
43
  ---
44
44
 
45
- ### Phase 1: DEFINE — /spec
45
+ ### Phase 1: DEFINE - /spec
46
46
 
47
47
  **Auto-activates → `[ROLE: Product Manager]`**
48
48
 
@@ -76,8 +76,8 @@ Before writing the spec, if there is ambiguity, high blast radius, or multiple a
76
76
  ### Technical Approach
77
77
  [Read the relevant code. Understand what changes where.]
78
78
  Files affected:
79
- - `src/X.js` — [what changes]
80
- - `src/Y.js` — [what changes]
79
+ - `src/X.js` - [what changes]
80
+ - `src/Y.js` - [what changes]
81
81
 
82
82
  ### Acceptance Criteria
83
83
  - [ ] Given [context], when [action], then [result]
@@ -90,7 +90,7 @@ Files affected:
90
90
 
91
91
  ---
92
92
 
93
- ### Phase 2: PLAN — /plan
93
+ ### Phase 2: PLAN - /plan
94
94
 
95
95
  **Auto-activates → `[ROLE: Architect]`**
96
96
 
@@ -108,7 +108,7 @@ Organize tasks as **Thin Vertical Slices** rather than horizontal layers:
108
108
  - Each task must be **completable in < 2 hours** of focused work.
109
109
  - Each task must be **independently testable**.
110
110
  - Tasks must be **ordered by dependency** (blocking tasks first).
111
- - Each task gets a **test requirement** — no task without a test.
111
+ - Each task gets a **test requirement** - no task without a test.
112
112
 
113
113
  #### Plan Template
114
114
 
@@ -133,13 +133,13 @@ Organize tasks as **Thin Vertical Slices** rather than horizontal layers:
133
133
  - [Risk 1]: [Mitigation]
134
134
  - [Risk 2]: [Mitigation]
135
135
 
136
- ### STOP — Awaiting Approval
136
+ ### STOP - Awaiting Approval
137
137
  Do not proceed to BUILD until this plan is approved.
138
138
  ```
139
139
 
140
140
  ---
141
141
 
142
- ### Phase 3: BUILD — /build
142
+ ### Phase 3: BUILD - /build
143
143
 
144
144
  **Auto-activates → `[ROLE: Senior Developer]`**
145
145
 
@@ -147,12 +147,12 @@ Implement one task at a time. Commit after each task.
147
147
 
148
148
  #### Build Rules
149
149
 
150
- 1. **One task per commit** — atomic, descriptive commit messages.
151
- 2. **Write the test FIRST** (TDD — red-green-refactor).
152
- 3. **No dead code** — if it's not tested, it's not shipped.
153
- 4. **No TODOs in committed code** — resolve or create a tracked issue.
154
- 5. **Read before writing** — understand the surrounding code before changing it.
155
- 6. **Limit the blast radius** — modify ONLY the files explicitly listed in the current task's plan. Do NOT rewrite adjacent components, hooks, or utilities unless strictly required AND approved.
150
+ 1. **One task per commit** - atomic, descriptive commit messages.
151
+ 2. **Write the test FIRST** (TDD - red-green-refactor).
152
+ 3. **No dead code** - if it's not tested, it's not shipped.
153
+ 4. **No TODOs in committed code** - resolve or create a tracked issue.
154
+ 5. **Read before writing** - understand the surrounding code before changing it.
155
+ 6. **Limit the blast radius** - modify ONLY the files explicitly listed in the current task's plan. Do NOT rewrite adjacent components, hooks, or utilities unless strictly required AND approved.
156
156
 
157
157
  #### Commit Message Format
158
158
 
@@ -169,7 +169,7 @@ Types: `feat`, `fix`, `refactor`, `test`, `docs`, `chore`
169
169
 
170
170
  ---
171
171
 
172
- ### Phase 4: VERIFY — /test
172
+ ### Phase 4: VERIFY - /test
173
173
 
174
174
  **Auto-activates → `[ROLE: QA Lead]`**
175
175
 
@@ -190,7 +190,7 @@ Tests are proof, not an afterthought.
190
190
 
191
191
  For complex React components, prioritize testing _user behavior_ over internal state:
192
192
 
193
- - Use **React Testing Library** (`userEvent`, `screen.getByRole`) — test what the user sees.
193
+ - Use **React Testing Library** (`userEvent`, `screen.getByRole`) - test what the user sees.
194
194
  - Use **Playwright** for critical user flows (login, checkout, form submit).
195
195
  - Do NOT test implementation details (internal state, private methods, component structure).
196
196
  - Focus on: "When user clicks X, does Y appear?" not "Does `useState` hold the right value?"
@@ -217,7 +217,7 @@ Before moving to Review, verify:
217
217
 
218
218
  ---
219
219
 
220
- ### Phase 5: REVIEW — /review
220
+ ### Phase 5: REVIEW - /review
221
221
 
222
222
  **Auto-activates → `[ROLE: Staff Engineer]` + `[ROLE: Senior Designer]` for UI tasks**
223
223
 
@@ -237,7 +237,7 @@ Inspired by [obra/superpowers](https://github.com/obra/superpowers):
237
237
 
238
238
  ---
239
239
 
240
- ### Phase 5.5: SIMPLIFY — /simplify
240
+ ### Phase 5.5: SIMPLIFY - /simplify
241
241
 
242
242
  **Auto-activates → `[ROLE: Staff Engineer]` (Ponytail Mindset)**
243
243
 
@@ -250,7 +250,7 @@ Before merging, ruthlessly simplify:
250
250
 
251
251
  ---
252
252
 
253
- ### Phase 6: SHIP — /ship
253
+ ### Phase 6: SHIP - /ship
254
254
 
255
255
  **Auto-activates → `[ROLE: Release Engineer]`**
256
256
 
@@ -264,8 +264,7 @@ Only ship when all gates are green.
264
264
  - [ ] Docs updated (README, API docs, changelogs)
265
265
  - [ ] Breaking changes documented
266
266
  - [ ] Rollback plan exists
267
- - [ ] Vercel Preview Deployment is successful and manually verified
268
- - [ ] Core Web Vitals pass in preview (LCP < 2.5s, CLS < 0.1, INP < 200ms)
267
+ - [ ] Preview / staging deployment verified (if applicable, e.g. Vercel Preview and Core Web Vitals for frontend deployments)
269
268
 
270
269
  #### Operational Self-Improvement
271
270
 
@@ -308,6 +307,7 @@ export async function POST(req) {
308
307
  - [ ] Implementation plan broken down into vertical tasks < 2 hours each.
309
308
  - [ ] Tests written before implementation (TDD/BDD).
310
309
  - [ ] Code reviewed against correctness, security, performance, and design gates.
310
+ - [ ] Staged security and quality check passes (`contextos scan --staged --enforce`).
311
311
  - [ ] Simplification ladder executed before shipping.
312
312
 
313
313
  ---
@@ -334,10 +334,10 @@ export async function POST(req) {
334
334
 
335
335
  When completing a task or workflow, you must explicitly report your final status as the last part of your output:
336
336
 
337
- - **DONE** — completed with evidence.
338
- - **DONE_WITH_CONCERNS** — completed, but list concerns.
339
- - **BLOCKED** — cannot proceed; state blocker and what was tried.
340
- - **NEEDS_CONTEXT** — missing info; state exactly what is needed.
337
+ - **DONE** - completed with evidence.
338
+ - **DONE_WITH_CONCERNS** - completed, but list concerns.
339
+ - **BLOCKED** - cannot proceed; state blocker and what was tried.
340
+ - **NEEDS_CONTEXT** - missing info; state exactly what is needed.
341
341
 
342
342
 
343
343
  <!-- Source: EXAMPLES.md -->
@@ -48,6 +48,7 @@ Activate whenever:
48
48
  1. Run the project validator or compiler (`node .agents/ctx.js validate`, `tsc --noEmit`, etc.).
49
49
  2. Run unit and integration tests (`npm test`, `pytest`, etc.).
50
50
  3. Run linter and formatting checks (`npm run lint:md`, `eslint`, etc.).
51
+ 4. Run staged security and quality scanner (`contextos scan --staged --enforce`).
51
52
  - If a test or validation fails, do not guess: read the exact error trace, fix the root cause, and re-run until green.
52
53
 
53
54
  ### 4. Surgical Blast Radius Containment
@@ -83,7 +84,7 @@ Activate whenever:
83
84
  **Eliminate the "black box" by narrating technical decisions.**
84
85
 
85
86
  - Avoid executing long, silent chains of tool calls without user visibility.
86
- - Provide a concise 1–2 sentence transparent status update before key operations:
87
+ - Provide a concise 1-2 sentence transparent status update before key operations:
87
88
  - State what was inspected or verified from the code.
88
89
  - State the architectural decision made and the immediate next action.
89
90
  - Keep narration crisp and actionable without excessive verbosity.
@@ -169,3 +170,106 @@ export async function updateUser(id, data, session) {
169
170
  - Enforces the 7-rung ladder of `ponytail-mindset`.
170
171
  - Acts as the baseline behavioral guardrail across all Gemini and Antigravity operations.
171
172
 
173
+
174
+ <!-- Source: EXAMPLES.md -->
175
+
176
+ # gemini-precision Examples - Anti-patterns vs ContextOS Standard
177
+
178
+ ## Example 1: Read-Before-Write Invariant (Zero Assumptions)
179
+
180
+ ### Anti-pattern: Hallucinated Import and Signature
181
+
182
+ ```typescript
183
+ // BAD: Assuming the module exists and export is a default function
184
+ import hashPassword from 'src/utils/crypto';
185
+ const hash = hashPassword(password);
186
+ ```
187
+
188
+ ### Best practice: ContextOS Standard (Inspected Active Codebase First)
189
+
190
+ ```typescript
191
+ // GOOD: Inspected src/lib/auth.ts via view_file before writing code
192
+ import { hashSecret, ARGON2_CONFIG } from '../lib/auth.js';
193
+ const hash = await hashSecret(password, ARGON2_CONFIG);
194
+ ```
195
+
196
+ ---
197
+
198
+ ## Example 2: Zero-Placeholder Invariant (Complete Code Only)
199
+
200
+ ### Anti-pattern: Lazy Stubs and Ellipsis Comments
201
+
202
+ ```typescript
203
+ // BAD: Emitting incomplete code with TODOs and ellipsis
204
+ export function processTransaction(tx: Transaction) {
205
+ // TODO: validate transaction balance
206
+ // ... rest of implementation stays here ...
207
+ return { status: 'ok' };
208
+ }
209
+ ```
210
+
211
+ ### Best practice: ContextOS Standard (100% Drop-in Compilable)
212
+
213
+ ```typescript
214
+ // GOOD: Fully implemented logic with complete error handling
215
+ export function processTransaction(tx: Transaction): TransactionResult {
216
+ if (!tx.amount || tx.amount <= 0) {
217
+ throw new ValidationError('Transaction amount must be positive');
218
+ }
219
+ if (tx.senderBalance < tx.amount) {
220
+ throw new InsufficientFundsError(tx.senderId, tx.amount);
221
+ }
222
+ return {
223
+ status: 'ok',
224
+ transactionId: tx.id,
225
+ newBalance: tx.senderBalance - tx.amount,
226
+ };
227
+ }
228
+ ```
229
+
230
+ ---
231
+
232
+ ## Example 3: Mandatory Proof-of-Work Invariant
233
+
234
+ ### Anti-pattern: Claiming Task Complete Without Evidence
235
+
236
+ ```text
237
+ BAD: "I have updated the authentication handler. The code looks correct and is ready to merge."
238
+ ```
239
+
240
+ ### Best practice: ContextOS Standard (Verified with Automated Gates)
241
+
242
+ ```bash
243
+ # GOOD: Run test suite, staged scanner, and consistency checks
244
+ npm test
245
+ contextos scan --staged --enforce
246
+ node .agents/ctx.js validate
247
+ ```
248
+
249
+ <!-- Source: TROUBLESHOOTING.md -->
250
+
251
+ # gemini-precision Troubleshooting & Common Failure Modes
252
+
253
+ ## 1. Test Failure Investigation (No Guesswork)
254
+
255
+ - **Symptom**: Test fails during `npm test` after code modifications.
256
+ - **Root Cause**: Trying to patch the code without reading the exact assertion diff.
257
+ - **Fix**: Never guess the fix. View the test file line where assertion failed, inspect expected vs actual output, and resolve the root discrepancy.
258
+
259
+ ## 2. Accidental Staged Secrets or Placeholders
260
+
261
+ - **Symptom**: `contextos scan --staged --enforce` fails with exit code 1.
262
+ - **Root Cause**: Committed temporary `.env` file or left an unfinished `// TODO: implement later` stub in added lines.
263
+ - **Fix**: Remove or redact the secret before committing. Fully implement the logic or replace the placeholder with an explicit tracked issue rather than committed code stubs.
264
+
265
+ ## 3. Scope Creep and Excessive Blast Radius
266
+
267
+ - **Symptom**: Unrelated files reformatted or imports reordered across the repository.
268
+ - **Root Cause**: Full-file rewrite instead of targeted surgical replacement.
269
+ - **Fix**: Use targeted chunks that touch only the lines specified in the task plan. Avoid modifying unrelated styling or formatting.
270
+
271
+ ## 4. Forbidden Long Dashes
272
+
273
+ - **Symptom**: Linter or compliance check flags unicode dashes in text.
274
+ - **Root Cause**: Using typography dashes (`\u2014` or `\u2013`) instead of standard ASCII hyphens.
275
+ - **Fix**: Replace all em-dashes and en-dashes with standard ASCII hyphens (` - `) or appropriate punctuation (parentheses, commas, colons).
@@ -15,7 +15,7 @@ Activate on every task to declare explicit specialist role and mindset before be
15
15
 
16
16
  ## Rules & Patterns
17
17
 
18
- Inspired by [Garry Tan's gstack](https://github.com/garrytan/gstack) — shipping 810× more logical code than a solo dev in 2013.
18
+ Inspired by [Garry Tan's gstack](https://github.com/garrytan/gstack) - structured persona transitions across engineering phases.
19
19
 
20
20
  ## Core Principle
21
21
 
@@ -23,13 +23,14 @@ Inspired by [Garry Tan's gstack](https://github.com/garrytan/gstack) — shippin
23
23
 
24
24
  ## Role Identification Protocol
25
25
 
26
- At the start of each task or major phase switch, declare your role:
26
+ At the start of each task or major phase switch, declare your role using the ContextOS standard format:
27
27
 
28
- ```
29
- [ROLE: <Role Name>] — <One-line description of your mandate for this task>
28
+ ```text
29
+ [DOMAIN: <Domain>] [PHASE: <Phase>] [ROLE: <Role Name>]
30
+ Skills loaded: <skill-1>, <skill-2>
30
31
  ```
31
32
 
32
- > **Anti-Spam Invariant**: Declare this role **strictly once per phase**. Never prefix intermediate tool calls, file operations, or step updates with role tags.
33
+ > **Anti-Spam Invariant**: Declare this role header **strictly once per phase**. Never prefix intermediate tool calls, file operations, or step updates with role tags.
33
34
 
34
35
  Then execute ONLY within the constraints of that role.
35
36
 
@@ -108,7 +109,7 @@ THINK PLAN BUILD REVIEW TEST SHIP
108
109
  2. **One role at a time.** Don't mix QA and implementation in the same response.
109
110
  3. **Declare before acting.** Always state `[ROLE: X]` before switching modes.
110
111
  4. **Escalate correctly.** If a QA finds an architectural problem → escalate to Architect role.
111
- 5. **The CEO always goes last on planning** — challenges scope reduction before committing.
112
+ 5. **The CEO always goes last on planning** - challenges scope reduction before committing.
112
113
 
113
114
  ## Example Usage
114
115