A Kekkai (結界, barrier) is a Kekkaishi's main source of offense and defense, and they have a wide variety of uses, in and out of combat. A Kekkai is typically created by a three commands: Hōi, which designates a target; Jōso, which determines the Kekkai's location; and Ketsu, which activates the Kekkai. From there, a Kekkai can be collapsed with Metsu, destroying it and its contents. A Kekkai can also be dispelled harmlessly, either through Kai, where the user dispels their own Kekkai, or Sekkai, which is only used to dispel another Kekkaishi's Kekkai. Kekkai have either coordinate or conditional settings. Coordinate Kekkai are anchored to one spot and cannot be moved, while conditional Kekkai can be moved.
Offensive Kekkai are used to damage an enemy, most commonly by either collapsing the Kekkai around them, or actually hitting them with the Kekkai.
Capture & Collapse: The Basics
Among the most basic uses of a Kekkai are the capture and destruction of Ayakashi. It should be noted, however, that an Ayakashi that can be immediately be detained and destroyed, with no damage beforehand, is generally thought to be either fairly weak, or simply outclassed by the Kekkaishi's skill. Some Ayakashi have special abilities that allow them to either avoid or escape from Kekkai. Stronger Ayakashi must be weakened considerably to improve the Kekkai's effectiveness. The strength of a Kekkai depends mostly on the Kekkaishi's skill and feelings, rather than their power, although it is repeatedly shown that Kekkaishi with great power can make Kekkai of enormous size when needed, while others cannot.
In terms of offense, the most commonly seen attack involving Kekkai is the destruction of a portion of an enemy by collapsing a Kekkai around it. While this is an excellent method to weaken Ayakashi, a great deal of them are able to regenerate quickly, and the rate at which they heal is always accelerated while in Karasumori. Repeated destruction of parts tends to gradually tire all but the strongest Ayakashi, so this is still an acceptable method with many of them.
A technique popularized by Tokine is the Kekkai spear: a rectangular, rapidly extending Kekkai that pierces the opponent's body. With larger foes, she tends to use multiple spears at once to great effect. She has also been known to use a far weaker (but still rather painful), blunted version on Yoshimori and Gen Shishio as punishment for small offenses. Yoshimori occasionally uses this as well, but tends to add far more power, resulting in a larger, harder-hitting impact that tends to flatten an enemy, rather than piercing them.
Using one or more Kekkai within another Kekkai is very effective. Not only does this make it harder and more time-consuming for the enemy to escape, it also increases the strength of the eventual collapse, and is useful against Ayakashi with tough outer shells. Similarly, multi-layer Kekkai make for powerful defensive barriers. However, they are harder to create because they take a great deal of strength to use. Masamori is the only Kekkaishi known to use this on numerous occasions, repeatedly if necessary. Tokine uses this for a short time; when Tokiko told her that it's not a good technique for her, she discontinued practicing it.
The most common defensive use of Kekkai is surrounding a target (either the enemy or the Kekkaishi) to prevent attack. Kekkai can also be manipulated so that they only target certain things: Yoshimori has perfected a "nap time Kekkai" that only prevents his grandfather from entering while Yoshimori is asleep, but allows others to pass through freely.
While most Kekkai are quite solid, Kekkaishi occasionally produce Kekkai that have a built-in amount of give. These are used to reflect or bounce back certain attacks, or to cushion the fall of allies.
Aside from the usual cube shape, Kekkai can be shaped into long walls to block access or slow down enemies as they keep breaking them.
A slower, vertical version of the Kekkai spear that lifts a target into the air. Kekkaishi also use this to raise themselves above battlefields, sometimes with an additional, outer elevator surrounding them to prevent attack.
Kekkai placed or produced in mid-air provide useful platforms for standing or traveling high above the ground. Yoshimori and Tokine created a relay system of these, allowing Gen (and later Souji) to bounce rapidly between them, landing swift strikes on enemies.
The Four-Corner Formation (四師方陣) is a technique in which four Kekkaishi form the four corners of a single Kekkai. Use of the technique is highly dangerous if not properly practiced. To preform the technique all four Kekkaishi must be in unison or risk destabilizing the Kekkai to the point that it will be almost impossible to reconfigure. The technique requires that one Kekkaishi creates the initial structure for the Four-Corner Formation and the initial footholds. Another Kekkaishi then can handle the remaining footholds and the other two focus on completely maintaining the Giant Kekkai. The formation requires the four separate powers of each Kekkaishi to compliment each other via synchronization. Once the four points have connected the four Kekkaishi mix their powers and focus it. Then in the instant the power is fully stabilized they must imagine themselves as pillars supporting the whole and focus that power upwards as one Ketsu.  After stabilizing the Kekkai the four Kekkaishi must compress it, the suppression power is all directed to a single point. Success or failure is determined by who controls the four-corner formation. Once it is a manageable size the four Kekkaishi then can Metsu the Kekkai with no problem.
Though not necessarily used for combat, the following Kekkai have also been used in the series.
Yoshimori frequently uses a Kekkai while he's sleeping to keep his grandfather at bay. He also uses a Kekkai to hide himself while he sleeps on the roof of the school while skipping class; he uses a Shikigami clone in his place so he doesn't get in trouble.
The Sensory Kekkai (探査用結界) is used frequently by Masamori to tracks enemies or objects by spreading his power out in the form of a vast ocean, which allows his landlord, Kurohime, to swim through it and bring him information. Sumiko Sumimura later confirms that this is a Kekkai meant for investigating, though her method is not as noticeable or disruptive to other Kekkaishi, and requires no landlord.
A Kekkai placed in a running enemy's path, so that they either run into it or stumble over it. Tokine sometimes uses this to test Yoshimori's reflexes (but he usually fails). Another variant of this is a gum-like Kekkai that the target's foot becomes stuck in.
Masamori makes mention of a Kekkai that surrounds Karasumori, and how it prevents surrounding areas from hearing the outrageous noises that are sometimes produced there. Shigemori also challenges Yoshimori by telling him to erect a soundproof Kekkai during his training so that he doesn't disturb the neighbors.
Masamori was able to create a Kekkai that allowed his teacup to fall through it, but trapped the tea itself inside it. He was also able to open a small opening in the lower corner of the Kekkai to pour the tea back into his cup.