|
| 1 | +# Contributing |
| 2 | + |
| 3 | +We're excited to welcome you as a contributor to our project! |
| 4 | + |
| 5 | +## How to Contribute |
| 6 | + |
| 7 | +There are many ways to contribute to **CTX**: |
| 8 | + |
| 9 | +1. **Report Issues**: If you find a bug or have a |
| 10 | + suggestion, [create an issue](https://github.com/context-hub/generator/issues) on our GitHub repository. |
| 11 | +2. **Submit Pull Requests**: Have a fix or a new feature? Submit a pull request! |
| 12 | +3. **Improve Documentation**: Help us make our [documentation](https://github.com/context-hub/docs) more clear, |
| 13 | + comprehensive, and accessible. |
| 14 | +4. **Share Your Use Cases**: Let us know how you're using **CTX** in your projects. |
| 15 | + |
| 16 | +We label issues that are suitable for community contribution with the `help wanted` tag. Additionally, we use labels |
| 17 | +such as `good first issue` for newcomer-friendly tasks, and complexity indicators to help you choose tasks that match |
| 18 | +your experience level. |
| 19 | + |
| 20 | +## Getting Started with Contributing |
| 21 | + |
| 22 | +Follow this guide to set up your environment and effectively contribute to the **CTX** project. We've designed |
| 23 | +a workflow that leverages the tool's own capabilities to help you understand and improve the codebase. |
| 24 | + |
| 25 | +### 1. Set Up Your Environment |
| 26 | + |
| 27 | +```bash |
| 28 | +# Fork and clone the repository |
| 29 | +git clone https://github.com/YOUR-USERNAME/context-generator.git |
| 30 | +cd context-generator |
| 31 | + |
| 32 | +# Install dependencies |
| 33 | +composer install |
| 34 | + |
| 35 | +# Make the CLI tool available locally |
| 36 | +chmod +x ctx |
| 37 | + |
| 38 | +# Test the command |
| 39 | +./ctx --help |
| 40 | +``` |
| 41 | + |
| 42 | +> **Note:** Use the local `./ctx` command during development to test your changes. The globally installed`ctx` command |
| 43 | +> won't reflect your local modifications. |
| 44 | +
|
| 45 | +### 2. Understand the Project Structure |
| 46 | + |
| 47 | +Before diving into specific components, familiarize yourself with the project structure. To get a detailed view of the |
| 48 | +project structure, use the `tree` source type: |
| 49 | + |
| 50 | +```yaml |
| 51 | +documents: |
| 52 | + - description: Project File Structure |
| 53 | + outputPath: docs/file-structure.md |
| 54 | + sources: |
| 55 | + - type: tree |
| 56 | + description: Project File Structure |
| 57 | + sourcePaths: |
| 58 | + - src |
| 59 | +``` |
| 60 | +
|
| 61 | +Run this configuration to generate a visual representation of the codebase structure: |
| 62 | +
|
| 63 | +```bash |
| 64 | +./ctx |
| 65 | +``` |
| 66 | + |
| 67 | +This will create a `docs/file-structure.md` file that outlines the project's organization. Put this file in the |
| 68 | +Claude project context to help it understand the codebase. |
| 69 | + |
| 70 | +### 3. Request Specific Context Using YAML |
| 71 | + |
| 72 | +When working on a specific feature or bug fix, create targeted context requests to get exactly the information you need. |
| 73 | + |
| 74 | +You can also describe your task to an LLM and ask it to suggest which files might be relevant to your problem. |
| 75 | + |
| 76 | +> **Tip:** If you provide a json-schema file, the LLM will be able to generate a valid context.yaml file for you. |
| 77 | +
|
| 78 | +```yaml |
| 79 | +# Example: Create focused context for exploring source types |
| 80 | +documents: |
| 81 | + - description: "Source Type Implementation" |
| 82 | + outputPath: "my-feature-context.md" |
| 83 | + sources: |
| 84 | + - type: file |
| 85 | + sourcePaths: [ "src/Source/FileType" ] |
| 86 | + filePattern: "*.php" |
| 87 | + - type: file |
| 88 | + sourcePaths: [ "src/Source" ] |
| 89 | + filePattern: "*Interface.php" |
| 90 | +``` |
| 91 | +
|
| 92 | +Generate your custom context: |
| 93 | +
|
| 94 | +```bash |
| 95 | +./ctx |
| 96 | +``` |
| 97 | + |
| 98 | +This structured approach offers several advantages: |
| 99 | + |
| 100 | +- **Precision**: Request only what you need without excess information |
| 101 | +- **Structure**: Use the application's own configuration format for clarity |
| 102 | +- **Progressive Discovery**: Build your understanding incrementally |
| 103 | +- **Efficiency**: Focus on relevant parts of the codebase |
| 104 | + |
| 105 | +Let me enhance the section on collaborating with AI assistants to include this important recommendation: |
| 106 | + |
| 107 | +### 4. Collaborate with AI Assistants |
| 108 | + |
| 109 | +Share the generated context files with AI assistants like Claude to get help with: |
| 110 | + |
| 111 | +- Understanding complex parts of the codebase |
| 112 | +- Designing new features |
| 113 | +- Debugging issues |
| 114 | +- Reviewing your implementation approach |
| 115 | + |
| 116 | +Before diving into implementation, ask the LLM to help you generate: |
| 117 | + |
| 118 | +- **Feature Request documents** for new functionality |
| 119 | +- **RFC (Request for Comments)** for architectural changes |
| 120 | +- **Bug reports** with comprehensive details |
| 121 | +- **Implementation plans** outlining the approach |
| 122 | + |
| 123 | +These documents serve multiple purposes: |
| 124 | + |
| 125 | +1. They help clarify your own understanding of the task |
| 126 | +2. They can be used to create GitHub issues with well-structured information |
| 127 | +3. They provide a reference document you can share in new chat sessions |
| 128 | +4. They ensure all aspects of the problem are considered before coding begins |
| 129 | + |
| 130 | +For example, you might ask: |
| 131 | + |
| 132 | +```yaml |
| 133 | +documents: |
| 134 | + - description: "Current Composer Source Implementation" |
| 135 | + outputPath: "composer-source-current.md" |
| 136 | + sources: |
| 137 | + - type: file |
| 138 | + sourcePaths: [ "src/Source/Composer/" ] |
| 139 | + filePattern: [ "ComposerSource.php", "ComposerSourceFetcher.php" ] |
| 140 | +``` |
| 141 | +
|
| 142 | +**Then ask Claude:** |
| 143 | +"Based on this implementation, please generate an RFC for adding remote repository support to the Composer source. |
| 144 | +Include the problem statement, proposed solution, implementation details, and potential challenges." |
| 145 | +
|
| 146 | +This gives the AI assistant exactly the context needed to provide meaningful assistance with your specific task, and the |
| 147 | +resulting document becomes a valuable asset throughout your development process. |
| 148 | +
|
| 149 | +### 5. Implement Your Changes |
| 150 | +
|
| 151 | +> **Tip**: When you provide all required context to Claude, it will be able to solve your task efficiently. With proper |
| 152 | +> context, the solution will be fast, precise, and aligned with the project's patterns and standards. |
| 153 | +
|
| 154 | +With a solid understanding of the codebase: |
| 155 | +
|
| 156 | +- Create a new branch for your changes |
| 157 | +- Implement your feature or fix following these steps: |
| 158 | + 1. Provide the generated context to Claude or another AI assistant |
| 159 | + 2. Clearly describe what you're trying to implement |
| 160 | + 3. With proper context, Claude can help generate precise, working solutions quickly |
| 161 | + 4. Review the suggested implementation and adapt as needed |
| 162 | +- Add tests to verify your changes |
| 163 | +- Update or add documentation as needed: |
| 164 | + 1. Provide the existing documentation section to Claude |
| 165 | + 2. Ask Claude to update or rewrite the section with your changes |
| 166 | + 3. Review and refine the suggested documentation |
| 167 | + 4. Include the updated documentation in your pull request |
| 168 | +
|
| 169 | +### 6. Document Your Changes |
| 170 | +
|
| 171 | +If you worked with an LLM to implement your changes, ask it to help draft commit messages and pull request descriptions. |
| 172 | +
|
| 173 | +You can also generate a diff for your changes and ask an LLM to analyze it: |
| 174 | +
|
| 175 | +```yaml |
| 176 | +# Generate context for your changes |
| 177 | +documents: |
| 178 | + - description: "My Feature Implementation" |
| 179 | + outputPath: "my-changes.md" |
| 180 | + sources: |
| 181 | + - type: git_diff |
| 182 | + description: "My Changes" |
| 183 | + commit: "unstaged" # or "staged" if you've already staged your changes |
| 184 | +``` |
| 185 | +
|
| 186 | +### 7. Code Quality Checks |
| 187 | +
|
| 188 | +Before submitting your pull request, ensure your code meets our quality standards: |
| 189 | +
|
| 190 | +#### Code Style Standards |
| 191 | +
|
| 192 | +- **PHP 8.3+** minimum requirement |
| 193 | +- **Strict typing**: All files must use `declare(strict_types=1)` |
| 194 | +- **camelCase** for enum cases (not SCREAMING_SNAKE_CASE) |
| 195 | +- **Namespace consistency**: Follow `Butschster\ContextGenerator\*` pattern |
| 196 | +- **Final classes**: Classes should be `final` unless designed for extension |
| 197 | + |
| 198 | +#### Architecture Patterns |
| 199 | + |
| 200 | +Follow these established patterns: |
| 201 | + |
| 202 | +- **Immutable DTOs**: Use readonly classes and value objects |
| 203 | +- **Interface segregation**: Create clear interfaces for all major components |
| 204 | +- **Factory pattern**: Use factories for creating configured instances |
| 205 | +- **Registry pattern**: Centralize registration of sources, modifiers, etc. |
| 206 | +- **Bootloader pattern**: Follow Spiral-style service registration |
| 207 | + |
| 208 | +#### Running Quality Tools |
| 209 | + |
| 210 | +Run these commands to ensure code quality: |
| 211 | + |
| 212 | +```bash |
| 213 | +# Check code style (dry run) |
| 214 | +composer cs-check |
| 215 | +
|
| 216 | +# Fix code style issues automatically |
| 217 | +composer cs-fix |
| 218 | +
|
| 219 | +# Run static analysis |
| 220 | +composer psalm |
| 221 | +
|
| 222 | +# Apply automated refactoring |
| 223 | +composer refactor |
| 224 | +
|
| 225 | +# Run tests |
| 226 | +composer test |
| 227 | +``` |
| 228 | + |
| 229 | +**Important**: Always run `composer cs-check` and `composer psalm` before submitting your PR. Fix any issues reported by |
| 230 | +these tools. |
| 231 | + |
| 232 | +### 8. Submit Your Pull Request |
| 233 | + |
| 234 | +- Push your changes to your fork |
| 235 | +- Open a pull request with a clear description |
| 236 | +- Include relevant context files or excerpts |
| 237 | +- Reference any related issues |
| 238 | +- Ensure all quality checks pass |
| 239 | + |
| 240 | +By using **CTX** in your contribution workflow, you'll not only improve the project but also gain firsthand |
| 241 | +experience with the tool while developing more effective collaboration patterns with AI assistants. |
| 242 | + |
| 243 | +## Areas Where Help Is Needed |
| 244 | + |
| 245 | +We're particularly looking for help with: |
| 246 | + |
| 247 | +- Adding support for additional source types |
| 248 | +- Enhancing documentation with more examples |
| 249 | +- Creating specialized content modifiers for different languages |
| 250 | +- Building integrations with popular IDEs and tools |
| 251 | + |
| 252 | +Your contributions, big or small, help make **CTX** a better tool for everyone. We look forward to |
| 253 | +collaborating with you! |
| 254 | + |
| 255 | +## Questions? |
| 256 | + |
| 257 | +If you have any questions about contributing, feel free to open an issue labeled "question" or reach out through the |
| 258 | +[discussions](https://github.com/context-hub/generator/discussions) section on GitHub. |
| 259 | + |
| 260 | +Thank you for considering contributing to **CTX**! |
0 commit comments