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+
44+ 3. Documentation:
45+ - Each example file should start with a docstring explaining its purpose
46+ - Include expected output in comments
47+ - Document any prerequisites (environment variables, etc)
48+
49+ 4. Testing:
50+ - Examples should be tested as part of CI
51+ - Examples should work with the latest package version
52+ - Include sample responses in comments
53+
54+ examples:
55+ - input: |
56+ # Good example structure
57+ import os
58+ from dotenv import load_dotenv
59+ from stackone_ai import StackOneToolSet
60+
61+ def main():
62+ """Example showing basic usage of StackOneToolSet."""
63+ load_dotenv()
64+
65+ api_key = os.getenv("STACKONE_API_KEY")
66+ if not api_key:
67+ raise ValueError("STACKONE_API_KEY not found")
68+
69+ # Example code...
70+
71+ if __name__ == "__main__":
72+ main()
73+ output: "Correctly structured example"
74+
75+ - input: |
76+ # Bad example - missing error handling, docs, types
77+ from stackone_ai import StackOneToolSet
78+
79+ toolset = StackOneToolSet("hardcoded_key")
80+ tools = toolset.get_tools("crm")
81+ result = tools["some_tool"].execute()
82+ output: "Incorrectly structured example"
83+
84+ metadata:
85+ priority: high
86+ version: 1.0
87+ tags:
88+ - examples
89+ - documentation
90+ - testing
91+ </rule>
0 commit comments