@esotech/contextuate 2.1.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.
- package/dist/commands/install.js +8 -24
- package/package.json +2 -2
- package/dist/templates/skills/pythia.md +0 -37
- package/dist/templates/templates/standards/go.standards.md +0 -167
- package/dist/templates/templates/standards/java.standards.md +0 -167
- package/dist/templates/templates/standards/javascript.standards.md +0 -292
- package/dist/templates/templates/standards/php.standards.md +0 -181
- package/dist/templates/templates/standards/python.standards.md +0 -175
- package/dist/templates/tools/agent-creator.tool.md +0 -252
- package/dist/templates/tools/quickref.tool.md +0 -216
- package/dist/templates/tools/spawn.tool.md +0 -31
- package/dist/templates/tools/standards-detector.tool.md +0 -301
- package/dist/templates/version.json +0 -8
- /package/dist/templates/{skills → commands}/consult.md +0 -0
- /package/dist/templates/{skills → commands}/orchestrate.md +0 -0
|
@@ -1,292 +0,0 @@
|
|
|
1
|
-
# JavaScript/TypeScript Coding Standards
|
|
2
|
-
|
|
3
|
-
> **Language:** JavaScript / TypeScript
|
|
4
|
-
> **Generated:** {DATE}
|
|
5
|
-
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
## Formatting
|
|
9
|
-
|
|
10
|
-
### Indentation
|
|
11
|
-
- **Style:** {tabs|spaces}
|
|
12
|
-
- **Size:** {2|4} {spaces|tabs}
|
|
13
|
-
|
|
14
|
-
### Semicolons
|
|
15
|
-
- **Required:** {yes|no}
|
|
16
|
-
|
|
17
|
-
### Quotes
|
|
18
|
-
- **Strings:** {single|double|backticks for templates}
|
|
19
|
-
|
|
20
|
-
### Trailing Commas
|
|
21
|
-
- **Style:** {none|es5|all}
|
|
22
|
-
|
|
23
|
-
---
|
|
24
|
-
|
|
25
|
-
## Naming Conventions
|
|
26
|
-
|
|
27
|
-
### Classes/Components
|
|
28
|
-
- **Style:** PascalCase
|
|
29
|
-
- **Example:** `UserService`, `PaymentForm`
|
|
30
|
-
|
|
31
|
-
### Functions/Methods
|
|
32
|
-
- **Style:** camelCase
|
|
33
|
-
- **Example:** `getUserById()`, `handleSubmit()`
|
|
34
|
-
|
|
35
|
-
### Variables
|
|
36
|
-
- **Style:** camelCase
|
|
37
|
-
- **Example:** `userName`, `isActive`
|
|
38
|
-
|
|
39
|
-
### Constants
|
|
40
|
-
- **Style:** {UPPER_SNAKE_CASE|camelCase}
|
|
41
|
-
- **Example:** `MAX_RETRIES` or `maxRetries`
|
|
42
|
-
|
|
43
|
-
### Private Members
|
|
44
|
-
- **Style:** {underscore prefix|# prefix|none}
|
|
45
|
-
- **Example:** `_privateMethod()` or `#privateField`
|
|
46
|
-
|
|
47
|
-
### File Names
|
|
48
|
-
- **Style:** {kebab-case|camelCase|PascalCase}
|
|
49
|
-
- **Example:** `user-service.js` or `UserService.js`
|
|
50
|
-
|
|
51
|
-
---
|
|
52
|
-
|
|
53
|
-
## Structure
|
|
54
|
-
|
|
55
|
-
### Module Organization
|
|
56
|
-
```javascript
|
|
57
|
-
// 1. Imports - external
|
|
58
|
-
import React from 'react';
|
|
59
|
-
import axios from 'axios';
|
|
60
|
-
|
|
61
|
-
// 2. Imports - internal
|
|
62
|
-
import { UserService } from './services';
|
|
63
|
-
import { formatDate } from './utils';
|
|
64
|
-
|
|
65
|
-
// 3. Types/Interfaces (TypeScript)
|
|
66
|
-
interface User {
|
|
67
|
-
id: number;
|
|
68
|
-
name: string;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// 4. Constants
|
|
72
|
-
const API_URL = '/api/v1';
|
|
73
|
-
|
|
74
|
-
// 5. Main export
|
|
75
|
-
export class MyClass {
|
|
76
|
-
// ...
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// 6. Helper functions (if not exported separately)
|
|
80
|
-
function helperFunction() {
|
|
81
|
-
// ...
|
|
82
|
-
}
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
### Function Length
|
|
86
|
-
- **Guideline:** {max lines per function}
|
|
87
|
-
|
|
88
|
-
---
|
|
89
|
-
|
|
90
|
-
## Variable Declarations
|
|
91
|
-
|
|
92
|
-
### Preferred Keywords
|
|
93
|
-
- **Immutable:** `const` (default)
|
|
94
|
-
- **Mutable:** `let`
|
|
95
|
-
- **Avoid:** `var`
|
|
96
|
-
|
|
97
|
-
```javascript
|
|
98
|
-
// GOOD
|
|
99
|
-
const user = getUser();
|
|
100
|
-
let count = 0;
|
|
101
|
-
|
|
102
|
-
// BAD
|
|
103
|
-
var user = getUser();
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
---
|
|
107
|
-
|
|
108
|
-
## Functions
|
|
109
|
-
|
|
110
|
-
### Declaration Style
|
|
111
|
-
```javascript
|
|
112
|
-
// Preferred: {function declaration|arrow function|mixed}
|
|
113
|
-
|
|
114
|
-
// Function declaration
|
|
115
|
-
function processData( data ) {
|
|
116
|
-
// ...
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// Arrow function
|
|
120
|
-
const processData = ( data ) => {
|
|
121
|
-
// ...
|
|
122
|
-
};
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
### Parameters
|
|
126
|
-
```javascript
|
|
127
|
-
// Destructuring: {preferred|optional}
|
|
128
|
-
function createUser( { name, email, role = 'user' } ) {
|
|
129
|
-
// ...
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// Default values
|
|
133
|
-
function greet( name = 'Guest' ) {
|
|
134
|
-
// ...
|
|
135
|
-
}
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
---
|
|
139
|
-
|
|
140
|
-
## Async/Await
|
|
141
|
-
|
|
142
|
-
### Preferred Style
|
|
143
|
-
```javascript
|
|
144
|
-
// {async/await|promises|callbacks for specific cases}
|
|
145
|
-
|
|
146
|
-
// GOOD
|
|
147
|
-
async function fetchUser( id ) {
|
|
148
|
-
try {
|
|
149
|
-
const response = await api.get( `/users/${id}` );
|
|
150
|
-
return response.data;
|
|
151
|
-
} catch( error ) {
|
|
152
|
-
handleError( error );
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// AVOID (unless necessary)
|
|
157
|
-
function fetchUser( id ) {
|
|
158
|
-
return api.get( `/users/${id}` )
|
|
159
|
-
.then( response => response.data )
|
|
160
|
-
.catch( handleError );
|
|
161
|
-
}
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
---
|
|
165
|
-
|
|
166
|
-
## TypeScript Specific
|
|
167
|
-
|
|
168
|
-
### Type Annotations
|
|
169
|
-
```typescript
|
|
170
|
-
// {Required|Inferred where possible}
|
|
171
|
-
|
|
172
|
-
// Explicit
|
|
173
|
-
function getUser( id: number ): Promise<User> {
|
|
174
|
-
// ...
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
// Inferred (if allowed)
|
|
178
|
-
const count = 0; // inferred as number
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
### Interfaces vs Types
|
|
182
|
-
```typescript
|
|
183
|
-
// Preferred for objects: {interface|type}
|
|
184
|
-
interface User {
|
|
185
|
-
id: number;
|
|
186
|
-
name: string;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
// Use type for: unions, primitives, tuples
|
|
190
|
-
type Status = 'active' | 'inactive';
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
### Strict Mode
|
|
194
|
-
- **Enabled:** {yes|no}
|
|
195
|
-
- **Null checks:** {strict|relaxed}
|
|
196
|
-
|
|
197
|
-
---
|
|
198
|
-
|
|
199
|
-
## Error Handling
|
|
200
|
-
|
|
201
|
-
### Try/Catch
|
|
202
|
-
```javascript
|
|
203
|
-
try {
|
|
204
|
-
await riskyOperation();
|
|
205
|
-
} catch( error ) {
|
|
206
|
-
if( error instanceof SpecificError ){
|
|
207
|
-
// handle specific
|
|
208
|
-
} else {
|
|
209
|
-
// handle general
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
### Error Types
|
|
215
|
-
```typescript
|
|
216
|
-
// Custom errors: {yes|no}
|
|
217
|
-
class ValidationError extends Error {
|
|
218
|
-
constructor( message: string, public field: string ){
|
|
219
|
-
super( message );
|
|
220
|
-
this.name = 'ValidationError';
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
---
|
|
226
|
-
|
|
227
|
-
## Imports/Exports
|
|
228
|
-
|
|
229
|
-
### Module Style
|
|
230
|
-
```javascript
|
|
231
|
-
// Named exports (preferred for utilities)
|
|
232
|
-
export function helper() {}
|
|
233
|
-
export const CONSTANT = 'value';
|
|
234
|
-
|
|
235
|
-
// Default export (for main class/component)
|
|
236
|
-
export default class MainService {}
|
|
237
|
-
```
|
|
238
|
-
|
|
239
|
-
### Import Organization
|
|
240
|
-
```javascript
|
|
241
|
-
// 1. External packages
|
|
242
|
-
// 2. Internal absolute paths
|
|
243
|
-
// 3. Internal relative paths
|
|
244
|
-
// 4. Styles/assets
|
|
245
|
-
```
|
|
246
|
-
|
|
247
|
-
---
|
|
248
|
-
|
|
249
|
-
## Common Patterns
|
|
250
|
-
|
|
251
|
-
### Null/Undefined Handling
|
|
252
|
-
```javascript
|
|
253
|
-
// Optional chaining
|
|
254
|
-
const city = user?.address?.city;
|
|
255
|
-
|
|
256
|
-
// Nullish coalescing
|
|
257
|
-
const name = user.name ?? 'Anonymous';
|
|
258
|
-
|
|
259
|
-
// Default parameters
|
|
260
|
-
function greet( name = 'Guest' ) {}
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
### Object Manipulation
|
|
264
|
-
```javascript
|
|
265
|
-
// Spread for copies
|
|
266
|
-
const updated = { ...user, name: 'New Name' };
|
|
267
|
-
|
|
268
|
-
// Destructuring
|
|
269
|
-
const { id, name } = user;
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
---
|
|
273
|
-
|
|
274
|
-
## Anti-Patterns
|
|
275
|
-
|
|
276
|
-
```javascript
|
|
277
|
-
// BAD: {description}
|
|
278
|
-
{bad example}
|
|
279
|
-
|
|
280
|
-
// GOOD: {description}
|
|
281
|
-
{good example}
|
|
282
|
-
```
|
|
283
|
-
|
|
284
|
-
---
|
|
285
|
-
|
|
286
|
-
## Framework-Specific
|
|
287
|
-
|
|
288
|
-
{Add any React/Vue/Node/etc. specific conventions here}
|
|
289
|
-
|
|
290
|
-
---
|
|
291
|
-
|
|
292
|
-
*This file should be customized for your project. Replace placeholders with actual values.*
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
# PHP Coding Standards
|
|
2
|
-
|
|
3
|
-
> **Language:** PHP
|
|
4
|
-
> **Generated:** {DATE}
|
|
5
|
-
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
## Formatting
|
|
9
|
-
|
|
10
|
-
### Indentation
|
|
11
|
-
- **Style:** {tabs|spaces}
|
|
12
|
-
- **Size:** {2|4} {spaces|tabs}
|
|
13
|
-
|
|
14
|
-
### Braces
|
|
15
|
-
- **Classes/Functions:** {same-line|next-line}
|
|
16
|
-
- **Control structures:** {same-line|next-line}
|
|
17
|
-
|
|
18
|
-
### Spacing
|
|
19
|
-
- **Inside parentheses:** {yes|no} - `function( $param )` vs `function($param)`
|
|
20
|
-
- **After keywords:** {yes|no} - `if ( $x )` vs `if($x)`
|
|
21
|
-
- **Array brackets:** {no-spaces} - `$arr['key']`
|
|
22
|
-
|
|
23
|
-
---
|
|
24
|
-
|
|
25
|
-
## Naming Conventions
|
|
26
|
-
|
|
27
|
-
### Classes
|
|
28
|
-
- **Style:** PascalCase
|
|
29
|
-
- **Example:** `UserService`, `PaymentController`
|
|
30
|
-
|
|
31
|
-
### Methods
|
|
32
|
-
- **Style:** camelCase
|
|
33
|
-
- **Example:** `getUserById()`, `processPayment()`
|
|
34
|
-
|
|
35
|
-
### Variables
|
|
36
|
-
- **Style:** {camelCase|snake_case}
|
|
37
|
-
- **Example:** `$userName` or `$user_name`
|
|
38
|
-
|
|
39
|
-
### Constants
|
|
40
|
-
- **Style:** UPPER_SNAKE_CASE
|
|
41
|
-
- **Example:** `MAX_RETRY_COUNT`, `API_VERSION`
|
|
42
|
-
|
|
43
|
-
### Properties
|
|
44
|
-
- **Style:** {camelCase|snake_case}
|
|
45
|
-
- **Visibility prefix:** {none|underscore for private}
|
|
46
|
-
|
|
47
|
-
---
|
|
48
|
-
|
|
49
|
-
## Structure
|
|
50
|
-
|
|
51
|
-
### File Organization
|
|
52
|
-
```php
|
|
53
|
-
<?php
|
|
54
|
-
// 1. Strict types declaration (if used)
|
|
55
|
-
declare( strict_types=1 );
|
|
56
|
-
|
|
57
|
-
// 2. Namespace
|
|
58
|
-
namespace App\Services;
|
|
59
|
-
|
|
60
|
-
// 3. Use statements (alphabetized)
|
|
61
|
-
use App\Models\User;
|
|
62
|
-
use Exception;
|
|
63
|
-
|
|
64
|
-
// 4. Class definition
|
|
65
|
-
class UserService {
|
|
66
|
-
// 5. Constants
|
|
67
|
-
// 6. Properties
|
|
68
|
-
// 7. Constructor
|
|
69
|
-
// 8. Public methods
|
|
70
|
-
// 9. Protected methods
|
|
71
|
-
// 10. Private methods
|
|
72
|
-
}
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
### Method Length
|
|
76
|
-
- **Guideline:** {max lines per method}
|
|
77
|
-
- **Complexity:** {max cyclomatic complexity}
|
|
78
|
-
|
|
79
|
-
---
|
|
80
|
-
|
|
81
|
-
## Type Hints
|
|
82
|
-
|
|
83
|
-
### Parameters
|
|
84
|
-
```php
|
|
85
|
-
// {Required|Optional}
|
|
86
|
-
public function process( string $name, int $count ): void
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
### Return Types
|
|
90
|
-
```php
|
|
91
|
-
// {Required|Optional}
|
|
92
|
-
public function getData(): array
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
### Property Types (PHP 7.4+)
|
|
96
|
-
```php
|
|
97
|
-
// {Required|Optional}
|
|
98
|
-
private string $name;
|
|
99
|
-
private User|null $user = null;
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
---
|
|
103
|
-
|
|
104
|
-
## Documentation
|
|
105
|
-
|
|
106
|
-
### Class DocBlocks
|
|
107
|
-
```php
|
|
108
|
-
/**
|
|
109
|
-
* {Required|Optional}
|
|
110
|
-
* Brief description of the class.
|
|
111
|
-
*/
|
|
112
|
-
class MyClass
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
### Method DocBlocks
|
|
116
|
-
```php
|
|
117
|
-
/**
|
|
118
|
-
* {Required|Optional|Only for complex methods}
|
|
119
|
-
*
|
|
120
|
-
* @param string $name Description
|
|
121
|
-
* @return array Description
|
|
122
|
-
* @throws Exception When condition
|
|
123
|
-
*/
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
---
|
|
127
|
-
|
|
128
|
-
## Error Handling
|
|
129
|
-
|
|
130
|
-
### Exceptions
|
|
131
|
-
- **Custom exceptions:** {yes|no}
|
|
132
|
-
- **Base exception class:** {name if applicable}
|
|
133
|
-
|
|
134
|
-
### Try/Catch
|
|
135
|
-
```php
|
|
136
|
-
try {
|
|
137
|
-
// code
|
|
138
|
-
} catch( SpecificException $e ){
|
|
139
|
-
// handle
|
|
140
|
-
} catch( Exception $e ){
|
|
141
|
-
// fallback
|
|
142
|
-
}
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
---
|
|
146
|
-
|
|
147
|
-
## Common Patterns
|
|
148
|
-
|
|
149
|
-
### Dependency Injection
|
|
150
|
-
```php
|
|
151
|
-
// {Constructor injection|Setter injection|Container}
|
|
152
|
-
public function __construct( private UserRepository $repo )
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
### Null Handling
|
|
156
|
-
```php
|
|
157
|
-
// Preferred: {null coalescing|ternary|early return}
|
|
158
|
-
$value = $data['key'] ?? 'default';
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
---
|
|
162
|
-
|
|
163
|
-
## Anti-Patterns
|
|
164
|
-
|
|
165
|
-
```php
|
|
166
|
-
// BAD: {description}
|
|
167
|
-
{bad example}
|
|
168
|
-
|
|
169
|
-
// GOOD: {description}
|
|
170
|
-
{good example}
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
---
|
|
174
|
-
|
|
175
|
-
## Framework-Specific
|
|
176
|
-
|
|
177
|
-
{Add any framework-specific conventions here}
|
|
178
|
-
|
|
179
|
-
---
|
|
180
|
-
|
|
181
|
-
*This file should be customized for your project. Replace placeholders with actual values.*
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
# Python Coding Standards
|
|
2
|
-
|
|
3
|
-
> **Language:** Python
|
|
4
|
-
> **Generated:** {DATE}
|
|
5
|
-
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
## Formatting
|
|
9
|
-
|
|
10
|
-
### Indentation
|
|
11
|
-
- **Style:** {spaces}
|
|
12
|
-
- **Size:** {4} {spaces}
|
|
13
|
-
|
|
14
|
-
### Line Length
|
|
15
|
-
- **Max Length:** {88|100|120} chars
|
|
16
|
-
- **Docstrings:** {72} chars
|
|
17
|
-
|
|
18
|
-
### Imports
|
|
19
|
-
- **Sort Order:** {Standard Library} > {Third Party} > {Local Application}
|
|
20
|
-
- **Style:** {Absolute imports preferred}
|
|
21
|
-
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
## Naming Conventions
|
|
25
|
-
|
|
26
|
-
### Classes
|
|
27
|
-
- **Style:** PascalCase
|
|
28
|
-
- **Example:** `UserContext`, `PaymentProcessor`
|
|
29
|
-
|
|
30
|
-
### Functions/Methods
|
|
31
|
-
- **Style:** snake_case
|
|
32
|
-
- **Example:** `get_user_by_id()`, `process_payment()`
|
|
33
|
-
|
|
34
|
-
### Variables
|
|
35
|
-
- **Style:** snake_case
|
|
36
|
-
- **Example:** `user_name`, `is_active`
|
|
37
|
-
|
|
38
|
-
### Constants
|
|
39
|
-
- **Style:** UPPER_SNAKE_CASE
|
|
40
|
-
- **Example:** `MAX_RETRY_COUNT`, `API_VERSION`
|
|
41
|
-
|
|
42
|
-
### Private Members
|
|
43
|
-
- **Style:** {underscore prefix}
|
|
44
|
-
- **Example:** `_private_method()`, `_internal_var`
|
|
45
|
-
|
|
46
|
-
---
|
|
47
|
-
|
|
48
|
-
## Structure
|
|
49
|
-
|
|
50
|
-
### File Organization
|
|
51
|
-
```python
|
|
52
|
-
# 1. Shebang (if executable)
|
|
53
|
-
#!/usr/bin/env python3
|
|
54
|
-
|
|
55
|
-
# 2. Module Docstring
|
|
56
|
-
"""
|
|
57
|
-
Module description.
|
|
58
|
-
"""
|
|
59
|
-
|
|
60
|
-
# 3. Imports
|
|
61
|
-
import os
|
|
62
|
-
from typing import List, Optional
|
|
63
|
-
|
|
64
|
-
# 4. Constants
|
|
65
|
-
MAX_RETRIES = 3
|
|
66
|
-
|
|
67
|
-
# 5. Classes
|
|
68
|
-
class MyClass:
|
|
69
|
-
"""Class docstring."""
|
|
70
|
-
|
|
71
|
-
def __init__(self):
|
|
72
|
-
pass
|
|
73
|
-
|
|
74
|
-
# 6. Main execution
|
|
75
|
-
if __name__ == "__main__":
|
|
76
|
-
pass
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
---
|
|
80
|
-
|
|
81
|
-
## Type Hints (PEP 484)
|
|
82
|
-
|
|
83
|
-
### Parameters & Returns
|
|
84
|
-
```python
|
|
85
|
-
# {Required|Preferred}
|
|
86
|
-
def process(name: str, count: int = 0) -> None:
|
|
87
|
-
pass
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### Variables (PEP 526)
|
|
91
|
-
```python
|
|
92
|
-
# {Optional|Preferred}
|
|
93
|
-
user_id: int = 123
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
---
|
|
97
|
-
|
|
98
|
-
## Documentation (Docstrings)
|
|
99
|
-
|
|
100
|
-
### Style
|
|
101
|
-
- **Format:** {Google|NumPy|Sphinx/reST}
|
|
102
|
-
|
|
103
|
-
#### Google Style Example
|
|
104
|
-
```python
|
|
105
|
-
def fetch_data(url: str) -> dict:
|
|
106
|
-
"""Fetches data from the API.
|
|
107
|
-
|
|
108
|
-
Args:
|
|
109
|
-
url: The endpoint URL.
|
|
110
|
-
|
|
111
|
-
Returns:
|
|
112
|
-
A dictionary containing the response data.
|
|
113
|
-
|
|
114
|
-
Raises:
|
|
115
|
-
ConnectionError: If the request fails.
|
|
116
|
-
"""
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
---
|
|
120
|
-
|
|
121
|
-
## Error Handling
|
|
122
|
-
|
|
123
|
-
### Exceptions
|
|
124
|
-
```python
|
|
125
|
-
try:
|
|
126
|
-
process_data()
|
|
127
|
-
except ValueError as e:
|
|
128
|
-
logger.error(f"Validation error: {e}")
|
|
129
|
-
except Exception:
|
|
130
|
-
# Catch-all only if necessary
|
|
131
|
-
raise
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
---
|
|
135
|
-
|
|
136
|
-
## Common Patterns
|
|
137
|
-
|
|
138
|
-
### List Comprehensions
|
|
139
|
-
```python
|
|
140
|
-
# Preferred for simple transformations
|
|
141
|
-
names = [u.name for u in users if u.is_active]
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
### Context Managers
|
|
145
|
-
```python
|
|
146
|
-
# Preferred for resource management
|
|
147
|
-
with open("file.txt") as f:
|
|
148
|
-
content = f.read()
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
---
|
|
152
|
-
|
|
153
|
-
## Anti-Patterns
|
|
154
|
-
|
|
155
|
-
```python
|
|
156
|
-
# BAD: Mutable default arguments
|
|
157
|
-
def add_item(item, list=[]):
|
|
158
|
-
list.append(item)
|
|
159
|
-
|
|
160
|
-
# GOOD:
|
|
161
|
-
def add_item(item, list=None):
|
|
162
|
-
if list is None:
|
|
163
|
-
list = []
|
|
164
|
-
list.append(item)
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
---
|
|
168
|
-
|
|
169
|
-
## Framework-Specific
|
|
170
|
-
|
|
171
|
-
{Add Django/Flask/FastAPI specific conventions here}
|
|
172
|
-
|
|
173
|
-
---
|
|
174
|
-
|
|
175
|
-
*This file should be customized for your project. Replace placeholders with actual values.*
|