1+ ---
2+ description:
3+ globs:
4+ ---
5+ # Examples Standards
6+
7+ Standards for creating and maintaining examples in the StackOne repository.
8+
9+ <rule>
10+ name: examples_standards
11+ description: Standards for creating and maintaining examples for all functionality
12+
13+ filters:
14+ - type: path
15+ pattern: "^examples/.*"
16+ - type: path
17+ pattern: "^packages/.*/.*"
18+
19+ actions:
20+ - type: suggest
21+ message: |
22+ When working with examples:
23+
24+ 1. Location Requirements:
25+ ```
26+ examples/
27+ ├── basic_usage/
28+ │ ├── basic_tool_usage.py # Basic usage examples
29+ │ └── error_handling.py # Error handling examples
30+ ├── integrations/ # Integration examples
31+ │ ├── openai_integration.py
32+ │ └── other_integration.py
33+ └── README.md # Examples documentation
34+ ```
35+
36+ 2. Example Requirements:
37+ - Every public function/class needs at least one example
38+ - Examples should be runnable Python scripts
39+ - Include error handling cases
40+ - Load credentials from .env
41+ - Include type hints
42+ - Follow the same code style as the main codebase
43+ - Always use "gpt-4o-mini" as the model name in LLM examples
44+ - Keep examples minimal and focused on demonstrating specific functionality
45+
46+ 3. Documentation:
47+ - Each example file should start with a docstring explaining its purpose
48+ - Include expected output in comments
49+ - Document any prerequisites (environment variables, etc)
50+
51+ 4. Testing:
52+ - Examples should be tested as part of CI
53+ - Examples should work with the latest package version
54+ - Include sample responses in comments
55+
56+ examples:
57+ - input: |
58+ # Good example structure
59+ import os
60+ from dotenv import load_dotenv
61+ from stackone_ai import StackOneToolSet
62+ from openai import OpenAI
63+
64+ def main():
65+ """Example showing basic usage of StackOneToolSet with OpenAI."""
66+ load_dotenv()
67+
68+ api_key = os.getenv("STACKONE_API_KEY")
69+ if not api_key:
70+ raise ValueError("STACKONE_API_KEY not found")
71+
72+ client = OpenAI()
73+ response = client.chat.completions.create(
74+ model="gpt-4o-mini", # Always use gpt-4o-mini in examples
75+ messages=[{"role": "user", "content": "Hello"}]
76+ )
77+
78+ # Example code...
79+
80+ if __name__ == "__main__":
81+ main()
82+ output: "Correctly structured example"
83+
84+ - input: |
85+ # Bad example - missing error handling, docs, types, wrong model name
86+ from stackone_ai import StackOneToolSet
87+ from openai import OpenAI
88+
89+ toolset = StackOneToolSet("hardcoded_key")
90+ client = OpenAI()
91+ response = client.chat.completions.create(
92+ model="gpt-4", # Wrong - should use gpt-4o-mini
93+ messages=[{"role": "user", "content": "Hello"}]
94+ )
95+ output: "Incorrectly structured example"
96+
97+ metadata:
98+ priority: high
99+ version: 1.0
100+ tags:
101+ - examples
102+ - documentation
103+ - testing
104+ </rule>
0 commit comments