Contributing
Thank you for your interest in contributing to MateClaw. This guide covers the development setup, coding conventions, and pull request workflow.
Getting Started
1. Fork and Clone
bash
git clone https://github.com/YOUR_USERNAME/mateclaw.git
cd mateclaw2. Set Up the Backend
bash
cd mateclaw-server
export DASHSCOPE_API_KEY=your-key
mvn spring-boot:run3. Set Up the Frontend
bash
cd mateclaw-ui
pnpm install
pnpm dev4. Verify
Open http://localhost:5173, log in with admin / admin123, and send a test message.
Development Workflow
- Create a feature branch from
main:
bash
git checkout -b feat/your-feature-name- Make your changes with clear, incremental commits
- Test your changes (see Testing section below)
- Push and open a pull request
Branch Naming
| Prefix | Purpose | Example |
|---|---|---|
feat/ | New feature | feat/voice-input |
fix/ | Bug fix | fix/sse-reconnect |
docs/ | Documentation | docs/api-reference |
refactor/ | Code refactoring | refactor/agent-state |
chore/ | Build, deps, tooling | chore/upgrade-spring-boot |
Commit Messages
Follow the Conventional Commits format:
type(scope): brief description
Optional longer description explaining the change.Examples:
feat(agent): add max iteration limit to ReAct loop
fix(channel): handle DingTalk message encoding correctly
docs(tools): add examples for WebSearchTool
chore(deps): upgrade Spring Boot to 3.5.1Backend Conventions
Package Structure
Place new code in the appropriate vip.mate.* package:
| You are adding... | Package |
|---|---|
| A new tool | vip.mate.tool |
| A new channel adapter | vip.mate.channel |
| A new agent type | vip.mate.agent |
| Utility code | vip.mate.common |
Code Style
- Java 17+ features are encouraged (records, sealed classes, text blocks, pattern matching)
- Use constructor injection (not field injection) for Spring beans
- Follow existing naming:
XxxService,XxxController,XxxMapper - All database tables use the
mate_prefix - Use MyBatis Plus for data access (not JPA)
Adding a New Tool
- Create a class in
vip.mate.tool:
java
@Component
public class MyNewTool {
@Tool(description = "Description for the LLM")
public String myMethod(
@ToolParam(description = "Parameter description") String input) {
// Implementation
return "result";
}
}- If the tool is dangerous, add it to the ToolGuard list in
application.yml - Add a test class
Adding a New Channel
- Create a class in
vip.mate.channelimplementingChannelAdapter - Register the webhook endpoint in a controller
- Add configuration properties
- Update the documentation
Frontend Conventions
Code Style
- Use the Composition API with
<script setup>for all new components - TypeScript is required -- no
anytypes unless absolutely necessary - Use Pinia stores for shared state, local
ref/reactivefor component state - Prefer Element Plus components over custom implementations
- Use TailwindCSS utilities; avoid inline styles
- Use the
@path alias for imports
Adding a New Page
- Create the view component in
views/ - Add a route in
router/ - Add translations in
i18n/zh-CN.tsandi18n/en-US.ts - If the page has shared state, create a Pinia store in
stores/
Component Structure
vue
<script setup lang="ts">
import { ref, onMounted } from 'vue';
import { useAgentStore } from '@/stores/agent';
const agentStore = useAgentStore();
const loading = ref(false);
onMounted(async () => {
loading.value = true;
await agentStore.fetchAgents();
loading.value = false;
});
</script>
<template>
<div class="p-4">
<el-table :data="agentStore.agents" v-loading="loading">
<!-- columns -->
</el-table>
</div>
</template>Testing
Backend Tests
bash
cd mateclaw-server
mvn test # All tests
mvn test -Dtest=ReActAgentTest # Single class
mvn test -Dtest=ReActAgentTest#testChat # Single methodFrontend Linting
bash
cd mateclaw-ui
pnpm lintManual Testing Checklist
Before submitting a PR, verify:
- [ ] Backend starts without errors
- [ ] Frontend builds without type errors (
pnpm build) - [ ] Login works with default credentials
- [ ] Chat with the default agent produces a response
- [ ] New feature works as described in the PR
- [ ] No console errors in the browser
Pull Request Process
- Title: Use the conventional commit format (
feat(scope): description) - Description: Explain what the PR does and why
- Screenshots: Include screenshots for UI changes
- Testing: Describe how you tested the changes
- Breaking changes: Clearly note any breaking changes
PR Template
markdown
## What
Brief description of the change.
## Why
Why this change is needed.
## How
Technical approach taken.
## Testing
How this was tested.
## Screenshots (if UI changes)
Before / After screenshots.Reporting Issues
When filing a bug report, include:
- MateClaw version (or commit hash)
- Java version and OS
- Steps to reproduce
- Expected vs. actual behavior
- Relevant log output
Next Steps
- Quick Start -- Development setup
- Architecture -- Project structure overview
- Roadmap -- Planned features to work on
