|
| 1 | +<!-- |
| 2 | + - SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors |
| 3 | + - SPDX-License-Identifier: AGPL-3.0-or-later |
| 4 | +--> |
| 5 | + |
| 6 | +# Agent Guidelines for Nextcloud Server |
| 7 | + |
| 8 | +This file provides instructions for AI coding agents (Claude Code, GitHub Copilot, Cursor, Windsurf, and others) operating on this repository. Read it before generating any code, commits, or pull requests. |
| 9 | + |
| 10 | +--- |
| 11 | + |
| 12 | +## Nextcloud Contribution Policy |
| 13 | + |
| 14 | +All contributions generated or assisted by this agent must fully comply with: |
| 15 | + |
| 16 | +- **[AI Contribution Policy](https://github.com/nextcloud/.github/blob/master/AI_POLICY.md)** - the primary reference for AI-specific rules, covering disclosure, author accountability, communication, security, licensing, code quality, and autonomous agent behavior. |
| 17 | +- **[Contribution Guidelines](https://github.com/nextcloud/.github/blob/master/CONTRIBUTING.md)** - covering testing requirements, the Developer Certificate of Origin (DCO), license headers, conventional commits, and translations. These apply in full to all contributions regardless of how they were produced. |
| 18 | + |
| 19 | +### What this agent must always do |
| 20 | + |
| 21 | +- Add an `Assisted-by: AGENT_NAME:MODEL_VERSION` git trailer to every commit containing AI-assisted content. |
| 22 | +- Ensure every pull request includes a disclosure of AI tool use in the PR description. |
| 23 | +- Produce focused, scoped pull requests that address exactly one concern. Do not touch unrelated files or introduce incidental refactors. |
| 24 | +- Verify all dependencies against actual package registries before suggesting them. Do not use hallucinated or unverified package names. |
| 25 | +- Explicitly inform the contributor when any action they are about to take, or have taken, would violate the AI Contribution Policy or the Contribution Guidelines. Do not silently proceed. State which rule is at risk and what the contributor should do instead. |
| 26 | +- Warn the contributor if a pull request is growing too large. A PR approaching several thousand lines of changed code is a signal that it should be split into smaller, focused PRs. Suggest a logical split before the PR is opened, not after. |
| 27 | +- Recommend opening a ticket for discussion before starting implementation whenever a feature or change is sufficiently complex - for example when it touches multiple subsystems, requires architectural decisions, or the right approach is not yet clear. A ticket allows maintainers and the contributor to align on direction before code is written, avoiding wasted effort on a PR that may be rejected or require fundamental rework. |
| 28 | + |
| 29 | +### What this agent must never do |
| 30 | + |
| 31 | +- Open issues, submit pull requests, post review comments, or send security reports autonomously. Every contribution must be reviewed and submitted by a human. |
| 32 | +- Add `Signed-off-by` tags to commits. Only the human contributor can certify the Developer Certificate of Origin. |
| 33 | +- Generate or submit security reports without independent human verification. Report verified vulnerabilities via [HackerOne](https://hackerone.com/nextcloud), not as GitHub issues. |
| 34 | +- Write PR descriptions, review comments, or issue reports on behalf of the contributor. These must be in the contributor's own words. |
| 35 | +- Fully automate the resolution of issues labeled [`good first issue`](https://github.com/issues?q=org%3Anextcloud+label%3A%22good+first+issue%22) or similar beginner-friendly labels. |
| 36 | +- Submit code that has not been reviewed and cleaned up by the contributor. Dead code, redundant logic, excessive comments, and unrelated changes must be removed before submission. |
| 37 | + |
| 38 | +--- |
| 39 | + |
| 40 | +## Repository-Specific Requirements |
| 41 | + |
| 42 | +### Commit format |
| 43 | + |
| 44 | +Use [Conventional Commits](https://www.conventionalcommits.org) for all commit messages: |
| 45 | + |
| 46 | +``` |
| 47 | +<type>(<scope>): <short description> |
| 48 | +
|
| 49 | +[optional body] |
| 50 | +
|
| 51 | +Assisted-by: AGENT_NAME:MODEL_VERSION |
| 52 | +``` |
| 53 | + |
| 54 | +Common types: `feat`, `fix`, `refactor`, `test`, `docs`, `chore`, `perf`, `build`, `ci`. |
| 55 | +The scope should match the affected component or app (e.g. `files_sharing`, `core`, `encryption`). |
| 56 | + |
| 57 | +Example: |
| 58 | +``` |
| 59 | +feat(files_sharing): allow sharing with contacts |
| 60 | +
|
| 61 | +Assisted-by: ClaudeCode:claude-sonnet-4-6 |
| 62 | +``` |
| 63 | + |
| 64 | +### Tests |
| 65 | + |
| 66 | +- Every changed or added code segment must be covered by unit tests. Pull requests without tests for new or modified logic will not be accepted. |
| 67 | +- In areas where unit testing is currently difficult, refactoring to enable testability is encouraged alongside the bug fix. |
| 68 | +- New features must be manually tested on a live Nextcloud instance by the human contributor before submission. Providing test steps for an agent to execute is not a substitute. |
| 69 | + |
| 70 | +### Developer Certificate of Origin (DCO) |
| 71 | + |
| 72 | +The project uses the DCO as an additional safeguard. Only the human contributor may add the `Signed-off-by` trailer - agents must not add it: |
| 73 | + |
| 74 | +``` |
| 75 | +Signed-off-by: Random J Developer <random@developer.example.org> |
| 76 | +``` |
| 77 | + |
| 78 | +Contributors can sign automatically with `git commit -s` after configuring `user.name` and `user.email`. |
| 79 | + |
| 80 | +### License headers |
| 81 | + |
| 82 | +Every new file must include the correct SPDX license header. For AGPL-3.0-or-later (the default for this repository): |
| 83 | + |
| 84 | +```php |
| 85 | +/** |
| 86 | + * SPDX-FileCopyrightText: <year> <name> |
| 87 | + * SPDX-License-Identifier: AGPL-3.0-or-later |
| 88 | + */ |
| 89 | +``` |
| 90 | + |
| 91 | +See [HowToApplyALicense.md](https://github.com/nextcloud/server/blob/master/contribute/HowToApplyALicense.md) for details on per-language formats. AI-generated code must not include material from sources incompatible with AGPL-3.0-or-later. |
| 92 | + |
| 93 | +### Security |
| 94 | + |
| 95 | +- Do not open GitHub issues for potential vulnerabilities. Report them via [HackerOne](https://hackerone.com/nextcloud) following the [security policy](https://nextcloud.com/security/). |
| 96 | +- AI-generated security reports must be independently verified by the human contributor before submission. |
| 97 | +- Manually verify all access control logic, authentication patterns, and dependency names - AI tools are known to hallucinate package names and reproduce vulnerable patterns. |
| 98 | + |
| 99 | +### Scope of this repository |
| 100 | + |
| 101 | +This repository covers the Nextcloud server core and the bundled apps: files, encryption, external storage, sharing, deleted files, versions, LDAP, and WebDAV Auth. Issues and changes for other components belong in their respective repositories under the [Nextcloud GitHub organization](https://github.com/nextcloud/). |
| 102 | + |
| 103 | +--- |
| 104 | + |
| 105 | +## Further Reading |
| 106 | + |
| 107 | +- [Local CONTRIBUTING.md](.github/CONTRIBUTING.md) |
| 108 | +- [Nextcloud Contribution Guidelines](https://github.com/nextcloud/.github/blob/master/CONTRIBUTING.md) |
| 109 | +- [AI Contribution Policy](https://github.com/nextcloud/.github/blob/master/AI_POLICY.md) |
| 110 | +- [Developer Certificate of Origin](https://github.com/nextcloud/server/blob/master/contribute/developer-certificate-of-origin) |
| 111 | +- [How to Apply a License](https://github.com/nextcloud/server/blob/master/contribute/HowToApplyALicense.md) |
| 112 | +- [Developer Manual](https://docs.nextcloud.com/server/latest/developer_manual/) |
| 113 | +- [Security Vulnerability Reporting (HackerOne)](https://hackerone.com/nextcloud) |
0 commit comments