samples
Skill26 starsChanged 9 months agoMITView on GitHub
Guide for creating or updating sample applications in this project. Use when adding a new sample, modifying an existing sample, or when asked to demonstrate a feature management capability with example code.
In this repository3 other files it gives its agents.
- .github/copilot-instructions.mdCopilot instructions
- ci-failure-debuggingSkill
- sync-async-patternSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 15
Every sample must have the Microsoft copyright header:
- Distinctive: line 23
Every sample must have a module-level docstring (one-liner describing what it demonstrates).
- Very specific: line 67
Use azure.appconfiguration.provider.load() to get configuration
- Very specific: line 75
Web app span processor: Use TargetingSpanProcessor from featuremanagement.azuremonitor with configure_azure_monitor(span_processors=[...]).
≈ “Common” is an estimate: at least 1 in 5 of the 383,637 skill 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
Sample Applications
Samples live in samples/ and demonstrate feature management capabilities to users.
File conventions
- Every sample must have the Microsoft copyright header:
# ------------------------------------------------------------------------ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # ------------------------------------------------------------------------- - Every sample must have a module-level docstring (one-liner describing what it demonstrates).
- Filename should end with
_sample.pyand describe what is being demonstrated (e.g.,feature_flag_sample.py,feature_variant_sample_with_telemetry.py).
Structure of a sample
Samples follow this general pattern:
# (copyright header)
"""Sample demonstrating <what this shows>."""
import json
import os
import sys
from featuremanagement import FeatureManager, TargetingContext
# Load feature flags from the local JSON file
file_path = os.path.dirname(os.path.abspath(sys.argv[0]))
with open(os.path.join(file_path, "formatted_feature_flags.json"), encoding="utf-8") as f:
feature_flags = json.load(f)
# Create FeatureManager
feature_manager = FeatureManager(feature_flags)
# Demonstrate the feature
result = feature_manager.is_enabled("FlagName")
print(f"FlagName is {'enabled' if result else 'disabled'}")Feature flag definitions
Sample feature flags go in formatted_feature_flags.json under feature_management.feature_flags. Each flag needs at minimum id and enabled. Add filters, variants, allocation, or telemetry as needed for the sample.
Custom filters
Custom filters used by samples are defined in their own file (e.g., random_filter.py) and imported by the samples that need them.
Async samples
Async samples import from featuremanagement.aio instead of featuremanagement. See quarty_sample.py for the async pattern.
Azure-connected samples
Samples that connect to Azure App Configuration:
- Use
azure.appconfiguration.provider.load()to get configuration - Authenticate using
DefaultAzureCredentialfromazure-identity, never connection strings - List Azure dependencies in
samples/requirements.txt
Telemetry samples
Two patterns exist:
- Callback-based: Pass
on_feature_evaluated=publish_telemetrytoFeatureManagerand usetrack_event()fromfeaturemanagement.azuremonitor. - Web app span processor: Use
TargetingSpanProcessorfromfeaturemanagement.azuremonitorwithconfigure_azure_monitor(span_processors=[...]).
Dependencies
Any new package a sample needs must be added to samples/requirements.txt. CI installs these before linting samples.
Linting
Samples are linted with relaxed rules:
pylint --disable=missing-function-docstring,missing-class-docstring samples testsFunction and class docstrings are NOT required in samples, but module-level docstrings ARE.
Checklist for adding a new sample
- Create
samples/feature_<name>_sample.pywith copyright header and module docstring. - Add any new feature flags to
formatted_feature_flags.json. - Add any new dependencies to
samples/requirements.txt. - Verify lint passes:
pylint --disable=missing-function-docstring,missing-class-docstring samples
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
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.

