This file provides AI and human contributors with a high-level architectural guide and navigation map for SublinkPro.
This is a HARD STOP requirement. No exceptions. No shortcuts. No "will fix later". No "just this once".
┌─────────────────────────────────────────────────────────────┐
│ 🛑 BLOCKING REQUIREMENT - READ THIS FIRST │
├─────────────────────────────────────────────────────────────┤
│ │
│ BEFORE any git commit, git add, or PR creation: │
│ │
│ 1. You MUST invoke: pre-commit-check skill │
│ 2. You MUST execute ALL applicable validation commands │
│ 3. You MUST fix ALL failures before proceeding │
│ 4. You MUST document what was validated │
│ │
│ Violations of this rule constitute incomplete work. │
│ │
└─────────────────────────────────────────────────────────────┘
You MUST invoke .agents/skills/pre-commit-check/SKILL.md BEFORE:
- Running
git addorgit commit- Whether initiated by you or requested by user - Creating or updating a PR - Via
gh pr createor any PR command - Declaring work "complete", "done", or "finished" - In any form
- User explicitly asks to commit - Even if they say "skip checks" (refuse and explain why)
- Any code change is ready for commit - Backend, frontend, docs, config, or mixed
Code Change Complete
↓
├─> Did you invoke pre-commit-check skill?
│ ├─> NO → STOP. Invoke it now. DO NOT PROCEED.
│ └─> YES → Continue
↓
├─> Did ALL validation commands pass?
│ ├─> NO → STOP. Fix failures. Re-run validation. DO NOT PROCEED.
│ └─> YES → Continue
↓
├─> Did you stage ONLY intended changes?
│ ├─> NO → STOP. Review staged files. Remove unintended. DO NOT PROCEED.
│ └─> YES → Continue
↓
├─> Did you prepare a proper commit message?
│ ├─> NO → STOP. Prepare semantic commit message. DO NOT PROCEED.
│ └─> YES → Continue
↓
Ready to Commit (present to user for final review)
Validation is NOT complete until ALL of the following are verified:
-
gofmt -wexecuted on all changed Go files -
gofmt -lreturns no files (all formatted) -
golangci-lint runexits with status 0 (no errors) -
go test ./...passes (or at minimum, relevant package tests pass) - No compilation errors
-
cd webs && yarn run lintexits with status 0 (no errors) -
cd webs && yarn run buildsucceeds (if routing/assets/build affected) - No build warnings about missing imports or broken dependencies
- Backend API changes → Frontend updated
- Frontend contract changes → Backend verified
- Config changes → Code + docs updated
- Skill verified:
.agents/skills/cross-layer-sync/SKILL.md(if complex)
- User-facing docs updated (both
.mdand.zh-CN.md) - API docs updated (
skill-sublinkpro/reference/api.md) - Config docs updated (
docs/configuration.md+.zh-CN.md) - Links verified (no broken references)
- Skill verified:
.agents/skills/doc-sync-check/SKILL.md(if complex)
- Tests added for new business logic
- Tests updated for changed behavior
- Regression tests added for bug fixes
- All tests passing
- Only intended files staged (no accidental includes)
- No sensitive files staged (
.env, credentials, keys) - No runtime data staged (
db/,logs/,cache/,out/) - No large binary files unintentionally staged
- No AI agent temporary files staged:
- No
*_SUMMARY.md,*_REPORT.mdin skill directories - No
QUICK_REFERENCE.mdfiles (execution artifacts) - No
.claude/projects/,.claude/sessions/,.claude/plans/runtime files - No agent execution logs or temporary outputs
- No
- Semantic prefix used (
feat:,fix:,docs:,refactor:,test:,chore:) - Subject line ≤72 characters
- Body explains what, why, and how validated
- References issues if applicable (
Closes #123,Fixes #456)
❌ "Let me commit this first, I'll fix validation later"
- Rejection: No. Fix validation now. Commits must be clean.
❌ "This is a small change, we can skip validation"
- Rejection: No. Small changes still need validation. No exceptions.
❌ "The user said skip checks"
- Rejection: No. Explain to user why checks are mandatory. Refuse to skip.
❌ "Validation failed but I'll commit anyway"
- Rejection: No. Fix failures first. Do not proceed with broken validation.
❌ "I'll update docs in a separate commit"
- Rejection: No. Docs are part of the same change. Update together.
❌ "Tests will be added later"
- Rejection: No. Tests are part of the deliverable. Add them now.
❌ Auto-committing without user verification
- Rejection: No. Stage changes and let user verify before committing.
When a user says "just commit it" or "skip the checks":
Your response should be:
I cannot commit without running validation checks. This is a mandatory
requirement for code quality and consistency.
The checks take only a few minutes and ensure:
- No linting errors that will fail CI
- No broken builds
- No test failures
- Cross-layer synchronization
- Documentation consistency
I'll run the validation now. If everything passes, I'll stage the changes
and you can commit immediately.
Then proceed to invoke the pre-commit-check skill and run all validations.
For complete validation procedures, checklists, and commands, see:
Primary Skill: .agents/skills/pre-commit-check/SKILL.md
- Complete validation command reference
- Layer-by-layer validation steps
- Troubleshooting guide
- Exit criteria
Supporting Skills:
.agents/skills/post-dev-workflow/SKILL.md- Full post-development orchestration.agents/skills/cross-layer-sync/SKILL.md- Cross-layer synchronization guide.agents/skills/doc-sync-check/SKILL.md- Documentation synchronization.agents/skills/theme-check/SKILL.md- Theme/UI validation.agents/skills/security-review/SKILL.md- Security validation.agents/skills/performance-check/SKILL.md- Performance validation
This rule applies to AI agents. Human contributors should also follow these practices, but are trusted to use their judgment.
If you're a human reading this:
- We recommend using the same validation workflow
- Consider setting up a git pre-commit hook to automate checks
- See
CONTRIBUTING.mdfor detailed contribution guidelines
- Validation First: No commit without validation. No exceptions.
- All Checks Pass: All validation commands must exit successfully. Fix failures before proceeding.
- User Verification: Stage changes and present to user. Do not auto-commit.
AI agents are FORBIDDEN from creating temporary, debug, scratch, or generated explanation files anywhere in the repository except the project-local .agents/.tmp/ directory.
Do not write agent work files to the operating system temp directory. For this project, /tmp, /var/tmp, and other system temp locations are not allowed for agent debugging, scratch work, temporary tests, logs, screenshots, reports, or intermediate outputs.
❌ DO NOT create ANY of the following outside .agents/.tmp/:
- Documentation files:
*.md(except when explicitly requested by user to update existing docs) - Summary files:
SUMMARY.md,IMPLEMENTATION_*.md,FEATURE_*.md,TEST_*.md, etc. - Temporary test files:
test_*.go,test_*.js,debug_*.py, etc. - Debug output files:
output.txt,result.json,debug.log, etc. - Notes or scratch files:
notes.txt,TODO.md,scratch.py, etc. - ANY file with names like:
QUICK_REFERENCE.md,REPORT.md, etc.
✅ ONLY use this location for agent temporary/test/debug files:
.agents/.tmp/at the repository root
Create .agents/.tmp/ if it does not exist, keep any contents disposable, and remove files when they are no longer needed. .agents/.tmp/ is ignored by git and must never be used for source code, documentation deliverables, configuration, or assets that need to ship.
❌ WRONG - DO NOT DO THIS:
# Creating summary in project root - FORBIDDEN
echo "# Summary" > IMPLEMENTATION_SUMMARY.md
# Creating test file in project - FORBIDDEN
cat > test_feature.go << 'EOF'
# Using system temp directories - FORBIDDEN for this project
cat > /tmp/test_feature.go << 'EOF'✅ CORRECT - Do this instead:
# Use project-local .tmp/ for temporary files
mkdir -p .tmp
echo "# Summary" > .agents/.tmp/implementation_summary.md
# Use project-local .tmp/ for test files
cat > .agents/.tmp/test_feature.go << 'EOF'- If you accidentally create temporary files outside
.agents/.tmp/, DELETE them immediately - Use
rm -f <file>to remove any temporary files you created - Check
git status --shortbefore finishing to ensure no temporary files are tracked or visible outside.agents/.tmp/
Creating temporary files outside .agents/.tmp/, or using system temp directories for this project, is UNACCEPTABLE and shows lack of respect for the codebase.
DO NOT make this mistake.
Architecture: Single full-stack application (not a monorepo)
- Backend: Go at repository root
- Frontend: React + Vite in
webs/ - Production: Frontend built first, then embedded into Go binary
Entry points:
- Backend:
main.go - Frontend:
webs/src/index.jsx
Key boundaries:
routers/- Route registrationapi/- HTTP handlersservices/- Business logic and background workflowsmodels/- Persistence and migrationsmiddlewares/- Auth and request pipelinenode/- Subscription and protocol parsingwebs/src/api/- Frontend request boundarywebs/src/views/- Page-level featureswebs/src/components/- Shared frontend components; feature-local components must stay under their owningwebs/src/views/<feature>/component(s)/directory unless intentionally sharedskill-sublinkpro/- User-facing AI agent skill (portable SKILL.md format, consumes REST API via X-API-Key)
When instructions conflict, trust these files in order:
webs/package.json- Frontend commands and dependenciesdocs/development.md- Development workflow and structuredocs/configuration.md- Config precedence and runtime behavior.github/workflows/pr-checks.yml- PR automated checks.github/workflows/build-release.yml- CI and release buildDockerfile- Production build sequence
For frontend commands, output paths, and toolchain: Trust repository files over generic framework assumptions.
| Layer | Technology |
|---|---|
| Backend | Go + Gin + GORM |
| Core network/proxy | mihomo (MetaCubeX) |
| Database | SQLite (default), MySQL/PostgreSQL (optional) |
| Frontend | React 19 + Vite |
| UI | Material UI |
| Package manager | Yarn 4 |
| Scheduler | robfig/cron |
About mihomo: Core integration point for proxy adapters, speed testing, DNS resolution, Host injection, and proxied outbound requests. Not a minor dependency.
See docs/development.md for:
- Local setup (backend and frontend)
- Validation commands
- Testing requirements
- Protocol extension guide
- Scheduled task development
- Cron format
See docs/configuration.md for:
- Environment variables
- Config file precedence
- Default values
- Runtime directories
See docs/installation.md and skill-sublinkpro/reference/deploy.md for:
- Docker installation
- docker-compose setup
- One-line script
- Update procedures
See CONTRIBUTING.md for:
- Branch and commit conventions
- PR submission process
- Cross-layer synchronization summary
- Testing and validation overview
Theme changes: See docs/frontend-theme-guidelines.md
- Light/dark mode requirements
- Surface layering principles
- Component coverage expectations
Internationalization: See docs/internationalization.md
- Frontend i18n infrastructure (i18next)
- Backend i18n patterns (i18nKey + i18nParams)
- Bilingual documentation requirements
Code quality: See docs/development.md sections:
- Commenting standards
- Testing standards
- Validation commands
For task-specific validation procedures, see .agents/skills/:
- post-dev-workflow - Mandatory post-development workflow orchestrating validation, synchronization, and testing phases (automatically invoked by AI agents)
- pre-commit-check - Pre-commit validation checklist for linting, formatting, building, and testing
- cross-layer-sync - Cross-layer synchronization guide for backend, frontend, and documentation changes
- doc-sync-check - Documentation synchronization checklist for API, configuration, and feature changes
- theme-check - Theme adaptation checklist for light/dark mode and UI component changes
- security-review - Security review checklist for authentication, authorization, and sensitive data handling
- performance-check - Performance review checklist for optimization, scalability, and resource usage
Skills follow the official Claude Code skill specification - freeform markdown with optional frontmatter. Each skill includes metadata indicating whether it's user-invocable or workflow-invoked.
For AI agents: The post-dev-workflow skill is the master workflow that orchestrates all other skills. It must be invoked automatically after every code change.
- Fix issues in the correct layer
- When a change affects multiple layers, synchronize all impacted layers in the same PR
- Don't move business logic into
routers/ - Don't put persistence details into UI code
- Keep scheduler logic in
services/scheduler/
Rule: When a change affects multiple layers (backend, frontend, docs), all impacted layers must be updated together.
For detailed requirements: See .agents/skills/cross-layer-sync/SKILL.md
Core principle: Backend API changes → update frontend + docs. Frontend contract changes → verify backend + docs. Config/deployment changes → update all relevant docs.
- Backend: Standard Go style and package structure
- Frontend: Current Vite + MUI + ESLint/Prettier setup
- Match surrounding naming and organization before introducing new patterns
Rule: Code changes that alter behavior, APIs, or configuration must update documentation in the same PR.
For detailed requirements: See .agents/skills/doc-sync-check/SKILL.md
Bilingual: All documentation maintained in English and Chinese (*.zh-CN.md)
Several core features depend directly on mihomo capabilities:
Key capabilities:
- Node delay and speed testing
- Proxy adapter construction and dialing
- DNS resolution and DoH flows
- Host mapping synchronization
- Proxied downloads and outbound requests
Key files:
services/mihomo/mihomo.go- Core adapter and testing wrapperservices/mihomo/dns_resolver.go- DNS resolution entry pointservices/mihomo/host_resolver.go- Host mapping syncservices/scheduler/speedtest_task.go- Speed test integrationutils/proxy_client.go- Shared proxy HTTP clientnode/sub.go,node/usage.go- Proxied subscription flows
When to check: Changes involving proxying, speed tests, DNS, Host mappings, chain proxy, or proxied downloads.
Start here when changing behavior:
| Area | Files |
|---|---|
| Auth/MFA | api/auth.go, api/auth_mfa.go, middlewares/ |
| Subscriptions | api/clients.go |
| mihomo core | services/mihomo/ |
| Scheduled tasks | services/scheduler/ |
| Tags | services/tag_service.go |
| Protocols | node/protocol/ |
| Proxy client | utils/proxy_client.go |
| Host management | models/host.go |
| DB migration | models/db_migrate.go |
| Frontend pages | webs/src/views/ |
| Frontend routing | webs/src/routes/ |
| Frontend API | webs/src/api/ |
| Theme infrastructure | webs/src/themes/, webs/src/utils/colorUtils.js |
Theme reference patterns:
- Node preview:
NodePreviewDialog.jsx,NodePreviewCard.jsx,NodePreviewDetailsPanel.jsx - Chain proxy:
ChainProxyDialog.jsx,ChainPreviewDialog.jsx,MobileChainBuilder.jsx,ConditionBuilder.jsx - Airport management:
views/airports/index.jsx,AirportFormDialog.jsx,AirportBatchEditDialog.jsx,AirportMobileList.jsx
README.md- Project overview and quick startdocs/installation.md- Installation methodsdocs/configuration.md- Configuration referencedocs/security-guidelines.md- Security best practicesdocs/features/- Feature-specific guidesskill-sublinkpro/- AI agent skill for REST API interaction
CONTRIBUTING.md- Contribution workflowdocs/development.md- Development guidedocs/build-and-deployment.md- Build process and deploymentdocs/practical-recipes.md- Common development patternsdocs/frontend-theme-guidelines.md- Theme adaptation rulesdocs/internationalization.md- i18n guidelines.agents/skills/- Operational checklists
AGENTS.md(this file) - Architectural overview and navigation.agents/skills/- Task-specific validation procedures
Order (highest to lowest):
- Command-line flags
- Environment variables
- Config file
db/config.yaml - Database-stored settings
- Defaults
Common defaults:
- Port:
8000 - DB path:
./db - Log path:
./logs - Default SQLite DSN:
sqlite://./db/sublink.db
For complete reference: See docs/configuration.md
- Frontend requests go through
webs/src/api/request.js - API boundary:
/api/* - Subscription access:
/c/* SUBLINK_WEB_BASE_PATHaffects Web UI routing, not/api/*or/c/*
skill-sublinkpro is also a REST API consumer:
- Any changes to
/api/v1/*or/c/*must updateskill-sublinkpro/reference/api.md - Deployment/config changes must update
skill-sublinkpro/reference/deploy.md - New/moved docs must update
skill-sublinkpro/reference/docs.md
- Default admin credentials:
admin / 123456(remind users to change) - SQLite → MySQL/PostgreSQL migration requires manual restart
- Not compatible with upstream project databases
- Docker runtime directories:
/app/db,/app/template,/app/logs
main- Stable branchdev- Development branch (target for PRs)- Semantic commit prefixes:
feat:,fix:,docs:,refactor:,test:,chore:
For complete workflow: See CONTRIBUTING.md
Frontend changes:
cd webs
yarn run lint # Always
yarn run build # When routing/assets/build affectedBackend changes:
gofmt -w <changed-files> # Format
golangci-lint run # Lint
go test ./... # TestFor complete checklist: See .agents/skills/pre-commit-check/SKILL.md
This file provides architectural overview and navigation. For specific procedures:
- Setup and development:
docs/development.md - Build and deployment:
docs/build-and-deployment.md - Configuration:
docs/configuration.md - Security:
docs/security-guidelines.md - Common development patterns:
docs/practical-recipes.md - Contributing:
CONTRIBUTING.md - Theme work:
docs/frontend-theme-guidelines.md - i18n work:
docs/internationalization.md - Validation checklists:
.agents/skills/ - Features:
docs/features/ - Skill API:
skill-sublinkpro/
Don't reinvent or duplicate content that exists in these references. Read the relevant file when you need details.