langchain-community
Copilot instructions287 starsChanged 12 months agoMITArchived repositoryView on GitHub
Always attempt to preserve function signatures, argument positions, and names for exported/public methods. ❌ Bad - Breaking Change: ✅ Good - Stable Interface: Before making ANY changes to public APIs: 🧠 Ask yourself: "Would this change break someone's code if they used it last week?" All Python code MUST include type hints and return types. Style Requirements: Every new feature or bugfix MUST be covered by unit tests. Test Organization: Test Quality Checklist: Checklist questions: Security Checklist: Use Google-style docstrings…
We split this copilot-instructions.md into the rules it gives an agent
15 rules. About 1 is common, 11 are distinctive, and 3 are very specific to this project.
≈1
Common · estimate
Many files like this have a rule of this kind.
≈11
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 26
Check if the function/class is exported in __init__.py
- Distinctive: line 27
Look for existing usage patterns in tests and examples
- Very specific: line 28
Use keyword-only arguments for new parameters: *, new_param: str = "default"
- Distinctive: line 62
Use descriptive, self-explanatory variable names.
- Distinctive: line 64
Avoid unnecessary abstraction or premature optimization
- Distinctive: line 65
Follow existing patterns in the codebase you're modifying
- Very specific: line 75
Use pytest as the testing framework
- Distinctive: line 109
Remove unreachable/commented code before committing
- Distinctive: line 111
Ensure proper resource cleanup (file handles, connections)
- Common: line 167
Document all parameters, return values, and exceptions
- Distinctive: line 168
Keep descriptions concise but clear
- Distinctive: line 222
If there's a cleaner, more scalable, or simpler design, highlight it and suggest improvements that would:
- Distinctive: line 228
Add clarity without adding complexity
- Distinctive: line 229
Prefer dataclasses for structured data
- Distinctive: line 308
Before submitting code changes:
≈ “Common” is an estimate: at least 1 in 5 of the 3,669 Copilot instructions 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.
Files
Global Development Guidelines for LangChain Projects
Core Development Principles
1. Maintain Stable Public Interfaces ⚠️ CRITICAL
Always attempt to preserve function signatures, argument positions, and names for exported/public methods.
❌ Bad - Breaking Change:
def get_user(id, verbose=False): # Changed from `user_id`
pass✅ Good - Stable Interface:
def get_user(user_id: str, verbose: bool = False) -> User:
"""Retrieve user by ID with optional verbose output."""
passBefore making ANY changes to public APIs:
- Check if the function/class is exported in
__init__.py - Look for existing usage patterns in tests and examples
- Use keyword-only arguments for new parameters:
*, new_param: str = "default" - Mark experimental features clearly with docstring admonitions (using MkDocs Material, like
!!! warning)
🧠 Ask yourself: "Would this change break someone's code if they used it last week?"
2. Code Quality Standards
All Python code MUST include type hints and return types.
❌ Bad:
def p(u, d):
return [x for x in u if x not in d]✅ Good:
def filter_unknown_users(users: list[str], known_users: set[str]) -> list[str]:
"""Filter out users that are not in the known users set.
Args:
users: List of user identifiers to filter.
known_users: Set of known/valid user identifiers.
Returns:
List of users that are not in the known_users set.
"""
return [user for user in users if user not in known_users]Style Requirements:
- Use descriptive, self-explanatory variable names. Avoid overly short or cryptic identifiers.
- Attempt to break up complex functions (>20 lines) into smaller, focused functions where it makes sense
- Avoid unnecessary abstraction or premature optimization
- Follow existing patterns in the codebase you're modifying
3. Testing Requirements
Every new feature or bugfix MUST be covered by unit tests.
Test Organization:
- Unit tests:
tests/unit_tests/(no network calls allowed) - Integration tests:
tests/integration_tests/(network calls permitted) - Use
pytestas the testing framework
Test Quality Checklist:
- Tests fail when your new logic is broken
- Happy path is covered
- Edge cases and error conditions are tested
- Use fixtures/mocks for external dependencies
- Tests are deterministic (no flaky tests)
Checklist questions:
- Does the test suite fail if your new logic is broken?
- Are all expected behaviors exercised (happy path, invalid input, etc)?
- Do tests use fixtures or mocks where needed?
def test_filter_unknown_users():
"""Test filtering unknown users from a list."""
users = ["alice", "bob", "charlie"]
known_users = {"alice", "bob"}
result = filter_unknown_users(users, known_users)
assert result == ["charlie"]
assert len(result) == 14. Security and Risk Assessment
Security Checklist:
- No
eval(),exec(), orpickleon user-controlled input - Proper exception handling (no bare
except:) and use amsgvariable for error messages - Remove unreachable/commented code before committing
- Race conditions or resource leaks (file handles, sockets, threads).
- Ensure proper resource cleanup (file handles, connections)
❌ Bad:
def load_config(path):
with open(path) as f:
return eval(f.read()) # ⚠️ Never eval config✅ Good:
import json
def load_config(path: str) -> dict:
with open(path) as f:
return json.load(f)5. Documentation Standards
Use Google-style docstrings with Args and Returns sections for all public functions.
❌ Insufficient Documentation:
def send_email(to, msg):
"""Send an email to a recipient."""✅ Complete Documentation:
def send_email(to: str, msg: str, *, priority: str = "normal") -> bool:
"""
Send an email to a recipient with specified priority.
Args:
to: The email address of the recipient.
msg: The message body to send.
priority: Email priority level.
Returns:
True if email was sent successfully, False otherwise.
Raises:
InvalidEmailError: If the email address format is invalid.
SMTPConnectionError: If unable to connect to email server.
"""Documentation Guidelines:
- Types go in function signatures, NOT in docstrings
- Focus on "why" rather than "what" in descriptions
- Document all parameters, return values, and exceptions
- Keep descriptions concise but clear
📌 Tip: Keep descriptions concise but clear. Only document return values if non-obvious.
6. Architectural Improvements
When you encounter code that could be improved, suggest better designs:
❌ Poor Design:
def process_data(data, db_conn, email_client, logger):
# Function doing too many things
validated = validate_data(data)
result = db_conn.save(validated)
email_client.send_notification(result)
logger.log(f"Processed {len(data)} items")
return result✅ Better Design:
@dataclass
class ProcessingResult:
"""Result of data processing operation."""
items_processed: int
success: bool
errors: List[str] = field(default_factory=list)
class DataProcessor:
"""Handles data validation, storage, and notification."""
def __init__(self, db_conn: Database, email_client: EmailClient):
self.db = db_conn
self.email = email_client
def process(self, data: List[dict]) -> ProcessingResult:
"""Process and store data with notifications.
Args:
data: List of data items to process.
Returns:
ProcessingResult with details of the operation.
"""
validated = self._validate_data(data)
result = self.db.save(validated)
self._notify_completion(result)
return resultDesign Improvement Areas:
If there's a cleaner, more scalable, or simpler design, highlight it and suggest improvements that would:
- Reduce code duplication through shared utilities
- Make unit testing easier
- Improve separation of concerns (single responsibility)
- Make unit testing easier through dependency injection
- Add clarity without adding complexity
- Prefer dataclasses for structured data
Development Tools & Commands
Package Management
# Add package
uv add package-name
# Sync project dependencies
uv sync
uv lockTesting
# Run unit tests (no network)
make test
# Don't run integration tests, as API keys must be set
# Run specific test file
uv run --group test pytest tests/unit_tests/test_specific.pyCode Quality
# Lint code
make lint
# Format code
make format
# Type checking
uv run --group lint mypy .Dependency Management Patterns
Local Development Dependencies:
[tool.uv.sources]
langchain-core = { path = "../core", editable = true }
langchain-tests = { path = "../standard-tests", editable = true }For tools, use the @tool decorator from langchain_core.tools:
from langchain_core.tools import tool
@tool
def search_database(query: str) -> str:
"""Search the database for relevant information.
Args:
query: The search query string.
"""
# Implementation here
return resultsCommit Standards
Use Conventional Commits format for PR titles:
feat(core): add multi-tenant support!fix(cli): resolve flag parsing error(breaking change uses exclamation mark)docs: update API usage examplesdocs(openai): update API usage examples
Quick Reference Checklist
Before submitting code changes:
- Breaking Changes: Verified no public API changes
- Type Hints: All functions have complete type annotations
- Tests: New functionality is fully tested
- Security: No dangerous patterns (eval, silent failures, etc.)
- Documentation: Google-style docstrings for public functions
- Code Quality:
make lintandmake formatpass - Architecture: Suggested improvements where applicable
- Commit Message: Follows Conventional Commits format
Where files are headingNew Copilot instructions files have more rules about branches and pull requests, and fewer about code style.
Of the Copilot instructions files we read, the 2,297 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
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.

