Loading...
Loading...
Manage project rules and standards in docs/rules/. Use when creating coding standards, git conventions, style guides, or any enforceable project rules. Routes to specialized sub-skills for code, git, and infrastructure rules.
npx skill4agent add opendndapps/ogt-skills ogt-docs-rulesdocs/rules/flowchart TB
subgraph rules ["docs/rules/"]
direction TB
CODE["code/"]
GIT["git/"]
INFRA["infra/"]
DOCS["docs/"]
STYLE["style/"]
end
subgraph skills ["Specialized Skills"]
S1["ogt-docs-rules-code"]
S2["ogt-docs-rules-git"]
S3["ogt-docs-rules-code-front"]
S4["ogt-docs-rules-code-back"]
S5["ogt-docs-rules-code-infra"]
end
CODE --> S1
CODE --> S3
CODE --> S4
CODE --> S5
GIT --> S2
INFRA --> S5| Skill | Domain | Use When |
|---|---|---|
| Coding standards | TypeScript, naming, patterns, error handling |
| Frontend code | React, components, state, styling |
| Backend code | API design, database, services |
| Infrastructure | Docker, CI/CD, deployment |
| Git workflow | Commits, branches, PRs, reviews |
docs/rules/
├── code/ # Coding standards
│ ├── general/ # Cross-cutting code rules
│ │ ├── rule.md # Primary rule definition
│ │ ├── examples.md # Good/bad examples
│ │ ├── .version # Schema version
│ │ └── .enforced_by # How it's enforced (eslint, tsc, etc.)
│ │
│ ├── typescript/ # TypeScript-specific rules
│ │ ├── rule.md
│ │ ├── examples.md
│ │ └── .enforced_by
│ │
│ ├── naming/ # Naming conventions
│ │ ├── rule.md
│ │ ├── examples.md
│ │ └── .enforced_by
│ │
│ ├── front/ # Frontend-specific rules
│ │ ├── components/
│ │ ├── state/
│ │ ├── styling/
│ │ └── routing/
│ │
│ ├── back/ # Backend-specific rules
│ │ ├── api/
│ │ ├── database/
│ │ └── services/
│ │
│ └── infra/ # Infrastructure rules
│ ├── docker/
│ ├── ci/
│ └── deployment/
│
├── git/ # Git workflow rules
│ ├── commits/ # Commit message format
│ │ ├── rule.md
│ │ ├── examples.md
│ │ └── .enforced_by
│ │
│ ├── branches/ # Branch naming
│ │ ├── rule.md
│ │ └── examples.md
│ │
│ ├── pull_requests/ # PR requirements
│ │ ├── rule.md
│ │ └── template.md
│ │
│ └── reviews/ # Code review standards
│ ├── rule.md
│ └── checklist.md
│
├── docs/ # Documentation rules
│ ├── structure/ # Folder organization
│ ├── formatting/ # Markdown standards
│ └── comments/ # Code comments
│
└── style/ # Style guides
├── ui/ # UI/UX consistency
├── api/ # API style
└── naming/ # Naming conventionsrule.md# Rule: {Rule Name}
## Summary
One sentence stating the rule clearly and unambiguously.
## Rationale
Why this rule exists. What problems it prevents. What benefits it provides.
## The Rule
Clear, specific statement of what MUST, SHOULD, or MUST NOT be done.
Use RFC 2119 keywords:
- **MUST** / **REQUIRED** - Absolute requirement
- **MUST NOT** / **SHALL NOT** - Absolute prohibition
- **SHOULD** / **RECOMMENDED** - Recommended but exceptions exist
- **SHOULD NOT** - Not recommended but exceptions exist
- **MAY** / **OPTIONAL** - Truly optional
## Examples
### Correct
{Show correct usage}
### Incorrect
{Show incorrect usage with explanation}
## Exceptions
Documented cases where this rule may be relaxed.
## Enforcement
How this rule is enforced:
- Automated (linter, type checker, CI)
- Manual (code review)
- Both
## References
- Related rules
- External standards
- Tooling documentationdocs/rules/code/typescript/
├── rule.md
├── examples.md
├── .version
└── .enforced_by# Rule: TypeScript Strict Mode
## Summary
All TypeScript code MUST compile with strict mode enabled.
## Rationale
Strict mode catches common errors at compile time:
- Implicit any types
- Null/undefined access
- Unused variables
- Missing return types
This prevents runtime errors and improves code quality.
## The Rule
1. **MUST** enable `"strict": true` in tsconfig.json
2. **MUST NOT** use `@ts-ignore` without explanatory comment
3. **MUST NOT** use `any` type except in documented exceptions
4. **SHOULD** prefer `unknown` over `any` for unknown types
5. **MUST** fix all TypeScript errors before committing
## Examples
### Correct
```typescript
// Explicit types
function calculateTotal(items: CartItem[]): number {
return items.reduce((sum, item) => sum + item.price, 0);
}
// Unknown instead of any
function parseJSON(text: string): unknown {
return JSON.parse(text);
}
// Type guards for unknown
function isUser(value: unknown): value is User {
return typeof value === "object" && value !== null && "id" in value;
}
```// Implicit any - TS7006
function process(data) {
// ERROR: Parameter 'data' implicitly has 'any' type
return data.value;
}
// Using any
function handleResponse(response: any) {
// AVOID: Use unknown or specific type
return response.data;
}
// ts-ignore without comment
// @ts-ignore // BAD: No explanation
const result = brokenLibrary.call();any// Exception: Legacy API returns untyped response (see #123)
const data = legacyApi.fetch() as any;tsc --noEmit@typescript-eslint/no-explicit-any
### examples.md
```markdown
# TypeScript Examples
Extended examples for TypeScript rules.
## Type Inference vs Explicit Types
### When to Use Explicit Types
```typescript
// Function return types - ALWAYS explicit
function fetchUser(id: string): Promise<User> {
return api.get(`/users/${id}`);
}
// Exported constants - ALWAYS explicit
export const DEFAULT_TIMEOUT: number = 5000;
// Complex objects - ALWAYS explicit
const config: AppConfig = {
apiUrl: process.env.API_URL,
timeout: 5000,
};// Local variables with obvious types
const count = 0; // Inferred as number
const name = "test"; // Inferred as string
const items = [1, 2, 3]; // Inferred as number[]
// Arrow functions in callbacks
users.filter((user) => user.active); // Parameter type inferred from array// CORRECT: Use discriminated unions
type Result<T> = { success: true; data: T } | { success: false; error: Error };
function handleResult<T>(result: Result<T>) {
if (result.success) {
console.log(result.data); // TypeScript knows data exists
} else {
console.error(result.error); // TypeScript knows error exists
}
}// INCORRECT: Loose union without discriminant
type Response = {
data?: User;
error?: Error;
};
// Problem: Both could be undefined, or both could be set// CORRECT: Constrain generics appropriately
function getProperty<T, K extends keyof T>(obj: T, key: K): T[K] {
return obj[key];
}
// INCORRECT: Unconstrained generic
function getValue<T>(obj: T, key: string): any {
// Returns any!
return (obj as any)[key];
}
### .version
```json
{ "schema": "1.0", "created": "2026-01-15T10:00:00Z", "updated": "2026-02-01T14:00:00Z" }tsc --noEmit
eslint --ext .ts,.tsx
pre-commit hook
CI pipelinedocs/rules/git/commits/
├── rule.md
├── examples.md
├── .version
└── .enforced_by# Rule: Commit Message Format
## Summary
All commit messages MUST follow Conventional Commits format.
## Rationale
Consistent commit messages enable:
- Automated changelog generation
- Semantic versioning automation
- Easy history navigation
- Clear communication of changes
## The Rule
### Format
### Types
| Type | Use When |
|------|----------|
| `feat` | New feature |
| `fix` | Bug fix |
| `docs` | Documentation only |
| `style` | Formatting, no code change |
| `refactor` | Code change that neither fixes nor adds |
| `perf` | Performance improvement |
| `test` | Adding/updating tests |
| `chore` | Maintenance tasks |
| `ci` | CI/CD changes |
### Requirements
1. **MUST** use lowercase type
2. **MUST** use imperative mood in description ("add" not "added")
3. **MUST** limit first line to 72 characters
4. **SHOULD** include scope for clarity
5. **MUST** reference issue number in footer for bug fixes
6. **MUST** mark breaking changes with `!` or `BREAKING CHANGE:` footer
## Examples
### Correct
undefinedundefinedundefined
### Incorrect
undefinedundefinedundefined
## Exceptions
- Merge commits may use default message
- Revert commits may use git's default format
## Enforcement
- **Automated**: commitlint in pre-commit hook
- **Automated**: CI check on PR
- **Manual**: PR review
## References
- [Conventional Commits](https://www.conventionalcommits.org/)
- [Angular Commit Guidelines](https://github.com/angular/angular/blob/main/CONTRIBUTING.md#commit)# Commit Message Examples
## Feature Commitsundefined
## Bug Fix Commits
undefined
## Refactor Commits
## Documentation Commits
## Breaking Change Commits
undefinedcommitlint
husky pre-commit
GitHub Actions CIflowchart TD
A[Identify Need for Rule] --> B{Rule Type?}
B -->|Code| C[docs/rules/code/]
B -->|Git| D[docs/rules/git/]
B -->|Docs| E[docs/rules/docs/]
B -->|Style| F[docs/rules/style/]
C --> G[Create Rule Folder]
D --> G
E --> G
F --> G
G --> H[Write rule.md]
H --> I[Add examples.md]
I --> J[Set .version]
J --> K[Document .enforced_by]
K --> L{Automated Enforcement?}
L -->|Yes| M[Configure Tooling]
L -->|No| N[Add to Review Checklist]
M --> O[Add to CI]
N --> O
O --> P[Announce to Team]docs/rules/{domain}/{rule_name}/| Signal | Type | Content | Purpose |
|---|---|---|---|
| Content | JSON with schema, created, updated | Track rule version |
| Content | List of tools/processes | Document enforcement |
| Empty | - | Mark rule as deprecated |
| Content | Path to new rule | Point to replacement |
| Empty | - | Track approval |