Skip to content

Commit 225c852

Browse files
authored
refactor(rules): reorganise Claude/Cursor rules structure (#53)
* refactor(rules): create .claude/rules/ as source of truth for project rules Migrate project rules from .cursor/rules/ to .claude/rules/ to establish a single source of truth for both Claude Code and Cursor IDE. New rules structure: - development-workflow.md: Code style and project conventions - git-workflow.md: Commit conventions, branch strategy, PR guidelines - examples-standards.md: Example requirements and organisation - no-relative-imports.md: Enforce absolute imports in Python files - package-installation.md: UV package management standards - release-please-standards.md: Release versioning with release-please - uv-scripts.md: Utility script standards with UV All rules now use simplified YAML frontmatter format compatible with both Claude Code (via description/alwaysApply) and Cursor (via globs). * refactor(rules): replace .cursor/rules/ files with symlinks to .claude/rules/ Convert .cursor/rules/*.mdc files to symlinks pointing to their corresponding .claude/rules/*.md sources. This ensures consistency between Claude Code and Cursor IDE rule definitions. Changes: - Remove cursor-rules-location.mdc (obsolete with new structure) - Add symlinks for development-workflow and git-workflow (new rules) - Convert existing rules to symlinks (examples-standards, no-relative-imports, package-installation, release-please-standards, uv-scripts) Symlink format: .cursor/rules/foo.mdc -> ../../.claude/rules/foo.md * docs(claude): update CLAUDE.md with rules structure and table Update CLAUDE.md to document the new rules and skills structure, matching the Node SDK's format. Changes: - Add rules/skills structure explanation section - Add table of available rules with their glob patterns - Update references to use rule names instead of file paths - Use UK English spelling (behaviour, organisation) * chore(rules): update commands from make to just Replace all make commands with just commands in rules and CLAUDE.md to reflect the migration from Makefile to justfile.
1 parent 878bad1 commit 225c852

16 files changed

+483
-482
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
description: Code style, file naming, and project conventions. (project)
3+
alwaysApply: true
4+
---
5+
6+
# Development Workflow
7+
8+
This rule provides code style guidelines and project conventions for the StackOne AI Python SDK.
9+
10+
## Code Style
11+
12+
- Use [ruff](https://docs.astral.sh/ruff/) for linting and formatting
13+
- Follow PEP 8 style guidelines
14+
- Maximum line length: 88 characters (ruff default)
15+
- Run `just lint` to check, `just lint-fix` to auto-fix
16+
17+
## Type Annotations
18+
19+
- Full type annotations required for all public APIs
20+
- Use Python 3.11+ typing features
21+
- Run `just mypy` to verify type correctness
22+
- Strict mypy configuration is enforced
23+
24+
## Pre-commit Hooks
25+
26+
Pre-commit hooks are configured for:
27+
28+
- ruff linting
29+
- mypy type checking
30+
31+
Run `just install` to set up hooks.
32+
33+
## Essential Commands
34+
35+
```bash
36+
just install # Install dependencies and pre-commit hooks
37+
just lint # Run ruff linting
38+
just lint-fix # Auto-fix linting issues
39+
just mypy # Run type checking
40+
just test # Run all tests
41+
just test-tools # Run tool-specific tests
42+
just test-examples # Run example tests
43+
```
44+
45+
## File Naming
46+
47+
- Use snake_case for Python files
48+
- Use `.yaml` extension instead of `.yml` for YAML files
49+
- Keep file names concise but meaningful
50+
51+
## Import Organisation
52+
53+
- Standard library imports first
54+
- Third-party imports second
55+
- Local imports last
56+
- Use absolute imports (see no-relative-imports rule)
57+
58+
## Working with Tools
59+
60+
- Use semantic tools for code exploration (avoid full file reads when possible)
61+
- Leverage symbol indexing for fast navigation
62+
- Use grep/ripgrep for pattern matching
63+
- Read only necessary code sections
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
description: Standards for creating and maintaining examples for all functionality. (project)
3+
globs: examples/**/*
4+
paths: examples/**/*
5+
---
6+
7+
# Examples Standards
8+
9+
Standards for creating and maintaining examples in the StackOne repository.
10+
11+
## Location Requirements
12+
13+
```
14+
examples/
15+
├── basic_usage/
16+
│ ├── basic_tool_usage.py # Basic usage examples
17+
│ └── error_handling.py # Error handling examples
18+
├── integrations/ # Integration examples
19+
│ ├── openai_integration.py
20+
│ └── other_integration.py
21+
└── README.md # Examples documentation
22+
```
23+
24+
## Example Requirements
25+
26+
- Every public function/class needs at least one example
27+
- Examples should be runnable Python scripts
28+
- Include error handling cases
29+
- Load credentials from .env
30+
- Include type hints
31+
- Follow the same code style as the main codebase
32+
33+
## Documentation
34+
35+
- Each example file should start with a docstring explaining its purpose
36+
- Include expected output in comments
37+
- Document any prerequisites (environment variables, etc)
38+
39+
## Testing
40+
41+
- Examples should be tested as part of CI
42+
- Examples should work with the latest package version
43+
- Include sample responses in comments
44+
45+
## Good Example Structure
46+
47+
```python
48+
import os
49+
from dotenv import load_dotenv
50+
from stackone_ai import StackOneToolSet
51+
52+
def main():
53+
"""Example showing basic usage of StackOneToolSet."""
54+
load_dotenv()
55+
56+
api_key = os.getenv("STACKONE_API_KEY")
57+
if not api_key:
58+
raise ValueError("STACKONE_API_KEY not found")
59+
60+
# Example code...
61+
62+
if __name__ == "__main__":
63+
main()
64+
```
65+
66+
## Bad Example (avoid)
67+
68+
```python
69+
# Missing error handling, docs, types
70+
from stackone_ai import StackOneToolSet
71+
72+
toolset = StackOneToolSet("hardcoded_key")
73+
tools = toolset.get_tools("crm")
74+
result = tools["some_tool"].execute()
75+
```

.claude/rules/git-workflow.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
---
2+
description: Git workflow, commit conventions, and pull request guidelines. (project)
3+
alwaysApply: true
4+
---
5+
6+
# Git Workflow
7+
8+
This rule provides guidance on git workflow, commit conventions, and pull request guidelines.
9+
10+
## Branch Strategy
11+
12+
- **Never push directly to main** without permission
13+
- Create a new branch for changes
14+
- Create a pull request to merge into main
15+
- Use `git switch -c feature-name` to start
16+
17+
## Development Flow
18+
19+
1. Create feature branch: `git switch -c feature-name`
20+
2. Make changes to source files
21+
3. Run linter: `just lint`
22+
4. Run tests: `just test`
23+
5. Fix linting issues: `just lint-fix`
24+
6. Commit with detailed messages
25+
7. Push and create PR: `gh pr create`
26+
27+
## Commit Strategy
28+
29+
Keep commits tiny but meaningful:
30+
31+
- Use git hunks (`-p` flag) to selectively commit changes
32+
- Write detailed commit messages
33+
- Ensure each commit is logically complete
34+
- Use English for all commit messages
35+
36+
## Commit Message Format
37+
38+
Format: `type(scope): description`
39+
40+
Types: `feat`, `fix`, `docs`, `refactor`, `test`, `chore`, `ci`, `perf`
41+
42+
Example:
43+
44+
```
45+
feat(parser): add support for custom parameter transformers
46+
47+
- Add new transformer hooks to OpenAPI parser
48+
- Enable pre-processing of tool parameters
49+
- Implement docs for custom transformers
50+
```
51+
52+
### Guidelines
53+
54+
- Keep each commit as tiny as possible
55+
- Write detailed commit messages explaining the "why"
56+
- Each commit should be meaningful (not just a single line change)
57+
- Use git hunks (`-p` flag) to selectively commit related changes
58+
- **Always use English** for commit messages
59+
- Reference issues and PRs when relevant
60+
61+
### When Committing
62+
63+
1. Run `git diff` to review all changes
64+
2. Use `git add -p` to review and stage hunks selectively
65+
3. Write comprehensive message explaining the purpose
66+
4. Verify with `git status` before committing
67+
68+
### File Moves for History Preservation
69+
70+
When moving files (e.g., migrating from skills to rules), combine the deletion and creation in a single commit so git treats it as a rename. This preserves file history.
71+
72+
```bash
73+
# Instead of separate add/delete commits:
74+
git add .claude/rules/new-file.md
75+
git rm .claude/skills/old-file/SKILL.md
76+
git commit -m "refactor(rules): migrate old-file to rules directory"
77+
```
78+
79+
## Pull Request Guidelines
80+
81+
### PR Title Format
82+
83+
Use the same format as commit messages: `type(scope): description`
84+
85+
Examples:
86+
87+
- `feat(tools): add support for custom OpenAPI specs`
88+
- `fix(parser): handle empty response bodies`
89+
- `refactor(rules): unify cursor rules and claude rules`
90+
91+
### PR Body
92+
93+
Include:
94+
95+
- **Summary**: 1-3 bullet points describing changes
96+
- **Test plan**: How to verify the changes work
97+
- Reference related issues with `Closes #123` or `Fixes #123`
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
description: Enforce the use of absolute imports instead of relative imports in Python files. (project)
3+
globs: "**/*.py"
4+
paths: "**/*.py"
5+
---
6+
7+
# No Relative Imports
8+
9+
Standards for using absolute imports instead of relative imports in Python files.
10+
11+
## Guidelines
12+
13+
- Always use absolute imports starting with the full package name (`stackone_ai`)
14+
- Never use relative imports (`.` or `..`)
15+
- Keep imports organised and grouped
16+
17+
## Examples
18+
19+
```python
20+
# Good - absolute imports
21+
from stackone_ai.tools import ToolDefinition
22+
from stackone_ai.constants import OAS_DIR
23+
24+
# Bad - relative imports (don't use)
25+
from .tools import ToolDefinition
26+
from ..constants import OAS_DIR
27+
```
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
description: Standards for installing packages with UV in StackOne. (project)
3+
globs: "**/pyproject.toml"
4+
paths: "**/pyproject.toml"
5+
---
6+
7+
# Package Installation Standards
8+
9+
Standards for installing packages with UV in the StackOne repository.
10+
11+
## Root Level Dev Dependencies
12+
13+
```bash
14+
# Install dev dependencies at root level
15+
uv add --dev pytest
16+
uv add --dev pytest-cov
17+
uv add --dev black
18+
```
19+
20+
## Package Level Dependencies
21+
22+
```bash
23+
# Install package dependencies
24+
uv add pydantic
25+
uv add requests
26+
```
27+
28+
## Never Use
29+
30+
```bash
31+
# ❌ Don't use pip install
32+
uv pip install package-name
33+
34+
# ❌ Don't use -e or editable installs
35+
uv pip install -e .
36+
```
37+
38+
## Running Tests
39+
40+
```bash
41+
# Run from root directory
42+
uv run pytest
43+
44+
# Run specific package tests
45+
uv run pytest stackone_ai
46+
47+
# Run tests on examples
48+
uv run pytest examples
49+
```
50+
51+
## Package Dependencies in pyproject.toml
52+
53+
```toml
54+
[project]
55+
dependencies = [
56+
"pydantic>=2.10.6",
57+
"requests>=2.32.3",
58+
]
59+
```
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
description: Standards for using release-please in the repository. (project)
3+
alwaysApply: true
4+
---
5+
6+
# Release Please Standards
7+
8+
Standards for managing releases with release-please in the repository.
9+
10+
## Configuration Files
11+
12+
```
13+
.release-please-config.json # Release configuration
14+
.release-please-manifest.json # Version tracking
15+
.github/workflows/release.yml # Release workflow
16+
```
17+
18+
## Commit Message Format
19+
20+
```bash
21+
# Features (0.1.0 -> 0.2.0)
22+
feat: add new feature
23+
feat!: breaking change feature
24+
25+
# Bug Fixes (0.1.0 -> 0.1.1)
26+
fix: bug fix description
27+
28+
# No Version Change
29+
docs: update readme
30+
chore: update dependencies
31+
test: add new tests
32+
```
33+
34+
## Release Process
35+
36+
1. Push to main branch triggers release-please
37+
2. Release-please creates/updates release PR
38+
3. Merging release PR:
39+
- Updates CHANGELOG.md
40+
- Creates GitHub release
41+
- Publishes to PyPI using UV
42+
43+
## Required Secrets
44+
45+
```
46+
PYPI_API_TOKEN # For publishing to PyPI
47+
```
48+
49+
## Good Commit Messages
50+
51+
```bash
52+
docs: update installation guide
53+
fix: handle API timeout errors
54+
feat: add new CRM integration
55+
```
56+
57+
## Bad Commit Messages (avoid)
58+
59+
```bash
60+
updated readme
61+
fixed bug in api
62+
added feature
63+
```

0 commit comments

Comments
 (0)