agentleFS
Data-WiseData-Wise/craft/AGENTS.md

craft

AGENTS.md4 starsChanged 4 months agoMITView on GitHub

This document provides development guidelines for agentic coding assistants working on the Craft plugin repository. It covers build/lint/test commands, code style conventions, and project-specific practices.

The file

Show its rules and text

We split this AGENTS.md into the rules it gives an agent

37 rules. About 1 is common, 22 are distinctive, and 14 are very specific to this project.

  • ≈1

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈22

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 14

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Very specific:

    Use Optional[T] for nullable types, not Union[T, None]

    line 83
  2. Very specific:

    Use List[T], Dict[K, V] instead of bare list, dict

    line 84
  3. Very specific:

    Use dataclasses with field() for complex defaults

    line 85
  4. Very specific:

    Use specific exception types, not bare Exception

    line 102
  5. Distinctive:

    Use triple quotes with proper formatting

    line 128
  6. Very specific:

    Lists: Use dashes (-) not asterisks (*)

    line 165
  7. Distinctive:

    Line length: No hard limit (MD013 disabled)

    line 166
  8. Distinctive:

    Headers: No duplicate headers in same section (MD024 with siblings_only)

    line 167
  9. Distinctive:

    Code blocks: Use fenced code blocks with language specification

    line 170
  10. Very specific:

    Use conventional commits: feat:, fix:, docs:, refactor:, test:

    line 185
  11. Distinctive:

    Keep first line under 50 characters

    line 186
  12. Distinctive:

    Use imperative mood ("Add feature" not "Added feature")

    line 187
  13. Distinctive:

    Never commit directly to main: - always use feature branches

    line 198
  14. Very specific:

    Use worktrees for isolation: git worktree add ../feature-name -b feature/name

    line 199
  15. Very specific:

    Test shell scripts in tests/*.sh

    line 214
  16. Very specific:

    Use descriptive test method names: test_should_ignore_broken_links

    line 215
  17. Distinctive:

    Test individual functions/classes in isolation

    line 237
  18. Distinctive:

    Use descriptive test names that explain the scenario

    line 238
  19. Distinctive:

    Use realistic test data

    line 256
  20. Common:

    Never: commit secrets or credentials

    line 270
  21. Distinctive:

    Use absolute paths for file operations

    line 271
  22. Distinctive:

    Use type hints to catch type-related issues early

    line 279
  23. Distinctive:

    Prefer list comprehensions over explicit loops when appropriate

    line 285
  24. Very specific:

    Use pathlib.Path for path operations

    line 286
  25. Distinctive:

    Keep unit tests under 100ms each

    line 292
  26. Distinctive:

    Use appropriate fixtures for test data

    line 293
  27. Distinctive:

    Update README.md when adding new features

    line 301
  28. Distinctive:

    Document breaking changes clearly

    line 303
  29. Distinctive:

    Keep installation instructions current

    line 304
  30. Distinctive:

    Document API contracts and expectations

    line 310
  31. Very specific:

    Update version in package.json

    line 323
  32. Distinctive:

    Run full test suite

    line 324
  33. Distinctive:

    Create GitHub release with changelog

    line 326
  34. Very specific:

    Count mismatches: Run ./scripts/validate-counts.sh to identify discrepancies

    line 332
  35. Distinctive:

    Test failures: Check for missing dependencies or environment issues

    line 333
  36. Very specific:

    Link validation errors: Update .linkcheck-ignore for known broken links

    line 334
  37. Very specific:

    Markdown linting: Run npx markdownlint-cli2 "/*.md" to identify issues

    line 335

≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

AGENTS.md - Development Guidelines for Craft Plugin

This document provides development guidelines for agentic coding assistants working on the Craft plugin repository. It covers build/lint/test commands, code style conventions, and project-specific practices.

Build/Lint/Test Commands

Primary Test Commands

# Run all unit tests (581+ tests, ~90% coverage)
python3 tests/test_craft_plugin.py

# Run all tests with pytest (includes integration tests)
python3 -m pytest tests/ -v

# Run specific test file
python3 tests/test_craft_plugin.py::TestClass::test_method

# Run integration tests only
python3 tests/test_integration_*.py

# Run dependency system tests
bash tests/test_dependency_management.sh

# Run specific integration test
python3 tests/test_integration_dependency_system.py

Linting and Validation

# Validate command/skill/agent counts match documentation
./scripts/validate-counts.sh

# Markdown linting (24 rules enforced)
npx markdownlint-cli2 "**/*.md" --config .markdownlint.json

# Build documentation site
mkdocs build

# Check broken links (with ignore rules)
python3 tests/test_craft_plugin.py -k "broken_links"

Development Workflow

# Quick validation (lint + test counts)
./scripts/validate-counts.sh && python3 tests/test_craft_plugin.py

# Full CI validation
python3 -m pytest tests/ -v && npx markdownlint-cli2 "**/*.md"

# Documentation validation
mkdocs build && python3 tests/test_craft_plugin.py -k "broken_links"

Code Style Guidelines

Python Conventions

Imports

# Standard library imports first
import json
import os
import re
from dataclasses import dataclass, field
from pathlib import Path
from typing import Dict, List, Optional, Tuple

# Third-party imports (none in this project)

# Local imports (alphabetized)
from .complexity_scorer import calculate_complexity_score
from .validators import validate_command_structure

Type Hints

  • Always use type hints for function parameters and return values
  • Use Optional[T] for nullable types, not Union[T, None]
  • Use List[T], Dict[K, V] instead of bare list, dict
  • Use dataclasses with field() for complex defaults
def calculate_complexity_score(task: str) -> int:
    """Calculate complexity score for a task."""

@dataclass
class TestResult:
    name: str
    passed: bool
    duration_ms: float
    details: str
    category: str = "general"

Error Handling

  • Use specific exception types, not bare Exception
  • Provide descriptive error messages
  • Log errors appropriately with context
try:
    result = risky_operation()
except FileNotFoundError as e:
    log(f"Configuration file not found: {config_path}")
    return TestResult(name, False, 0, f"Missing config: {e}", "structure")
except json.JSONDecodeError as e:
    log(f"Invalid JSON in plugin.json: {e}")
    return TestResult(name, False, 0, f"JSON parse error: {e}", "structure")

Naming Conventions

  • Functions: snake_case (e.g., calculate_complexity_score)
  • Classes: PascalCase (e.g., IgnorePattern)
  • Constants: UPPER_SNAKE_CASE (e.g., MULTI_STEP_INDICATORS)
  • Variables: snake_case (e.g., task_lower)
  • Methods: snake_case, descriptive names

Documentation

  • Always include docstrings for public functions and classes
  • Use triple quotes with proper formatting
  • Include Args and Returns sections for complex functions
def should_ignore(self, source_file: str, target_link: str) -> Tuple[bool, Optional[str]]:
    """
    Check if a broken link should be ignored.

    Args:
        source_file: Path to the file containing the link
        target_link: The broken link target

    Returns:
        (should_ignore, category) tuple
    """

Markdown Conventions

Frontmatter (for Commands/Skills/Agents)

---
description: Brief description of the command
arguments:
  - name: mode
    description: Execution mode
    required: false
    default: default
  - name: path
    description: Target path
    required: true
---

Formatting Rules (from .markdownlint.json)

  • Lists: Use dashes (-) not asterisks (*)
  • Line length: No hard limit (MD013 disabled)
  • Headers: No duplicate headers in same section (MD024 with siblings_only)
  • Inline HTML: Limited allowed elements (MD033)
  • List spacing: Consistent single-line spacing (MD030)
  • Code blocks: Use fenced code blocks with language specification

Table Formatting

| Mode | Time | Focus |
|------|------|-------|
| default | < 30s | Quick smoke tests |
| debug | < 120s | Verbose with traces |

Git Workflow

Commit Messages

  • Use conventional commits: feat:, fix:, docs:, refactor:, test:
  • Keep first line under 50 characters
  • Use imperative mood ("Add feature" not "Added feature")
  • Reference issues when applicable
git commit -m "feat: add complexity scoring for task routing"
git commit -m "fix: resolve broken link validation in docs"
git commit -m "test: add integration tests for dependency system"

Branching

  • Never commit directly to main - always use feature branches
  • Use worktrees for isolation: git worktree add ../feature-name -b feature/name
  • Branch naming: feature/description, fix/issue-number

Project Structure

Command Organization

  • Commands in commands/ directory with category subdirs
  • Each command is a .md file with frontmatter
  • Frontmatter defines arguments, descriptions, defaults

Test Organization

  • Unit tests in tests/test_*.py
  • Integration tests in tests/test_integration_*.py
  • Test shell scripts in tests/*.sh
  • Use descriptive test method names: test_should_ignore_broken_links

File Structure Expectations

commands/
├── arch/          # Architecture analysis commands
├── ci/           # CI/CD commands
├── code/         # Code quality commands
├── docs/         # Documentation commands
└── git/          # Git workflow commands

skills/           # Specialized capabilities
agents/           # Multi-step task handlers
utils/            # Shared Python utilities
scripts/          # Shell scripts and tools

Testing Practices

Unit Tests

  • Test individual functions/classes in isolation
  • Use descriptive test names that explain the scenario
  • Mock external dependencies
  • Assert both positive and negative cases
def test_calculate_complexity_score():
    # Test multi-step task detection
    score = calculate_complexity_score("lint and test the code")
    assert score >= 2, "Multi-step tasks should score at least 2"

    # Test simple task
    score = calculate_complexity_score("run tests")
    assert score < 2, "Simple tasks should score less than 2"

Integration Tests

  • Test component interactions
  • Use realistic test data
  • Validate end-to-end workflows
  • Clean up test artifacts

Test Coverage

  • Target 90%+ coverage
  • Focus on critical paths
  • Include edge cases and error conditions

Security Considerations

File Operations

  • Never commit secrets or credentials
  • Use absolute paths for file operations
  • Validate file paths before operations
  • Handle file permissions appropriately

Input Validation

  • Sanitize user inputs
  • Validate file paths exist before operations
  • Use type hints to catch type-related issues early

Performance Guidelines

Code Efficiency

  • Prefer list comprehensions over explicit loops when appropriate
  • Use pathlib.Path for path operations
  • Cache expensive operations when possible
  • Profile performance-critical code

Test Performance

  • Keep unit tests under 100ms each
  • Use appropriate fixtures for test data
  • Parallelize independent tests when possible
  • Mock slow external dependencies

Documentation Standards

README Updates

  • Update README.md when adding new features
  • Include usage examples and screenshots
  • Document breaking changes clearly
  • Keep installation instructions current

Inline Documentation

  • Comment complex algorithms
  • Explain non-obvious business logic
  • Document API contracts and expectations

CI/CD Integration

Pre-commit Hooks

  • Markdown linting enforced (24 rules)
  • Count validation for commands/skills/agents
  • Test execution required
  • Link validation with ignore patterns

Release Process

  • Update version in package.json
  • Run full test suite
  • Validate documentation builds
  • Create GitHub release with changelog

Troubleshooting

Common Issues

  • Count mismatches: Run ./scripts/validate-counts.sh to identify discrepancies
  • Test failures: Check for missing dependencies or environment issues
  • Link validation errors: Update .linkcheck-ignore for known broken links
  • Markdown linting: Run npx markdownlint-cli2 "**/*.md" to identify issues

Debug Commands

# Verbose test output
python3 -m pytest tests/ -v -s

# Debug specific test
python3 -m pytest tests/test_craft_plugin.py::test_plugin_json_exists -v -s

# Profile test performance
python3 -m pytest tests/ --durations=10

This guide ensures consistent development practices across all contributors to the Craft plugin project.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.