Development environment and guidelines for QGIS scripts, plugins, and tools following mqs repository standards
Development assistant for QGIS-related projects following the mqs (My QGIS Stuff) repository standards. This skill helps with creating QGIS Processing Toolbox scripts, QGIS plugins, and maintaining proper project structure.
**ALWAYS enforce these requirements:**
1. **Testing First**
- Write tests alongside implementation
- Run tests before marking work complete
- All test files go in `testing/` directory
- Never implement features without corresponding tests
2. **Version Management**
- Add `__version__ = "x.y.z"` to all code files
- Follow semantic versioning (MAJOR.MINOR.PATCH)
- Update `CHANGELOG.md` with every version bump
- Include version number and date in changelog entries
Understand the two main code categories:
**Processing Toolbox Scripts** (`Scripts/` directory):
**QGIS Plugins** (`Plugins/` directory):
When user requests a new QGIS Processing script:
1. Create directory structure:
```bash
mkdir -p docs/[SubprojectName]/testing
```
2. Create script at `Scripts/[scriptname].py` with:
- Version header: `__version__ = "0.1.0"`
- Class inheriting from `QgsProcessingAlgorithm`
- Group set to "MQS Tools"
- Comprehensive help text
- Proper parameter definitions
3. Create documentation files:
- `docs/[SubprojectName]/README.md` - User guide
- `docs/[SubprojectName]/REQUIREMENTS.md` - Technical specs
- `docs/[SubprojectName]/CHANGELOG.md` - Start with v0.1.0 entry
4. Create test file in `docs/[SubprojectName]/testing/`
5. Update main `README.md` with new subproject
When user requests a new plugin:
1. Suggest using QGIS Plugin Builder first if starting from scratch
2. Set up structure:
```bash
mkdir -p Plugins/[plugin_name]
mkdir -p docs/[plugin_name]/testing
```
3. Ensure plugin has:
- `__init__.py` with `classFactory()` function
- `metadata.txt` with proper metadata (qgisMinimumVersion=3.40)
- Main plugin class file
- `resources.qrc` for resources
- `Makefile` or `pb_tool.cfg` for building
- `test/` directory for tests
4. Create documentation:
- `docs/[plugin_name]/README.md` - Installation and usage
- `docs/[plugin_name]/REQUIREMENTS.md` - Technical specs
- `docs/[plugin_name]/CHANGELOG.md` - Version history
5. Compile resources:
```bash
cd Plugins/[plugin_name]
pyrcc5 -o resources.py resources.qrc
```
6. Update main `README.md`
When user requests changes to existing code:
1. Read the current version from the file
2. Determine version bump type:
- PATCH: Bug fixes, minor changes
- MINOR: New features, backward compatible
- MAJOR: Breaking changes
3. Update `__version__` in code
4. Update or create entry in `CHANGELOG.md`:
```markdown
## [x.y.z] - YYYY-MM-DD
### Added/Changed/Fixed
- Description of changes
```
5. Write or update tests for the changes
6. Run tests to verify
Before marking any work complete:
1. Verify test file exists in appropriate `testing/` directory
2. Run tests:
```bash
python -m unittest discover -s testing
```
3. Ensure all tests pass
4. If tests fail, fix issues before proceeding
Every subproject must have:
```
User: Create a new QGIS script that merges all shapefiles in a directory
Steps:
1. Create docs/ShapefileMerger/testing/
2. Write Scripts/shapefile_merger.py with:
- __version__ = "0.1.0"
- Class inheriting QgsProcessingAlgorithm
- group() returns "MQS Tools"
- Input: folder parameter
- Output: merged layer
3. Create docs/ShapefileMerger/README.md
4. Create docs/ShapefileMerger/REQUIREMENTS.md
5. Create docs/ShapefileMerger/CHANGELOG.md with v0.1.0
6. Write test_shapefile_merger.py in testing/
7. Run tests
8. Update main README.md
```
```
User: Add option to filter by geometry type in vectors2gpkg
Steps:
1. Read Scripts/vectors2gpkg.py (current version: 0.8.3)
2. Implement geometry filter parameter
3. Update __version__ to "0.9.0" (new feature = MINOR bump)
4. Update docs/vectors2gpkg/CHANGELOG.md:
## [0.9.0] - 2024-XX-XX
### Added
- Geometry type filter option
5. Update or add test case in testing/
6. Run tests
7. Verify all tests pass
```
```
User: Create a plugin for batch layer styling
Steps:
1. Suggest: "Let's use QGIS Plugin Builder first"
2. After builder output:
- Move to Plugins/batch_styler/
- Create docs/batch_styler/testing/
3. Update metadata.txt:
- version=0.1.0
- qgisMinimumVersion=3.40
- experimental=True
4. Create documentation files in docs/batch_styler/
5. Compile resources:
cd Plugins/batch_styler && make
6. Create tests in Plugins/batch_styler/test/
7. Update main README.md
```
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/qgis-development-environment/raw