agentleFS
Microsoft AzureKnown publisherAzure/Connectors-NET-Samples/.github/copilot-instructions.md

Connectors-NET-Samples

Copilot instructions3 starsChanged 8 months agoMITView on GitHub

This repository contains sample projects demonstrating how to use the Azure Connectors .NET SDK, including design-time generated POCOs from dynamic schema operations. Code must follow the team's coding conventions based on BPM repo standards. Each connector's sample functions must be in a dedicated file named {Connector}Functions.cs: Variable naming rules: ALWAYS use this multi-line format: Boolean parameters MUST always use named arguments:

The file

We split this copilot-instructions.md into the rules it gives an agent

9 rules. About 0 are common, 6 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    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
  • could be automatic: a setting could enforce it
  1. Distinctive:

    No empty lines between using groups

    line 33
  2. Distinctive:

    Use complete, unabbreviated English terms for all identifiers

    line 65
  3. Very specific:

    No single-letter variable names, even in lambdas (use arg, item, method, parameter)

    line 66
  4. Very specific:

    No placeholder names (blah, foo, temp, x) — always use meaningful names

    line 67
  5. Very specific:

    ALWAYS use ConfigureAwait(continueOnCapturedContext: false) with explicit parameter name

    line 83
  6. Distinctive:

    Never push directly to main

    line 184
  7. Distinctive:

    Always create PR for review

    line 185
  8. Distinctive:

    Start connector validation with a discovery operation that requires no dependent resource identifier.

    line 190
  9. Distinctive:

    Use only data returned by the authenticated connector in E2E follow-on calls.

    line 194

≈ “Common” is an estimate: at least 1 in 5 of the 1,644 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.

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

Copilot Instructions for Connectors-NET-Samples

Overview

This repository contains sample projects demonstrating how to use the Azure Connectors .NET SDK, including design-time generated POCOs from dynamic schema operations. Code must follow the team's coding conventions based on BPM repo standards.

Quick Reference: Coding Style Rules

File Structure

//------------------------------------------------------------
// Copyright (c) Microsoft Corporation.  All rights reserved.
//------------------------------------------------------------

using System;
using System.Collections.Generic;
using Microsoft.Azure.Connectors.Sdk;

namespace DirectConnector
{
    public class YourClass
    {
    }
}

Rules:

  • Copyright header: Use //---- (4 dashes) format with double space before "All rights reserved"
  • Usings OUTSIDE namespace (standard C# convention)
  • Usings sorted: System.* first, then alphabetically
  • No empty lines between using groups

Project Organization — One File Per Connector

Each connector's sample functions must be in a dedicated file named {Connector}Functions.cs:

ConnectorFile
Office365, SharePoint, TeamsConnectorFunctions.cs (legacy combined file — to be refactored)
OneDrive for BusinessOneDriveFunctions.cs
MS Graph Groups & UsersMsGraphFunctions.cs

Rules:

  • Each file is a separate class with its own ILogger<T> and connector client injected via constructor
  • DI registration of the connector client stays in Program.cs
  • Configuration options class stays in Configuration/ConnectorOptions.cs
  • New connectors must follow this pattern; do NOT add functions to ConnectorFunctions.cs

Naming and Qualification

ElementRuleExample
Static membersQualify with class nameMyClass.StaticMethod()
Instance membersQualify with this.this.instanceField
Private fieldsUse _camelCaseprivate readonly string _connectionString;
ConstantsQualify with class nameMyClass.DefaultTimeout
Local variablesUse complete English termsparameter not p, method not m
Lambda parametersUse descriptive namesmethods.Where(method => ...) not m => ...

Variable naming rules:

  • Use complete, unabbreviated English terms for all identifiers
  • No single-letter variable names, even in lambdas (use arg, item, method, parameter)
  • No placeholder names (blah, foo, temp, x) — always use meaningful names

Async/Await Format

ALWAYS use this multi-line format:

var result = await this.httpClient
    .GetAsync(requestUri)
    .ConfigureAwait(continueOnCapturedContext: false);

Rules:

  • Period on NEW line, not end of previous line
  • Arguments indented ONE level (4 spaces)
  • ALWAYS use ConfigureAwait(continueOnCapturedContext: false) with explicit parameter name

DO NOT:

// Wrong: ConfigureAwait without named parameter
.ConfigureAwait(false);

// Wrong: Method call on same line as object
var result = await this.httpClient.GetAsync(requestUri)
    .ConfigureAwait(continueOnCapturedContext: false);

// Wrong: Missing ConfigureAwait
var result = await this.httpClient.GetAsync(requestUri);

Exception Handling

catch (SpecificException ex)
{
    this.logger.LogError(ex, "Failed: '{Message}'.", ex.Message);
    throw;
}
catch (Exception ex) when (!ex.IsFatal())
{
    throw new InvalidOperationException(message: "Operation failed.", innerException: ex);
}

Rules:

  • Exception variable name: ex (not exception)
  • Wrap inserted values in single quotes in error messages
  • End error messages with period

Boolean Parameters

Boolean parameters MUST always use named arguments:

// Correct
IdentifierNormalizer.Normalize(name, isVariableName: true);
this.CreateNode(schema, isRequired: false);

// Wrong - unnamed boolean is ambiguous
IdentifierNormalizer.Normalize(name, true);
this.CreateNode(schema, false);

String Comparison

ALWAYS use StringComparison:

string.Equals(str1, str2, StringComparison.OrdinalIgnoreCase)

Variable Declaration

Use var when type is obvious:

var items = new List<string>();
var response = await this.GetResponseAsync();

Ternary Operators

Put ? and : at START of new line:

var result = condition
    ? valueIfTrue
    : valueIfFalse;

Access Modifiers

ALWAYS explicit - order: access, static, readonly, other:

public static readonly string DefaultValue = "default";
private readonly ILogger _logger;

Patterns to Avoid

Anti-PatternCorrect Pattern
.Result on Taskawait task.ConfigureAwait(continueOnCapturedContext: false)
.Wait() on Taskawait task.ConfigureAwait(continueOnCapturedContext: false)
Task.Run() for I/Oawait the async method directly
new Exception("msg.")new SpecificException(message: "msg.")
Magic numbersNamed constants (e.g., MyClass.DefaultTimeoutSeconds)
Magic strings (e.g., "type", "object")Named constants (e.g., SchemaPropertyNames.Type)
[0] or .First().Single() (or .SingleOrDefault() + explicit validation)

Git Workflow

  • Branch naming: feature/description, fix/description, docs/description
  • Never push directly to main
  • Always create PR for review

E2E Validation

  • A Function endpoint returning HTTP 502 is a failed connector invocation, not E2E validation. Inspect the structured response and resolve the downstream error before recording any validation claim.
  • Start connector validation with a discovery operation that requires no dependent resource identifier. Use a resource value returned in that session for every subsequent site-, account-, table-, container-, or item-scoped call; never use fabricated placeholders.
  • Record the public generated SDK method and the successful downstream result that establishes E2E coverage. Do not describe REST path suffixes as SDK method names or infer successful connector behavior from a Function wrapper status alone.
  • For mutating validation, use a uniquely named temporary resource with the least-cost valid configuration. Put cleanup in a finally path, verify that the delete request was accepted, and avoid leaving dependent resources behind if a later step fails.
  • Validate the deployed sample route as well as a direct runtime call when practical. This distinguishes a working connector operation from a stale app setting, missing managed-identity access policy, or Function serialization issue.
  • Use only data returned by the authenticated connector in E2E follow-on calls. Never add environment-specific resource names, runtime URLs, connection identifiers, tenant identifiers, test data, or credentials to source, documentation, PR descriptions, or test fixtures.
  • Preserve negative evidence: if a generated operation reaches the connector but is rejected by the service, record the operation and returned error for triage but do not label it validated or broaden a connector-level claim.

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.