Skip to content

Commit 6f84c40

Browse files
committed
feat: second optimized rules.
1 parent d04fa9b commit 6f84c40

File tree

6 files changed

+294
-70
lines changed

6 files changed

+294
-70
lines changed

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ Want just the essentials? Copy these:
5151
- `AGENTS.md` (put in your project root)
5252
- `rules/` folder (the main rules)
5353
- `specs/` folder (for user persona and other specs)
54+
- `project-specs/` folder (for project specifications)
5455

5556
**Your Editor Config:**
5657
- **Trae AI**: Copy `.trae/` folder
@@ -59,9 +60,18 @@ Want just the essentials? Copy these:
5960
- **Kiro**: Copy `.kiro/` folder
6061

6162
### Rule Activation
62-
- Close and reopen project (optional but recommended)
63-
- Start a new chat
64-
- The agent should automatically read the rules and begin the onboarding process.
63+
64+
- **Close and reopen project** (optional but recommended).
65+
- **Start a new chat session**.
66+
- **Trigger the rules** using one of the methods below:
67+
68+
- **Vague Trigger (Recommended)**: Start the session with a simple, vague statement like:
69+
- "Hello"
70+
- "Let's make some changes"
71+
- **Explicit Trigger**: If the agent doesn't respond interactively, you can explicitly ask it to read the rules:
72+
- "Please read the project rules first."
73+
74+
*Note: The rules must be triggered for each new chat session for the agent to follow them.*
6575

6676
**First Time Expectation:** The agent will guide you through creating a `user-persona.spec.md` file, which will tailor its communication style to your preferences.
6777

rules/file-caching.rules.md

Lines changed: 0 additions & 12 deletions
This file was deleted.

rules/holistic-workflow.rules.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ This is not just a set of rules; it is a framework for your thinking.
3737

3838
For example, if you are in the **"Implement"** step and you discover an unexpected technical challenge, you should not "push through." Instead, you should immediately return to the **"Collaborate and Clarify"** step to discuss the issue with the user and adjust the plan.
3939

40-
Always be ready to adapt. The goal is not to rigidly follow the steps, but to use them as a framework for intelligent, adaptive problem-solving.
40+
Always be ready to adapt. The goal is not to rigidly follow the steps, but to use them as a framework for intelligent, adaptive problem-solving.

rules/interactive-input.rules.md

Lines changed: 112 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,53 @@
1-
# Interactive Input: Core Rules (Token-Optimized)
1+
# Interactive Input: Core Rules
22

33
## 1. Core Principle: Clarify & Verify (Mandatory)
44
- **Vague? -> Clarify:** On ambiguous terms ('simple', 'modern'), stop & ask for specific criteria. Present options with trade-offs.
55
- **Verify -> Then Act:** Always get explicit approval. Ask `"Should I proceed?"` before coding and `"Does this meet your expectations?"` after.
66
- **Validate -> Scope:** Implement ONLY what is explicitly requested. Never add, modify, or remove features/code without direct permission.
77

88
## 2. When to Stop & Ask (Mandatory)
9-
- **Vague Terms:** "modern", "simple", "clean".
10-
- **Multiple Paths:** Design patterns, tech choices.
11-
- **New Features:** Anything not explicitly requested.
12-
- **Major Changes:** New dependencies, architectural shifts.
13-
- **Assumptions:** Never infer user intent.
9+
- **Vague Requirements:** "modern", "simple", "clean", "responsive", "scalable".
10+
- **Multiple Valid Approaches:** Design patterns (hooks vs classes), libraries (Redux vs Zustand), or tool choices.
11+
- **Feature Additions:** ANY feature not explicitly requested by the user.
12+
- **Significant Code Changes:** New dependencies, core architecture modifications.
13+
- **Assumptions About User Intent:** Inferring unstated requirements.
14+
- **Post-Implementation:** After completing ANY feature or implementation.
15+
- **Project Direction:** When multiple valid next steps exist.
16+
- **Project Rules:** Before codifying new coding standards.
17+
18+
### Scope & Preservation Violations
19+
- **NEVER** implement buttons, UI elements, or functionality not explicitly requested.
20+
- **NEVER** assume user wants "complete" implementations with extra features.
21+
- **NEVER** remove/modify existing working components without explicit request.
22+
- **NEVER** assume existing code is redundant or should be removed.
23+
- **CORRECT APPROACH**: Ask "Should I add features like accept/decline buttons?" or "Should I preserve existing [component] or modify it?"
1424

1525
## 3. Interactive Command Protocol (Critical)
16-
- **Tool:** Use `run_command` ONLY. `blocking: true`, `requires_approval: false`.
17-
- **Format:** Simple `echo/read/echo`. One question per command. No `&&` chaining.
18-
- **Readability:** Every interactive command **MUST** begin with two newlines (`\n\n` or `echo. & echo.`).
19-
- **OS Syntax:** Detect OS and use correct syntax.
26+
- **Tool:** Use `run_command` ONLY. `blocking: true`, `requires_approval: false` for questions.
27+
- **Format:** Use `echo -e` for interactive input.
28+
- **Readability:** Every interactive command **MUST** begin with two newlines (`\n\n`).
29+
- **OS Syntax:** Use OS-appropriate syntax.
30+
31+
### Tool Usage Example
32+
```json
33+
{
34+
"command": "echo -e '\\n\\nYour question here (option1/option2): '; read answer; echo 'You selected: $answer'",
35+
"blocking": true,
36+
"target_terminal": "new",
37+
"requires_approval": false
38+
}
39+
```
40+
- **JSON Escaping:** Note the use of `\\n\\n` for newlines within the JSON string.
2041

2142
### OS-Specific Commands
43+
44+
### Complex & Multi-line Questions
45+
For complex questions that require more context, you can format the question over multiple lines using `\n` for newlines within the `echo -e` command. This improves readability.
46+
47+
**Unix/Linux/macOS Example:**
48+
```bash
49+
echo -e '\n\nI need to update the user authentication flow. Which approach should I take?\n1. JWT-based authentication with refresh tokens\n2. Session-based authentication with server-side storage\n3. OAuth 2.0 with a third-party provider (e.g., Google, GitHub)\nPlease enter the number of your choice: '; read answer; echo "You selected: $answer"
50+
```
2251
**Unix/Linux/macOS:**
2352
```bash
2453
echo -e '\n\nQuestion...?'; read answer; echo "You selected: $answer"
@@ -36,22 +65,78 @@ Write-Host "`n`nQuestion...?" -NoNewline; $answer = Read-Host; Write-Host "You s
3665

3766
## 4. Display vs. Input (Critical Distinction)
3867
- **Display-Only:** Use `echo` to show info. MUST end with `"Press Enter to continue..."` and wait for `read` acknowledgment.
39-
- **Interactive Input:** Use `echo/read/echo` format to ask a question and capture a response.
40-
41-
## 5. Critical Violations (Non-Negotiable)
42-
1. **Executing without Approval:** Implementing code before getting a "yes".
43-
2. **Scope Creep:** Adding, modifying, or removing anything not explicitly asked for.
44-
3. **Ignoring Ambiguity:** Proceeding with vague terms without clarification.
45-
4. **Chaining Commands:** Using `&&` to link multiple questions or actions.
46-
5. **Displaying Commands:** Showing the command as text instead of executing it via `run_command`.
47-
6. **Incorrect Formatting:** Missing the two leading newlines.
48-
49-
## 6. Session Closure (Mandatory)
50-
- Always end by asking: `echo -e '\n\nAre we done, or do you have more changes? (done/changes)'; read answer`
68+
- **Interactive Input:** Use `echo/read/echo` format to ask a question and capture a response. MUST confirm with `echo "You selected: $answer"`.
69+
70+
## 5. Question Guidelines
71+
- **Be Specific:** One question at a time, avoid vague phrasing.
72+
- **Provide Context:** Explain why it matters, include implications.
73+
- **Offer Options:** Clear choices, numbered, include "other".
74+
- **Follow-up:** Drill deeper when answers leave ambiguity.
75+
76+
## 6. Mandatory Practices
77+
- **Early Clarification** - Ask questions at task start, resolve ambiguities before coding
78+
- **Feature Scope Verification** - MUST confirm before adding ANY feature not explicitly requested
79+
- **Display Text Acknowledgment** - ALL display-only text MUST require user acknowledgment before proceeding
80+
- **Provide Rationale** - Always explain why questions matter, help weigh trade-offs
81+
- **Respect User Decisions** - User choice is final, no exceptions
82+
- **Document Decisions** - Ask before codifying new standards
83+
- **File Content Verification** - Re-read all relevant files before making implementation decisions
84+
- **Fresh Content Protocol** - Never base interactive questions on stale file content or cached understanding
85+
- **Mandatory Closure** - Always end with: "Done or want changes?"
86+
87+
## 7. Session Closure (Mandatory)
88+
- Always end by asking: `echo -e '\n\nDone or want changes? (done/adjust)'; read answer`
5189
- Never exit without explicit user confirmation.
5290

53-
## 7. Compliance Checklist (Mandatory)
54-
- **Before Action:** [ ] Clarified vague terms? [ ] Got explicit `Should I proceed?` approval?
55-
- **Command Format:** [ ] Using `run_command`? [ ] Starts with `\n\n`? [ ] Correct OS syntax?
56-
- **After Action:** [ ] Confirmed with `Does this meet your expectations?`? [ ] No scope creep?
57-
- **Session End:** [ ] Asked `Are we done...?` before exiting?
91+
## 8. Compliance & Violations
92+
93+
### Enhanced Compliance Checklist
94+
95+
**Before ANY implementation:**
96+
- [ ] Clarified vague terms?
97+
- [ ] Presented options for multiple approaches?
98+
- [ ] Explained implications and trade-offs?
99+
- [ ] Asked "Should I proceed?" before implementation?
100+
- [ ] Confirmed feature scope - only implementing what's explicitly requested?
101+
- [ ] Avoided adding unrequested buttons, UI elements, or functionality?
102+
- [ ] Confirmed assumptions?
103+
- [ ] Respected user preferences?
104+
- [ ] Verified no scope creep?
105+
- [ ] Asked for explicit approval?
106+
107+
**After EVERY implementation:**
108+
- [ ] Asked "Does this meet your expectations?"
109+
- [ ] Confirmed no unrequested features were added?
110+
- [ ] Validated implementation scope matches user request?
111+
- [ ] Asked if user wants modifications?
112+
113+
**For ALL display-only text:**
114+
- [ ] Included "Press Enter to continue" or "Type what you'd like to change"?
115+
- [ ] Used `read` to wait for user acknowledgment?
116+
- [ ] Avoided proceeding without user acknowledgment?
117+
118+
**REFACTORING-SPECIFIC CHECKLIST:**
119+
- [ ] Preserved ALL original functionality?
120+
- [ ] Maintained existing component behavior?
121+
- [ ] Avoided removing working features?
122+
- [ ] Asked before changing component structure?
123+
- [ ] Confirmed refactoring scope with user?
124+
125+
**At session end:**
126+
- [ ] Asked if user wants changes?
127+
- [ ] Verified all requirements were met?
128+
129+
### Violation Protocol
130+
1. STOP immediately
131+
2. ACKNOWLEDGE missed step
132+
3. **EXECUTE** required interactive command via `run_command` tool
133+
4. WAIT for user response
134+
5. **NEVER** show interactive commands as text - always execute them
135+
136+
### Execution Failures
137+
- **Critical Violation:** Showing an interactive command (`echo...; read...`) as text instead of executing it via the `run_command` tool.
138+
- **Forbidden:** Displaying interactive commands as text is strictly forbidden.
139+
140+
## 9. Information Freshness (Critical)
141+
- **Core Rule:** You MUST always use the most up-to-date file content. Before you ask a question or implement a change, re-read any relevant files to ensure you have not missed a manual update from the user.
142+
- **Stale Content = Critical Failure:** Basing actions on outdated information is a critical violation.
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Specification Decision Examples
2+
3+
This document provides a comprehensive, non-exhaustive list of examples for when a specification is required. It is intended as a reference to be used for validation when there is doubt.
4+
5+
---
6+
7+
## Detailed Triggers for Specification Creation
8+
9+
A specification is required for **ALL** of the following:
10+
11+
### General Code Changes
12+
- **New Features:** Any new functionality, components, functions, endpoints, or capabilities.
13+
- **Bug Fixes:** Any correction of existing code behavior or functionality.
14+
- **Refactoring:** Any restructuring, optimization, or code improvement without changing external behavior.
15+
- **Configuration Changes:** Any modification to build tools, environment settings, or project configuration.
16+
- **Dependency Changes:** Adding, removing, or updating any external libraries or packages.
17+
- **Documentation Updates:** Changes to code comments, README files, or technical documentation.
18+
- **Testing Changes:** Adding, modifying, or removing tests at any level.
19+
- **Performance Optimizations:** Any changes aimed at improving system performance.
20+
- **Security Updates:** Any changes related to security, authentication, or authorization.
21+
- **Maintenance Tasks:** Code cleanup, formatting changes, or routine maintenance.
22+
- **Architecture Changes:** Any modification to system structure, patterns, or design.
23+
- **Database Changes:** Schema modifications, query updates, or data migration scripts.
24+
- **API Changes:** Endpoint modifications, request/response format changes, or protocol updates.
25+
- **UI/UX Changes:** Any modification to user interface or user experience elements.
26+
- **Infrastructure Changes:** Deployment, CI/CD, or environment configuration modifications.
27+
28+
### Architectural Patterns
29+
- Component architecture (atomic design, feature-based, etc.)
30+
- State management (Redux, Zustand, Context, etc.)
31+
- Data fetching (REST, GraphQL, SWR, React Query, etc.)
32+
- Routing (React Router, Next.js, etc.)
33+
- Form handling (Formik, React Hook Form, etc.)
34+
- Styling (CSS Modules, Styled Components, Tailwind, etc.)
35+
- Concurrency models (Threading vs async/await vs actor model - Go goroutines, Rust tokio, Erlang processes)
36+
- Memory management (Manual C/C++, garbage collected Java/C#, ownership-based Rust)
37+
- Error handling strategies (Exceptions vs result types vs error codes)
38+
- Module organization (Monolithic vs microservices vs modular monolith)
39+
- Communication patterns (Message queues, event streams, RPC, REST APIs)
40+
41+
### Data & Persistence
42+
- Storage paradigms (Relational PostgreSQL, document MongoDB, key-value Redis, graph Neo4j, time-series InfluxDB)
43+
- Data serialization (JSON vs Protocol Buffers vs MessagePack vs XML)
44+
- Caching strategies (In-memory, distributed, CDN, database query caching)
45+
- Consistency models (ACID transactions vs eventual consistency vs BASE)
46+
- Schema evolution (Migration strategies, versioning approaches)
47+
48+
### Language & Runtime
49+
- Language selection (Systems programming Rust/C++, web services Go/Java, scripting Python/JavaScript, mobile Swift/Kotlin)
50+
- Compilation strategies (Ahead-of-time Go, just-in-time Java/C#, interpreted Python)
51+
- TypeScript vs JavaScript
52+
- Node.js version and runtime features
53+
- Package manager (npm, yarn, pnpm)
54+
- Build tools (Webpack, Vite, Rollup, etc.)
55+
- Transpilation (Babel, SWC, etc.)
56+
- Dependency management (Package managers, version pinning, lock files)
57+
- Cross-platform deployment (Native compilation, containers, virtual machines)
58+
59+
### Quality & Reliability
60+
- Testing approaches (Unit, integration, end-to-end, property-based testing)
61+
- Testing frameworks (Jest, Vitest, Cypress, etc.)
62+
- Error monitoring (Logging levels, structured logging, distributed tracing)
63+
- Code analysis (Static analysis tools, linters, formatters)
64+
- Performance profiling (Memory profilers, CPU analysis, benchmarking tools)
65+
- Security practices (Input validation, authentication, authorization, encryption)
66+
- Linting and formatting (ESLint, Prettier, etc.)
67+
68+
### Tooling & Workflow
69+
- Build systems (Make, Bazel, Maven, Gradle, Cargo, npm)
70+
- Version control (Git workflows, branching strategies, merge vs rebase)
71+
- Code formatting (Language-specific formatters - gofmt, rustfmt, prettier)
72+
- Development environments (Local setup, containerized development, cloud IDEs)
73+
- Deployment strategies (Blue-green, canary, rolling updates)
74+
- Git workflow and branching strategy
75+
- CI/CD pipeline and deployment
76+
- Development environment setup
77+
- Code quality tools (Husky, lint-staged, etc.)
78+
79+
### Foundational Decisions
80+
- File naming conventions (snake_case vs camelCase vs kebab-case)
81+
- Directory structure (Feature-based vs layer-based organization)
82+
- Configuration management (Environment variables, config files, feature flags)
83+
- Documentation standards (Code comments, API documentation, architectural diagrams)
84+
- Logging conventions (Log levels, structured vs unstructured, centralized collection)

0 commit comments

Comments
 (0)